mirror of
https://github.com/troglobit/finit.git
synced 2026-12-04 21:58:19 +00:00
Hide command line arguments from ps, for forked children like getty
The built-in gety in Finit forks but does not execv(). To prevent confusion on the part of the user, this patch hides all command line arguments to PID 1 so it won't show up in ps listings of children. Finit currently reads its arguments from the kernel /proc/cmdline, it has hard-coded paths to /etc/finit.conf etc. A future version of Finit may take command line params, in which case this patch should be moved after any getopt() handling. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
85fe613b30
commit
c391e04983
1 file changed
+13
+13
@@ -325,6 +325,19 @@ int main(int argc, char* argv[])
|
|||||||
if (getpid() != 1)
|
if (getpid() != 1)
|
||||||
return client(argc, argv);
|
return client(argc, argv);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hide command line arguments from ps (in particular for
|
||||||
|
* forked children that don't execv()). This is an ugly
|
||||||
|
* hack that only works on Linux.
|
||||||
|
* https://web.archive.org/web/20110227041321/http://netsplit.com/2007/01/10/hiding-arguments-from-ps/
|
||||||
|
*/
|
||||||
|
if (argc > 1) {
|
||||||
|
char *arg_end;
|
||||||
|
|
||||||
|
arg_end = argv[argc-1] + strlen (argv[argc-1]);
|
||||||
|
*arg_end = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initalize event context.
|
* Initalize event context.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in new issue
Block a user