component(developer/golang-123): Add Component
[oi-userland.git] / components / network / ntp / patches / 75-notroot.patch
blobd6cd3615cd1bf684f2dc243424251dfc1360f5e1
1 This works around the limitation of requiring root as the user. This has
2 been reported to the community as NTP bug 2422 "Allow ntpd to be started as
3 non-root if appropriate POSIX capabilities are set" which although reported
4 as Linux specific, is being used to track the Solaris issue as well.
6 This particular solution is not being passed to the community as a solution
7 because it is specific to Solaris and to our specific use of SMF and is not
8 really suitable as a general solution.
10 --- ntpd/ntpd.c.orig
11 +++ ntpd/ntpd.c
12 @@ -922,17 +922,19 @@
14 /* MPE lacks the concept of root */
15 # if defined(HAVE_GETUID) && !defined(MPE)
16 - uid = getuid();
17 - if (uid && !HAVE_OPT( SAVECONFIGQUIT )
18 + if (!getenv("SMF_FMRI")) {
19 + uid = getuid();
20 + if (uid && !HAVE_OPT( SAVECONFIGQUIT )
21 # if defined(HAVE_TRUSTEDBSD_MAC)
22 - /* We can run as non-root if the mac_ntpd policy is enabled. */
23 - && mac_is_present("ntpd") != 1
24 + /* We can run as non-root if the mac_ntpd policy is enabled. */
25 + && mac_is_present("ntpd") != 1
26 # endif
27 - ) {
28 - msyslog_term = TRUE;
29 - msyslog(LOG_ERR,
30 - "must be run as root, not uid %ld", (long)uid);
31 - exit(1);
32 + ) {
33 + msyslog_term = TRUE;
34 + msyslog(LOG_ERR,
35 + "must be run as root, not uid %ld", (long)uid);
36 + exit(1);
37 + }
39 # endif