@ -1,7 +1,7 @@ | |||
From f67a51ea7b11f1082dac77beb632f4d71f397584 Mon Sep 17 00:00:00 2001 | |||
From be678b846a8bbeede06d66a630a64a19c589c45f Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:01:57 -0600 | |||
Subject: [PATCH 04/12] remove unused dns_pid | |||
Subject: [PATCH 03/16] remove unused dns_pid | |||
--- | |||
src/usr.sbin/ntpd/ntp.c | 4 ++-- |
@ -1,14 +1,14 @@ | |||
From 802b2ccf5257b840ed252a2bc1a6cb70a37b3f57 Mon Sep 17 00:00:00 2001 | |||
From 06c8339b3a1bde6f71d437d792ae01d118832fb4 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Wed, 31 Dec 2014 22:39:58 -0600 | |||
Subject: [PATCH 14/14] add MAX macro | |||
Subject: [PATCH 04/16] add MAX macro | |||
--- | |||
src/usr.sbin/ntpd/ntpd.h | 4 ++++ | |||
1 file changed, 4 insertions(+) | |||
diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h | |||
index f8d6382..5ac0bbb 100644 | |||
index aa9858b..61a447f 100644 | |||
--- a/src/usr.sbin/ntpd/ntpd.h | |||
+++ b/src/usr.sbin/ntpd/ntpd.h | |||
@@ -72,6 +72,10 @@ |
@ -0,0 +1,38 @@ | |||
From b0d68d365d6b4512a5a07d14e56f0c51cdeae0c3 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Thu, 1 Jan 2015 13:06:38 -0600 | |||
Subject: [PATCH 05/16] 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. | |||
--- | |||
src/usr.sbin/ntpd/ntp.c | 13 +++++++++---- | |||
1 file changed, 9 insertions(+), 4 deletions(-) | |||
diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c | |||
index ddbcedd..26701c8 100644 | |||
--- a/src/usr.sbin/ntpd/ntp.c | |||
+++ b/src/usr.sbin/ntpd/ntp.c | |||
@@ -121,10 +121,15 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf, | |||
ntp_dns(pipe_dns, nconf, pw); | |||
close(pipe_dns[1]); | |||
- if (stat(pw->pw_dir, &stb) == -1) | |||
- fatal("stat"); | |||
- if (stb.st_uid != 0 || (stb.st_mode & (S_IWGRP|S_IWOTH)) != 0) | |||
- fatalx("bad privsep dir permissions"); | |||
+ if (stat(pw->pw_dir, &stb) == -1) { | |||
+ log_warn("privsep dir %s could not be opened", pw->pw_dir); | |||
+ exit(1); | |||
+ } | |||
+ if (stb.st_uid != 0 || (stb.st_mode & (S_IWGRP|S_IWOTH)) != 0) { | |||
+ log_warnx("bad privsep dir %s permissions: %o", | |||
+ pw->pw_dir, stb.st_mode); | |||
+ exit(1); | |||
+ } | |||
if (chroot(pw->pw_dir) == -1) | |||
fatal("chroot"); | |||
if (chdir("/") == -1) | |||
-- | |||
1.9.1 | |||
@ -0,0 +1,31 @@ | |||
From 555e4346d4a441e2385b91c3188edbe9b093cfd5 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Thu, 1 Jan 2015 13:26:29 -0600 | |||
Subject: [PATCH 06/16] 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. | |||
--- | |||
src/usr.sbin/ntpd/ntp.c | 6 ++++++ | |||
1 file changed, 6 insertions(+) | |||
diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c | |||
index 26701c8..a24f305 100644 | |||
--- a/src/usr.sbin/ntpd/ntp.c | |||
+++ b/src/usr.sbin/ntpd/ntp.c | |||
@@ -147,6 +147,12 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf, | |||
conf = nconf; | |||
setup_listeners(se, conf, &listener_cnt); | |||
+ if (pw->pw_uid == 0 || pw->pw_gid == 0) | |||
+ fatal("privsep user cannot be root"); | |||
+ | |||
+ if (pw->pw_uid == geteuid() || pw->pw_gid == getegid()) | |||
+ fatal("privsep user cannot be the privileged user"); | |||
+ | |||
if (setgroups(1, &pw->pw_gid) || | |||
setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || | |||
setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) | |||
-- | |||
1.9.1 | |||
@ -1,7 +1,7 @@ | |||
From 20911c235ab4af36242a9b913bc41a3b1b0958cb Mon Sep 17 00:00:00 2001 | |||
From 204f212fd5905b8af28f22c49254be4a29923c94 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:00:12 -0600 | |||
Subject: [PATCH 03/12] Use LOG_NTP syslog facility. | |||
Subject: [PATCH 10/16] Use LOG_NTP syslog facility. | |||
FreeBSD PR: 114191 | |||
Submitted by: Robert Archer <freebsd@deathbeforedecaf.net> |
@ -1,7 +1,7 @@ | |||
From e73468f4e08442681c79e84edc62cf8e9f3b733a Mon Sep 17 00:00:00 2001 | |||
From e6c8f113fb20f3768e3c35b2f23c694a61c7c5f2 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:02:50 -0600 | |||
Subject: [PATCH 05/12] conditionally fill in sin_len/sin6_len if they exist | |||
Subject: [PATCH 11/16] conditionally fill in sin_len/sin6_len if they exist | |||
Should we even be setting these at all? Does anything really rely in | |||
this anymore? |
@ -1,7 +1,7 @@ | |||
From ec73e05867d8e80b1f5d056f35eea8f9011b8c3c Mon Sep 17 00:00:00 2001 | |||
From d874a2d6c44f3656289437b49002ba0f19ca63a2 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/14] EAI_NODATA does not exist everywhere | |||
Subject: [PATCH 12/16] EAI_NODATA does not exist everywhere | |||
FreeBSD says it is deprecated and should be removed. | |||
--- |
@ -1,34 +0,0 @@ | |||
From 47a111a45a541316d7ff9d844362b901f24f41e1 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Wed, 31 Dec 2014 08:47:45 -0600 | |||
Subject: [PATCH 12/12] don't be too stingy on braces | |||
Match if bracing of the block below it to improve readability. | |||
--- | |||
src/usr.sbin/ntpd/client.c | 3 ++- | |||
1 file changed, 2 insertions(+), 1 deletion(-) | |||
diff --git a/src/usr.sbin/ntpd/client.c b/src/usr.sbin/ntpd/client.c | |||
index 0271068..4bfbf90 100644 | |||
--- a/src/usr.sbin/ntpd/client.c | |||
+++ b/src/usr.sbin/ntpd/client.c | |||
@@ -139,7 +139,7 @@ client_query(struct ntp_peer *p) | |||
struct sockaddr *sa = (struct sockaddr *)&p->addr->ss; | |||
p->query->fd = socket(p->addr->ss.ss_family, SOCK_DGRAM, 0); | |||
- if (p->query->fd == -1) | |||
+ if (p->query->fd == -1) { | |||
if (errno == EAFNOSUPPORT) { | |||
log_warn("client_query socket"); | |||
client_nextaddr(p); | |||
@@ -147,6 +147,7 @@ client_query(struct ntp_peer *p) | |||
return (-1); | |||
} else | |||
fatal("client_query socket"); | |||
+ } | |||
#ifdef SO_RTABLE | |||
if (p->rtable != -1 && | |||
-- | |||
1.9.1 | |||
@ -1,7 +1,7 @@ | |||
From 84100327370fec7ef44555c380e09e94b8a21c7c Mon Sep 17 00:00:00 2001 | |||
From edb43d28257d62671d7b364a55375bcf1332a1b9 Mon Sep 17 00:00:00 2001 | |||
From: Brent Cook <busterb@gmail.com> | |||
Date: Tue, 30 Dec 2014 09:20:03 -0600 | |||
Subject: [PATCH 09/12] update ntpd.conf to indicate OS-dependent options | |||
Subject: [PATCH 14/16] update ntpd.conf to indicate OS-dependent options | |||
Also, clarify listening behavior based on a patch from | |||
Dererk <dererk@debian.org> |