components/ntp/patches/75-notroot.patch
author Channappa BV<channappa.vakkalad@oracle.com>
Thu, 03 Nov 2016 22:18:09 -0700
changeset 7244 0d8fd6bb915f
parent 5962 cb383b2a2d0a
permissions -rw-r--r--
25039888 Update timezone data to 2016i

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