mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 05:22:48 +07:00
Move argument-hiding magic together with argument parsing
Everything else Finit does related to parsing the incoming arguments is in conf.c, so it makes sense for this block to also reside there.
This commit is contained in:
+18
@@ -59,6 +59,22 @@ static TAILQ_HEAD(head, conf_change) conf_change_list = TAILQ_HEAD_INITIALIZER(c
|
||||
static int parse_conf(char *file);
|
||||
static void drop_changes(void);
|
||||
|
||||
static void hide_args(int argc, char *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 = ' ';
|
||||
}
|
||||
}
|
||||
|
||||
static void parse_arg(char *arg, int *dbg)
|
||||
{
|
||||
/* Catches finit_debug (deprecated), --debug, and debug */
|
||||
@@ -84,6 +100,8 @@ void conf_parse_cmdline(int argc, char *argv[])
|
||||
for (int i = 1; i < argc; i++)
|
||||
parse_arg(argv[i], &dbg);
|
||||
|
||||
hide_args(argc, argv);
|
||||
|
||||
fp = fopen("/proc/cmdline", "r");
|
||||
if (!fp)
|
||||
goto done;
|
||||
|
||||
-13
@@ -298,19 +298,6 @@ int main(int argc, char *argv[])
|
||||
*/
|
||||
conf_parse_cmdline(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