From: Brian Utterback Date: Fri, 22 Jun 2007 16:52:24 +0000 (-0400) Subject: [Bug 864] Place ntpd service in maintenance mode if using SMF on Solaris X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85666bb52371996cfc7d1ab33efb448f49438f17;p=thirdparty%2Fntp.git [Bug 864] Place ntpd service in maintenance mode if using SMF on Solaris bk: 467bfe48jbB6nItR3S4Yk2uuDhoULA --- diff --git a/ChangeLog b/ChangeLog index 7d84498bde..262465e458 100644 --- 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. diff --git a/configure.ac b/configure.ac index 7ec7a31907..d5576b5186 100644 --- a/configure.ac +++ b/configure.ac @@ -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) ;; diff --git a/ntpd/Makefile.am b/ntpd/Makefile.am index 429b003559..a46031ea1d 100644 --- a/ntpd/Makefile.am +++ b/ntpd/Makefile.am @@ -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 diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index a1b5f8ab08..495b984c51 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -15,6 +15,9 @@ #include "ntp_string.h" #include +#ifdef HAVE_LIBSCF_H +#include +#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 */