@ -1,7 +1,7 @@ | |||
From 137e34d4af16d3f4c4b15de019e50a719db6cc5a Mon Sep 17 00:00:00 2001 | |||
From 76505eff3c813ccdc4bece27e96f26cf04a1ffca Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Thu, 1 Jan 2015 13:06:38 -0600 | |||
Subject: [PATCH 02/12] be more verbose when logging privsep errors | |||
Subject: [PATCH 01/11] be more verbose when logging privsep errors | |||
Make it easy for a sysadmin to diagnose a privilege separation path | |||
problem without looking at the source code. |
@ -1,120 +0,0 @@ | |||
From 7720c6cbb7ff30abc1c4d85aada869294cc3db47 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Sun, 4 Jan 2015 22:19:51 -0600 | |||
Subject: [PATCH 01/12] make fatal/fatalx variadic like the other logging | |||
functions | |||
this factors out the guts of log_warn and adds logerr | |||
--- | |||
src/usr.sbin/ntpd/log.c | 54 +++++++++++++++++++++++++++--------------------- | |||
src/usr.sbin/ntpd/ntpd.h | 4 ++-- | |||
2 files changed, 32 insertions(+), 26 deletions(-) | |||
diff --git a/src/usr.sbin/ntpd/log.c b/src/usr.sbin/ntpd/log.c | |||
index 618f4cc..e92924e 100644 | |||
--- a/src/usr.sbin/ntpd/log.c | |||
+++ b/src/usr.sbin/ntpd/log.c | |||
@@ -71,29 +71,33 @@ vlog(int pri, const char *fmt, va_list ap) | |||
vsyslog(pri, fmt, ap); | |||
} | |||
- | |||
void | |||
-log_warn(const char *emsg, ...) | |||
+vlogerr(int pri, const char *fmt, va_list ap) | |||
{ | |||
char *nfmt; | |||
- va_list ap; | |||
/* best effort to even work in out of memory situations */ | |||
- if (emsg == NULL) | |||
- logit(LOG_CRIT, "%s", strerror(errno)); | |||
- else { | |||
- va_start(ap, emsg); | |||
- | |||
- if (asprintf(&nfmt, "%s: %s", emsg, strerror(errno)) == -1) { | |||
+ if (fmt) { | |||
+ if (asprintf(&nfmt, "%s: %s", fmt, strerror(errno)) == -1) { | |||
/* we tried it... */ | |||
- vlog(LOG_CRIT, emsg, ap); | |||
+ vlog(LOG_CRIT, fmt, ap); | |||
logit(LOG_CRIT, "%s", strerror(errno)); | |||
} else { | |||
vlog(LOG_CRIT, nfmt, ap); | |||
free(nfmt); | |||
} | |||
- va_end(ap); | |||
- } | |||
+ } else | |||
+ logit(LOG_CRIT, "%s", strerror(errno)); | |||
+} | |||
+ | |||
+void | |||
+log_warn(const char *emsg, ...) | |||
+{ | |||
+ va_list ap; | |||
+ | |||
+ va_start(ap, emsg); | |||
+ vlogerr(LOG_CRIT, emsg, ap); | |||
+ va_end(ap); | |||
} | |||
void | |||
@@ -129,25 +133,27 @@ log_debug(const char *emsg, ...) | |||
} | |||
void | |||
-fatal(const char *emsg) | |||
+fatal(const char *emsg, ...) | |||
{ | |||
- if (emsg == NULL) | |||
- logit(LOG_CRIT, "fatal: %s", strerror(errno)); | |||
- else | |||
- if (errno) | |||
- logit(LOG_CRIT, "fatal: %s: %s", | |||
- emsg, strerror(errno)); | |||
- else | |||
- logit(LOG_CRIT, "fatal: %s", emsg); | |||
+ va_list ap; | |||
+ | |||
+ va_start(ap, emsg); | |||
+ vlogerr(LOG_CRIT, emsg, ap); | |||
+ va_end(ap); | |||
exit(1); | |||
} | |||
void | |||
-fatalx(const char *emsg) | |||
+fatalx(const char *emsg, ...) | |||
{ | |||
- errno = 0; | |||
- fatal(emsg); | |||
+ va_list ap; | |||
+ | |||
+ va_start(ap, emsg); | |||
+ vlog(LOG_CRIT, emsg, ap); | |||
+ va_end(ap); | |||
+ | |||
+ exit(1); | |||
} | |||
const char * | |||
diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h | |||
index 4a768d8..31bc5a0 100644 | |||
--- a/src/usr.sbin/ntpd/ntpd.h | |||
+++ b/src/usr.sbin/ntpd/ntpd.h | |||
@@ -269,8 +269,8 @@ void log_warn(const char *, ...); | |||
void log_warnx(const char *, ...); | |||
void log_info(const char *, ...); | |||
void log_debug(const char *, ...); | |||
-void fatal(const char *); | |||
-void fatalx(const char *); | |||
+void fatal(const char *, ...); | |||
+void fatalx(const char *, ...); | |||
const char *log_sockaddr(struct sockaddr *); | |||
/* ntp.c */ | |||
-- | |||
1.9.1 | |||
@ -1,7 +1,7 @@ | |||
From a27d00d02e1c1bba00bcb5195c1aa90fc557fd60 Mon Sep 17 00:00:00 2001 | |||
From 360d2de5b706fda9555348d4df4eb78a5eed7b3d Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Thu, 1 Jan 2015 13:26:29 -0600 | |||
Subject: [PATCH 03/12] do not allow privsep user to be a privileged user | |||
Subject: [PATCH 02/11] do not allow privsep user to be a privileged user | |||
This may need to be a function call for different platforms with | |||
different capability / privilege mechanisms. |
@ -1,7 +1,7 @@ | |||
From 9d6d657754752aa3530e4669a91a7293039c9e81 Mon Sep 17 00:00:00 2001 | |||
From fa13ece45c6f03bcbd2c19255c9b8b71f740ef7f Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:10:22 -0600 | |||
Subject: [PATCH 04/12] Handle IPv6 DNS records on IPv4 networks more liberally | |||
Subject: [PATCH 03/11] Handle IPv6 DNS records on IPv4 networks more liberally | |||
Rather than fail on IPv4 only networks when seeing an IPv6 DNS record, | |||
just give a warning. |
@ -1,7 +1,7 @@ | |||
From 7fe3c31fe71685b88e88af88c64802735b7661ec Mon Sep 17 00:00:00 2001 | |||
From d15a3b100ee3b497582df84d91c9ff989654cd37 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:04:08 -0600 | |||
Subject: [PATCH 06/12] EAI_NODATA does not exist everywhere | |||
Subject: [PATCH 05/11] EAI_NODATA does not exist everywhere | |||
FreeBSD says it is deprecated #ifdef's it out. | |||
@ -0,0 +1,46 @@ | |||
From ce2a92acf47861cf55d00a7f8ccd7037758c0f63 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:00:12 -0600 | |||
Subject: [PATCH 06/11] Use LOG_NTP syslog facility if it is available | |||
FreeBSD PR: 114191 | |||
Submitted by: Robert Archer <freebsd@deathbeforedecaf.net> | |||
--- | |||
src/usr.sbin/ntpd/log.c | 7 +++++-- | |||
1 file changed, 5 insertions(+), 2 deletions(-) | |||
diff --git a/src/usr.sbin/ntpd/log.c b/src/usr.sbin/ntpd/log.c | |||
index 1d8304b..3b751b5 100644 | |||
--- a/src/usr.sbin/ntpd/log.c | |||
+++ b/src/usr.sbin/ntpd/log.c | |||
@@ -30,6 +30,10 @@ | |||
#include "log.h" | |||
+#ifndef LOG_NTP | |||
+#define LOG_NTP LOG_DAEMON | |||
+#endif | |||
+ | |||
#define TRACE_DEBUG 0x1 | |||
static int foreground; | |||
@@ -39,7 +43,6 @@ void vlog(int, const char *, va_list); | |||
void logit(int, const char *, ...) | |||
__attribute__((format (printf, 2, 3))); | |||
- | |||
void | |||
log_init(int n_foreground) | |||
{ | |||
@@ -47,7 +50,7 @@ log_init(int n_foreground) | |||
foreground = n_foreground; | |||
if (! foreground) | |||
- openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON); | |||
+ openlog(__progname, LOG_PID | LOG_NDELAY, LOG_NTP); | |||
tzset(); | |||
} | |||
-- | |||
1.9.1 | |||
@ -1,38 +0,0 @@ | |||
From 89d3d178a801c9fdaa59bf05def788a1eec9662b Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:00:12 -0600 | |||
Subject: [PATCH 07/12] Use LOG_NTP syslog facility. | |||
FreeBSD PR: 114191 | |||
Submitted by: Robert Archer <freebsd@deathbeforedecaf.net> | |||
--- | |||
src/usr.sbin/ntpd/log.c | 6 +++++- | |||
1 file changed, 5 insertions(+), 1 deletion(-) | |||
diff --git a/src/usr.sbin/ntpd/log.c b/src/usr.sbin/ntpd/log.c | |||
index e92924e..22e1f05 100644 | |||
--- a/src/usr.sbin/ntpd/log.c | |||
+++ b/src/usr.sbin/ntpd/log.c | |||
@@ -26,6 +26,10 @@ | |||
#include "ntpd.h" | |||
+#ifndef LOG_NTP | |||
+#define LOG_NTP LOG_DAEMON | |||
+#endif | |||
+ | |||
int debug; | |||
extern int debugsyslog; | |||
@@ -37,7 +41,7 @@ log_init(int n_debug) | |||
debug = n_debug; | |||
if (!debug) | |||
- openlog(__progname, LOG_PID | LOG_NDELAY, LOG_DAEMON); | |||
+ openlog(__progname, LOG_PID | LOG_NDELAY, LOG_NTP); | |||
tzset(); | |||
} | |||
-- | |||
1.9.1 | |||
@ -1,7 +1,7 @@ | |||
From 1c97bf8f63a68525d343216fec27565192c001e0 Mon Sep 17 00:00:00 2001 | |||
From 69da53e369dc71809ea54003f4c20c5f1a11eb0d Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:02:50 -0600 | |||
Subject: [PATCH 08/12] conditionally fill in sin_len/sin6_len if they exist | |||
Subject: [PATCH 07/11] conditionally fill in sin_len/sin6_len if they exist | |||
--- | |||
src/usr.sbin/ntpd/config.c | 8 ++++++++ |
@ -1,7 +1,7 @@ | |||
From 67a166ce4c0e337b3315ea0c6b21a87e60198fcf Mon Sep 17 00:00:00 2001 | |||
From 9c3c4a91d822a4abf6c204a73ffde3abc4b8aad8 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:20:03 -0600 | |||
Subject: [PATCH 10/12] update ntpd.conf to indicate OS-dependent options | |||
Subject: [PATCH 09/11] update ntpd.conf to indicate OS-dependent options | |||
Also, clarify listening behavior based on a patch from | |||
Dererk <dererk@debian.org> |