]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 864] Place ntpd service in maintenance mode if using SMF on Solaris
authorBrian Utterback <utterback@ntp.org>
Fri, 22 Jun 2007 16:52:24 +0000 (12:52 -0400)
committerBrian Utterback <utterback@ntp.org>
Fri, 22 Jun 2007 16:52:24 +0000 (12:52 -0400)
bk: 467bfe48jbB6nItR3S4Yk2uuDhoULA

ChangeLog
configure.ac
ntpd/Makefile.am
ntpd/ntp_proto.c

index 7d84498bde47f2d83b808c1b0a638dfd60b4921c..262465e4589a86809d644e0e031f35e7a891f4d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 864] Place ntpd service in maintenance mode if using SMF on Solaris
 * Start using 'design by contract' assertions.
 * Allow null driftfile.
 * leap second infrastructure fixes from Dave Mills.
index 7ec7a3190747dafa190343bfcdf439b4799fd355..d5576b51861f5808e7d27acc580bb62a542bbde7 100644 (file)
@@ -201,7 +201,13 @@ case "$ac_linuxcaps$ac_cv_header_sys_capability_h$ac_cv_header_sys_prctl_h" in
     LIBS="$LIBS -lcap"
     ;;
 esac
-
+AC_CHECK_HEADERS(libscf.h)
+case "$ac_cv_header_libscf_h" in
+ yes)
+    AC_SUBST(LSCF, [-lscf])
+    ;;
+esac
+AC_CHECK_FUNC(setppriv,AC_DEFINE(HAVE_SOLARIS_PRIVS, ,[Are Solaris privileges available?]), )
 case "$build" in
  $host)
     ;;
index 429b003559920c7ee0a3e2d738d59f86427984ed..a46031ea1d24132a485f813c27f9790bdb55ab05 100644 (file)
@@ -23,8 +23,8 @@ man_MANS=     ntpd.1
 # sqrt                                ntp_control.o
 # floor                               refclock_wwv.o
 # which are (usually) provided by -lm.
-ntpd_LDADD = $(LDADD) -lm @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a
-ntpdsim_LDADD = $(LDADD) -lm @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntpsim.a
+ntpd_LDADD = $(LDADD) -lm @LCRYPTO@ @LSCF@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+ntpdsim_LDADD = $(LDADD) -lm @LCRYPTO@ @LSCF@ $(LIBOPTS_LDADD) ../libntp/libntpsim.a
 ntpdsim_CFLAGS = $(CFLAGS) -DSIM
 check_y2k_LDADD = $(LDADD) ../libntp/libntp.a
 DISTCLEANFILES = .version version.c
index a1b5f8ab083675832aeeb423e2fc54b15cd9b0f2..495b984c51d8e211454860fffb2931ea6e4ab2c9 100644 (file)
@@ -15,6 +15,9 @@
 #include "ntp_string.h"
 
 #include <stdio.h>
+#ifdef HAVE_LIBSCF_H
+#include <libscf.h>
+#endif
 
 #if defined(VMS) && defined(VMS_LOCALUNIT)     /*wjm*/
 #include "ntp_refclock.h"
@@ -1265,6 +1268,9 @@ clock_update(void)
        u_char  ostratum;
        double  dtemp;
        l_fp    now;
+#ifdef HAVE_LIBSCF_H
+       char *fmri;
+#endif
 
        /*
         * There must be a system peer at this point. If we just changed
@@ -1293,6 +1299,19 @@ clock_update(void)
         */
        case -1:
                report_event(EVNT_SYSFAULT, NULL);
+#ifdef HAVE_LIBSCF_H
+               /* enter the maintenance mode */
+               if ((fmri = getenv("SMF_FMRI")) != NULL) {
+                       if (smf_maintain_instance(fmri, 0) < 0) {
+                               printf("smf_maintain_instance:%s\n",
+                                   scf_strerror(scf_error()));
+                               exit(1);
+                       }
+                       /* sleep until SMF kills us */
+                       for (;;)
+                               pause();
+               }
+#endif
                exit (-1);
                /* not reached */