components/ntp/patches/75-notroot.patch
author John Beck <John.Beck@Oracle.COM>
Fri, 09 Sep 2016 13:08:45 -0700
changeset 6889 83e26eb7e42b
parent 5962 cb383b2a2d0a
permissions -rw-r--r--
24624202 virtualenv needs bypass on S11

This works around the limitation of requiring root as the user. This has
been reported to the community as NTP bug 2422 "Allow ntpd to be started as 
non-root if appropriate POSIX capabilities are set" which although reported
as Linux specific, is being used to track the Solaris issue as well.

This particular solution is not being passed to the community as a solution
because it is specific to Solaris and to our specific use of SMF and is not
really suitable as a general solution.

--- ntpd/ntpd.c
+++ ntpd/ntpd.c
@@ -620,12 +620,14 @@ ntpdmain(
 
 	/* MPE lacks the concept of root */
 # if defined(HAVE_GETUID) && !defined(MPE)
-	uid = getuid();
-	if (uid && !HAVE_OPT( SAVECONFIGQUIT )) {
-		msyslog_term = TRUE;
-		msyslog(LOG_ERR,
-			"must be run as root, not uid %ld", (long)uid);
-		exit(1);
+	if (!getenv("SMF_FMRI")) {
+		uid = getuid();
+		if (uid && !HAVE_OPT( SAVECONFIGQUIT )) {
+			msyslog_term = TRUE;
+			msyslog(LOG_ERR,
+				"must be run as root, not uid %ld", (long)uid);
+			exit(1);
+		}
 	}
 # endif