Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

58 lines
1.5 KiB

From 235bc89116fdbbf177017c802a6042a82a0fb6bd Mon Sep 17 00:00:00 2001
From: Brent Cook <busterb@gmail.com>
Date: Mon, 12 Jan 2015 06:18:31 -0600
Subject: [PATCH 08/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 | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
index d1599e2..9dac894 100644
--- a/src/usr.sbin/ntpd/ntpd.c
+++ b/src/usr.sbin/ntpd/ntpd.c
@@ -117,6 +117,13 @@ usage(void)
#define PFD_PIPE 0
#define PFD_MAX 1
+/* 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[])
{
@@ -138,6 +145,8 @@ main(int argc, char *argv[])
char **argv0 = argv;
char *pname = NULL;
+ __progname = get_progname(argv[0]);
+
if (strcmp(__progname, "ntpctl") == 0) {
ctl_main(argc, argv);
/* NOTREACHED */
@@ -147,6 +156,16 @@ main(int argc, char *argv[])
memset(&lconf, 0, sizeof(lconf));
+#ifndef HAVE_SETPROCTITLE
+ /* 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:nPp:sSv")) != -1) {
switch (ch) {
case 'd':
--
2.10.1