Fwd: why are init's arguments wiped ?
Mike Frysinger
vapier at gentoo.org
Mon Feb 1 08:00:36 UTC 2016
On 01 Feb 2016 08:09, Nicolas CARRIER wrote:
> I wrote a little patch which adds the option not to wipe the arguments, but
> the result is a little bit odd, some 0 are inserted between "init" and the
> rest of the arguments. I must be because "/bin/init" is replaced with
> "init".
> So the proper patch should either :
> * inhibit this argv[0] modification too
> * perform a memmove to wipe those extra zeros
>
> Which one do you think is best ?
what do you mean "some 0" ? can you copy & paste the exact terminal
output you're seeing ?
argv settings has always been ugly in Linux ... the location of argv
is static as is the size. there's no way to tell the kernel to use
a different location so you're force to screw with the existing mem.
that said, i would just start with the simple answer: don't mess with
anything at all.
-mike
--- a/init/init.c
+++ b/init/init.c
@@ -1139,11 +1139,13 @@ int init_main(int argc UNUSED_PARAM, char **argv)
}
#endif
- /* Make the command line just say "init" - thats all, nothing else */
- strncpy(argv[0], "init", strlen(argv[0]));
- /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */
- while (*++argv)
- nuke_str(*argv);
+ if (FEATURE_INIT_ARGV_REWRITE) {
+ /* Make the command line just say "init" - thats all, nothing else */
+ strncpy(argv[0], "init", strlen(argv[0]));
+ /* Wipe argv[1]-argv[N] so they don't clutter the ps listing */
+ while (*++argv)
+ nuke_str(*argv);
+ }
/* Set up signal handlers */
if (!DEBUG_INIT) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20160201/8ff33e77/attachment-0001.asc>
More information about the busybox
mailing list