- From fd8a742d7e3f2ff92e812cdccfb3477b948340fc Mon Sep 17 00:00:00 2001
- From: Brent Cook <busterb@gmail.com>
- Date: Mon, 12 Jan 2015 06:18:31 -0600
- Subject: [PATCH 09/13] initialize setproctitle where needed
-
- We need to save a copy of argv and __progname to avoid setproctitle
- clobbering them.
- ---
- src/usr.sbin/ntpd/ntpd.c | 20 ++++++++++++++++++++
- 1 file changed, 20 insertions(+)
-
- diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
- index c7935bf..310e808 100644
- --- a/src/usr.sbin/ntpd/ntpd.c
- +++ b/src/usr.sbin/ntpd/ntpd.c
- @@ -112,6 +112,13 @@ usage(void)
- #define POLL_MAX 8
- #define PFD_PIPE 0
-
- +/* Saves a copy of argv for setproctitle emulation */
- +#ifndef HAVE_SETPROCTITLE
- +static char **saved_argv;
- +#endif
- +
- +char *get_progname(char *argv0);
- +
- int
- main(int argc, char *argv[])
- {
- @@ -124,6 +131,8 @@ main(int argc, char *argv[])
- struct passwd *pw;
- extern char *__progname;
-
- + __progname = get_progname(argv[0]);
- +
- if (strcmp(__progname, "ntpctl") == 0) {
- ctl_main(argc, argv);
- /* NOTREACHED */
- @@ -135,6 +144,17 @@ main(int argc, char *argv[])
-
- log_init(1); /* log to stderr until daemonized */
-
- +#ifndef HAVE_SETPROCTITLE
- + int i;
- + /* Prepare for later setproctitle emulation */
- + saved_argv = calloc(argc + 1, sizeof(*saved_argv));
- + for (i = 0; i < argc; i++)
- + saved_argv[i] = strdup(argv[i]);
- + saved_argv[i] = NULL;
- + compat_init_setproctitle(argc, argv);
- + argv = saved_argv;
- +#endif
- +
- while ((ch = getopt(argc, argv, "df:np:sSv")) != -1) {
- switch (ch) {
- case 'd':
- --
- 2.4.5
-
|