]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3062] Change the process name of forked DNS worker
authorJuergen Perlinger <perlinger@ntp.org>
Sun, 8 Jan 2017 10:16:33 +0000 (11:16 +0100)
committerJuergen Perlinger <perlinger@ntp.org>
Sun, 8 Jan 2017 10:16:33 +0000 (11:16 +0100)
 - applied patch by Reinhard Max. See bugzilla for limitations.

bk: 58721181FAOWje2k7bvWKPVo5xfJVQ

ChangeLog
include/ntpd.h
libntp/work_fork.c
ntpd/ntpd.c

index 0cb8c4fb4779b249944c144baf63c35be953e531..d73a9d85fad3593571c140d7a28f9dc39dc3f4c2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
+---
+* [Bug 3062] Change the process name of forked DNS worker <perlinger@ntp.org>
+  - applied patch by Reinhard Max. See bugzilla for limitations.
+
 ---
 (4.2.8p9) 2016/11/21 Released by Harlan Stenn <stenn@ntp.org>
-(4.2.8p9) 2016/MM/DD Released by Harlan Stenn <stenn@ntp.org>
 
 * [Sec 3119] Trap crash <perlinger@ntp.org>
 * [Sec 3118] Mode 6 information disclosure and DDoS vector <perlinger@ntp.org>
index 1f33bf456b2faa69670a92674cbef7fb0432bfd5..fd3328d9d4b21637a8bfdb27132a98162dd74e78 100644 (file)
@@ -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;
index 8223fdd2f9b29b5ce531422fc5d8b992ca9c2084..48fd998f6204eb0aa6ee5694f59da9d0ff224e35 100644 (file)
@@ -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.
index 9c6f94740c06cf04aa60a1268c802684a3b0f900..a0880be6c84b54a0ee52fea2aeca6fa572bdc8e8 100644 (file)
@@ -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 **);