mirror of
https://github.com/troglobit/finit.git
synced 2026-10-13 10:14:47 +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:
+14
-1
@@ -305,7 +305,7 @@ static void final_worker(void *work)
|
||||
finalize();
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct wq crank = {
|
||||
.cb = crank_worker
|
||||
@@ -325,6 +325,19 @@ int main(int argc, char* argv[])
|
||||
if (getpid() != 1)
|
||||
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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user