[Git][NTPsec/ntpsec][master] Under Linux, keep scheduler privileges (cap_sys_nice) when dropping root.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Jul 6 09:52:29 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
7ca77376 by Eric S. Raymond at 2016-07-06T05:51:26-04:00
Under Linux, keep scheduler privileges (cap_sys_nice) when dropping root.

- - - - -


1 changed file:

- ntpd/ntp_sandbox.c


Changes:

=====================================
ntpd/ntp_sandbox.c
=====================================
--- a/ntpd/ntp_sandbox.c
+++ b/ntpd/ntp_sandbox.c
@@ -63,7 +63,7 @@ bool sandbox(const bool droproot,
 		/* Drop super-user privileges and chroot now if the OS supports this */
 
 #  ifdef HAVE_LINUX_CAPABILITY
-		/* set flag: keep privileges accross setuid() call (we only really need cap_sys_time): */
+		/* set flag: keep privileges across setuid() call. */
 		if (prctl( PR_SET_KEEPCAPS, 1L, 0L, 0L, 0L ) == -1) {
 			msyslog( LOG_ERR, "prctl( PR_SET_KEEPCAPS, 1L ) failed: %m" );
 			exit(-1);
@@ -204,7 +204,7 @@ getgroup:
 			 *  We may be running under non-root uid now,
 			 *  but we still hold full root privileges!
 			 *  We drop all of them, except for the
-			 *  crucial one or two: cap_sys_time and
+			 *  crucial few: cap_sys_nice, cap_sys_time and
 			 *  cap_net_bind_service for doing dynamic
 			 *  interface tracking.
 			 */
@@ -212,8 +212,8 @@ getgroup:
 			char *captext;
 			
 			captext = want_dynamic_interface_tracking
-				      ? "cap_sys_time,cap_net_bind_service=pe"
-				      : "cap_sys_time=pe";
+				      ? "cap_sys_nice,cap_sys_time,cap_net_bind_service=pe"
+				      : "cap_sys_nice,cap_sys_time=pe";
 			caps = cap_from_text(captext);
 			if (!caps) {
 				msyslog(LOG_ERR,



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/7ca77376e62e1d8ad3e213664f3a7fd1bcec68ce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160706/753c3cd1/attachment.html>


More information about the vc mailing list