From: Juergen Perlinger Date: Sun, 8 Jan 2017 10:16:33 +0000 (+0100) Subject: [Bug 3062] Change the process name of forked DNS worker X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=95d3f4539ef8f2a2dc93cc8247fbe25b0e6a74de;p=thirdparty%2Fntp.git [Bug 3062] Change the process name of forked DNS worker - applied patch by Reinhard Max. See bugzilla for limitations. bk: 58721181FAOWje2k7bvWKPVo5xfJVQ --- diff --git a/ChangeLog b/ChangeLog index 0cb8c4fb4..d73a9d85f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ +--- +* [Bug 3062] Change the process name of forked DNS worker + - applied patch by Reinhard Max. See bugzilla for limitations. + --- (4.2.8p9) 2016/11/21 Released by Harlan Stenn -(4.2.8p9) 2016/MM/DD Released by Harlan Stenn * [Sec 3119] Trap crash * [Sec 3118] Mode 6 information disclosure and DDoS vector diff --git a/include/ntpd.h b/include/ntpd.h index 1f33bf456..fd3328d9d 100644 --- a/include/ntpd.h +++ b/include/ntpd.h @@ -321,6 +321,8 @@ extern void parse_cmdline_opts(int *, char ***); /* ntp_config.c */ extern char const * progname; +extern int saved_argc; +extern char **saved_argv; extern char *sys_phone[]; /* ACTS phone numbers */ #if defined(HAVE_SCHED_SETSCHEDULER) extern int config_priority_override; diff --git a/libntp/work_fork.c b/libntp/work_fork.c index 8223fdd2f..48fd998f6 100644 --- a/libntp/work_fork.c +++ b/libntp/work_fork.c @@ -24,6 +24,8 @@ int worker_process; addremove_io_fd_func addremove_io_fd; static volatile int worker_sighup_received; +int saved_argc = 0; +char **saved_argv; /* === function prototypes === */ static void fork_blocking_child(blocking_child *); @@ -502,6 +504,22 @@ fork_blocking_child( c->pid = getpid(); worker_process = TRUE; + /* + * Change the process name of the child to avoid confusion + * about ntpd trunning twice. + */ + if (saved_argc != 0) { + int argcc; + int argvlen = 0; + /* Clear argv */ + for (argcc = 0; argcc < saved_argc; argcc++) { + int l = strlen(saved_argv[argcc]); + argvlen += l + 1; + memset(saved_argv[argcc], 0, l); + } + strlcpy(saved_argv[0], "ntpd: asynchronous dns resolver", argvlen); + } + /* * In the child, close all files except stdin, stdout, stderr, * and the two child ends of the pipes. diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c index 9c6f94740..a0880be6c 100644 --- a/ntpd/ntpd.c +++ b/ntpd/ntpd.c @@ -230,8 +230,10 @@ static RETSIGTYPE no_debug (int); # endif /* !DEBUG */ #endif /* !SIM && !SYS_WINNT */ +#ifndef WORK_FORK int saved_argc; char ** saved_argv; +#endif #ifndef SIM int ntpdmain (int, char **);