components/ntp/patches/75-notroot.patch
author Mike Sullivan <Mike.Sullivan@Oracle.COM>
Thu, 13 Oct 2016 17:44:49 -0700
changeset 7105 60994030253b
parent 5962 cb383b2a2d0a
permissions -rw-r--r--
24616528 sqlite-3 fails to build with studio 12.5

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