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.

52 lines
1.3 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. From 3208d0b0529a09765c0674cbc4c57ab26ab30fc9 Mon Sep 17 00:00:00 2001
  2. From: Brent Cook <busterb@gmail.com>
  3. Date: Mon, 12 Jan 2015 06:18:31 -0600
  4. Subject: [PATCH 09/11] initialize setproctitle where needed
  5. We need to save a copy of argv and __progname to avoid setproctitle
  6. clobbering them.
  7. ---
  8. src/usr.sbin/ntpd/ntpd.c | 20 ++++++++++++++++++++
  9. 1 file changed, 20 insertions(+)
  10. diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
  11. index f5f0dbb..26463f6 100644
  12. --- a/src/usr.sbin/ntpd/ntpd.c
  13. +++ b/src/usr.sbin/ntpd/ntpd.c
  14. @@ -111,6 +111,13 @@ usage(void)
  15. #define POLL_MAX 8
  16. #define PFD_PIPE 0
  17. +/* Saves a copy of argv for setproctitle emulation */
  18. +#ifndef HAVE_SETPROCTITLE
  19. +static char **saved_argv;
  20. +#endif
  21. +
  22. +char *get_progname(char *argv0);
  23. +
  24. int
  25. main(int argc, char *argv[])
  26. {
  27. @@ -134,6 +141,19 @@ main(int argc, char *argv[])
  28. log_init(1); /* log to stderr until daemonized */
  29. + __progname = get_progname(argv[0]);
  30. +
  31. +#ifndef HAVE_SETPROCTITLE
  32. + int i;
  33. + /* Prepare for later setproctitle emulation */
  34. + saved_argv = calloc(argc + 1, sizeof(*saved_argv));
  35. + for (i = 0; i < argc; i++)
  36. + saved_argv[i] = strdup(argv[i]);
  37. + saved_argv[i] = NULL;
  38. + compat_init_setproctitle(argc, argv);
  39. + argv = saved_argv;
  40. +#endif
  41. +
  42. while ((ch = getopt(argc, argv, "df:np:sSv")) != -1) {
  43. switch (ch) {
  44. case 'd':
  45. --
  46. 1.9.1