2 * ntpd.c - main program for the fixed point NTP daemon
9 #include "ntp_machine.h"
12 #include "ntp_stdlib.h"
13 #include <ntp_random.h>
17 # include "ntpdsim-opts.h"
19 # include "ntpd-opts.h"
25 #ifdef HAVE_SYS_STAT_H
26 # include <sys/stat.h>
29 #if !defined(VMS) /*wjm*/
30 # ifdef HAVE_SYS_PARAM_H
31 # include <sys/param.h>
34 #ifdef HAVE_SYS_SIGNAL_H
35 # include <sys/signal.h>
39 #ifdef HAVE_SYS_IOCTL_H
40 # include <sys/ioctl.h>
41 #endif /* HAVE_SYS_IOCTL_H */
42 #ifdef HAVE_SYS_RESOURCE_H
43 # include <sys/resource.h>
44 #endif /* HAVE_SYS_RESOURCE_H */
45 #if defined(HAVE_RTPRIO)
46 # ifdef HAVE_SYS_RESOURCE_H
47 # include <sys/resource.h>
49 # ifdef HAVE_SYS_LOCK_H
50 # include <sys/lock.h>
52 # include <sys/rtprio.h>
55 # ifdef HAVE_SYS_LOCK_H
56 # include <sys/lock.h>
60 #if defined(HAVE_SCHED_SETSCHEDULER)
64 # ifdef HAVE_SYS_SCHED_H
65 # include <sys/sched.h>
69 #if defined(HAVE_SYS_MMAN_H)
70 # include <sys/mman.h>
78 # include <apollo/base.h>
79 #endif /* SYS_DOMAINOS */
82 #include "ntp_cmdargs.h"
84 #if 0 /* HMS: I don't think we need this. 961223 */
87 # include <sys/mman.h>
89 # include <sys/lock.h>
99 # include <sys/ci/ciioctl.h>
106 #ifdef HAVE_LINUX_CAPABILITIES
107 # include <sys/capability.h>
108 # include <sys/prctl.h>
113 * Signals we catch for debugging. If not debugging we ignore them.
115 #define MOREDEBUGSIG SIGUSR1
116 #define LESSDEBUGSIG SIGUSR2
119 * Signals which terminate us gracefully.
122 # define SIGDIE1 SIGHUP
123 # define SIGDIE3 SIGQUIT
124 # define SIGDIE2 SIGINT
125 # define SIGDIE4 SIGTERM
126 #endif /* SYS_WINNT */
128 #ifdef HAVE_DNSREGISTRATION
134 * Scheduling priority we run at
136 #define NTPD_PRIO (-12)
138 int priority_done = 2; /* 0 - Set priority */
139 /* 1 - priority is OK where it is */
140 /* 2 - Don't set priority */
141 /* 1 and 2 are pretty much the same */
147 volatile int debug = 0; /* No debugging by default */
150 int listen_to_virtual_ips = 1;
151 const char *specific_interface = NULL; /* interface name or IP address to bind to */
154 * No-fork flag. If set, we do not become a background daemon.
156 int nofork = 0; /* Fork by default */
160 char *user = NULL; /* User to switch to */
161 char *group = NULL; /* group to switch to */
162 char *chrootdir = NULL; /* directory to chroot to */
168 #endif /* HAVE_DROPROOT */
171 * Initializing flag. All async routines watch this and only do their
172 * thing when it is clear.
177 * Version declaration
179 extern const char *Version;
181 char const *progname;
187 * We put this here, since the argument profile is syscall-specific
189 extern int syscall P((int, ...));
190 #endif /* DECL_SYSCALL */
194 static RETSIGTYPE finish P((int));
199 static RETSIGTYPE moredebug P((int));
200 static RETSIGTYPE lessdebug P((int));
202 #else /* not DEBUG */
203 static RETSIGTYPE no_debug P((int));
204 #endif /* not DEBUG */
206 int ntpdmain P((int, char **));
207 static void set_process_priority P((void));
208 static void init_logging P((char const *));
209 static void setup_logfile P((void));
212 * Initialize the logging
215 init_logging(char const *name)
220 * Logging. This may actually work on the gizmo board. Find a name
221 * to log with by using the basename
223 cp = strrchr(name, '/');
232 openlog(cp, LOG_PID);
233 # else /* LOG_DAEMON */
236 # define LOG_NTP LOG_DAEMON
238 openlog(cp, LOG_PID | LOG_NDELAY, LOG_NTP);
241 setlogmask(LOG_UPTO(LOG_DEBUG));
244 setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */
245 # endif /* LOG_DAEMON */
246 #endif /* !SYS_WINNT && !VMS */
248 NLOG(NLOG_SYSINFO) /* conditional if clause for conditional syslog */
249 msyslog(LOG_NOTICE, "%s", Version);
254 * See if we should redirect the logfile
262 if (HAVE_OPT( LOGFILE )) {
263 const char *my_optarg = OPT_ARG( LOGFILE );
266 if(strcmp(my_optarg, "stderr") == 0)
268 else if(strcmp(my_optarg, "stdout") == 0)
271 new_file = fopen(my_optarg, "a");
272 if (new_file != NULL) {
274 msyslog(LOG_NOTICE, "logging to file %s", my_optarg);
275 if (syslog_file != NULL &&
276 fileno(syslog_file) != fileno(new_file))
277 (void)fclose(syslog_file);
279 syslog_file = new_file;
284 "Cannot open log file %s",
296 return ntpsim(argc, argv);
299 #ifdef NO_MAIN_ALLOWED
300 CALL(ntpd,"ntpd",ntpdmain);
309 return ntpdmain(argc, argv);
311 #endif /* SYS_WINNT */
312 #endif /* NO_MAIN_ALLOWED */
317 * OK. AIX is different than solaris in how it implements plock().
318 * If you do NOT adjust the stack limit, you will get the MAXIMUM
319 * stack size allocated and PINNED with you program. To check the
320 * value, use ulimit -a.
322 * To fix this, we create an automatic variable and set our stack limit
323 * to that PLUS 32KB of extra space (we need some headroom).
325 * This subroutine gets the stack address.
327 * Grover Davidson and Matt Ladendorf
338 * Signal handler for SIGDANGER.
341 catch_danger(int signo)
343 msyslog(LOG_INFO, "ntpd: setpgid(): %m");
344 /* Make the system believe we'll free something, but don't do it! */
350 * Set the process priority
353 set_process_priority(void)
358 msyslog(LOG_DEBUG, "set_process_priority: %s: priority_done is <%d>",
360 ? "Leave priority alone"
361 : "Attempt to set priority"
367 priority_done += NT_set_process_priority();
370 #if defined(HAVE_SCHED_SETSCHEDULER)
371 if (!priority_done) {
372 extern int config_priority_override, config_priority;
374 struct sched_param sched;
376 pmax = sched_get_priority_max(SCHED_FIFO);
377 sched.sched_priority = pmax;
378 if ( config_priority_override ) {
379 pmin = sched_get_priority_min(SCHED_FIFO);
380 if ( config_priority > pmax )
381 sched.sched_priority = pmax;
382 else if ( config_priority < pmin )
383 sched.sched_priority = pmin;
385 sched.sched_priority = config_priority;
387 if ( sched_setscheduler(0, SCHED_FIFO, &sched) == -1 )
388 msyslog(LOG_ERR, "sched_setscheduler(): %m");
392 #endif /* HAVE_SCHED_SETSCHEDULER */
393 #if defined(HAVE_RTPRIO)
395 if (!priority_done) {
398 srtp.type = RTP_PRIO_REALTIME; /* was: RTP_PRIO_NORMAL */
399 srtp.prio = 0; /* 0 (hi) -> RTP_PRIO_MAX (31,lo) */
401 if (rtprio(RTP_SET, getpid(), &srtp) < 0)
402 msyslog(LOG_ERR, "rtprio() error: %m");
406 # else /* not RTP_SET */
407 if (!priority_done) {
408 if (rtprio(0, 120) < 0)
409 msyslog(LOG_ERR, "rtprio() error: %m");
413 # endif /* not RTP_SET */
414 #endif /* HAVE_RTPRIO */
415 #if defined(NTPD_PRIO) && NTPD_PRIO != 0
416 # ifdef HAVE_ATT_NICE
417 if (!priority_done) {
419 if (-1 == nice (NTPD_PRIO) && errno != 0)
420 msyslog(LOG_ERR, "nice() error: %m");
424 # endif /* HAVE_ATT_NICE */
425 # ifdef HAVE_BSD_NICE
426 if (!priority_done) {
427 if (-1 == setpriority(PRIO_PROCESS, 0, NTPD_PRIO))
428 msyslog(LOG_ERR, "setpriority() error: %m");
432 # endif /* HAVE_BSD_NICE */
433 #endif /* NTPD_PRIO && NTPD_PRIO != 0 */
435 msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority");
440 * Main program. Initialize us, disconnect us from the tty if necessary,
441 * and loop waiting for I/O and/or timer expiries.
450 struct recvbuf *rbuf;
451 #ifdef _AIX /* HMS: ifdef SIGDANGER? */
457 initializing = 1; /* mark that we are initializing */
460 int optct = optionProcess(
471 /* HMS: is this lame? Should we process -l first? */
473 init_logging(progname); /* Open the log file */
487 #if defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */
494 msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid);
495 printf("must be run as root, not uid %ld", (long)uid);
502 if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) {
504 "ntpd: OpenSSL version mismatch. Built against %lx, you have %lx\n",
505 OPENSSL_VERSION_NUMBER, SSLeay());
510 /* getstartup(argc, argv); / * startup configuration, may set debug */
513 debug = DESC(DEBUG_LEVEL).optOccCt;
515 printf("%s\n", Version);
519 * Enable the Multi-Media Timer for Windows?
522 if (HAVE_OPT( MODIFYMMTIMER ))
523 set_mm_timer(MM_TIMER_HIRES);
526 if (HAVE_OPT( NOFORK ) || HAVE_OPT( QUIT ))
529 if (HAVE_OPT( NOVIRTUALIPS ))
530 listen_to_virtual_ips = 0;
532 if (HAVE_OPT( INTERFACE )) {
534 int ifacect = STACKCT_OPT( INTERFACE );
535 char** ifaces = STACKLST_OPT( INTERFACE );
537 /* malloc space for the array of names */
538 while (ifacect-- > 0) {
539 next_iface = *ifaces++;
542 specific_interface = OPT_ARG( INTERFACE );
546 if (HAVE_OPT( NICE ))
549 #if defined(HAVE_SCHED_SETSCHEDULER)
550 if (HAVE_OPT( PRIORITY )) {
551 config_priority = OPT_VALUE_PRIORITY;
552 config_priority_override = 1;
559 * Initialize the time structures and variables
567 * Initialize random generator and public key pair
571 ntp_srandom((int)(now.l_i * now.l_uf));
573 #ifdef HAVE_DNSREGISTRATION
574 /* HMS: does this have to happen this early? */
575 msyslog(LOG_INFO, "Attemping to register mDNS");
576 if ( DNSServiceRegister (&mdns, 0, 0, NULL, "_ntp._udp", NULL, NULL, htons(NTP_PORT), 0, NULL, NULL, NULL) != kDNSServiceErr_NoError ) {
577 msyslog(LOG_ERR, "Unable to register mDNS");
584 * Detach us from the terminal. May need an #ifndef GIZMO.
595 # else /* not HAVE_DAEMON */
596 if (fork()) /* HMS: What about a -1? */
600 #if !defined(F_CLOSEM)
603 #endif /* not F_CLOSEM */
605 #if defined(F_CLOSEM)
607 * From 'Writing Reliable AIX Daemons,' SG24-4946-00,
608 * by Eric Agar (saves us from doing 32767 system
611 if (fcntl(0, F_CLOSEM, 0) == -1)
612 msyslog(LOG_ERR, "ntpd: failed to close open files(): %m");
613 #else /* not F_CLOSEM */
615 # if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
616 max_fd = sysconf(_SC_OPEN_MAX);
617 # else /* HAVE_SYSCONF && _SC_OPEN_MAX */
618 max_fd = getdtablesize();
619 # endif /* HAVE_SYSCONF && _SC_OPEN_MAX */
620 for (s = 0; s < max_fd; s++)
621 (void) close((int)s);
622 #endif /* not F_CLOSEM */
631 proc2_$who_am_i(&puid);
632 proc2_$make_server(&puid, &st);
634 #endif /* SYS_DOMAINOS */
635 #if defined(HAVE_SETPGID) || defined(HAVE_SETSID)
637 if (setsid() == (pid_t)-1)
638 msyslog(LOG_ERR, "ntpd: setsid(): %m");
640 if (setpgid(0, 0) == -1)
641 msyslog(LOG_ERR, "ntpd: setpgid(): %m");
643 #else /* HAVE_SETPGID || HAVE_SETSID */
645 # if defined(TIOCNOTTY)
648 fid = open("/dev/tty", 2);
651 (void) ioctl(fid, (u_long) TIOCNOTTY, (char *) 0);
654 # endif /* defined(TIOCNOTTY) */
655 # ifdef HAVE_SETPGRP_0
657 # else /* HAVE_SETPGRP_0 */
658 (void) setpgrp(0, getpid());
659 # endif /* HAVE_SETPGRP_0 */
661 #endif /* HAVE_SETPGID || HAVE_SETSID */
663 /* Don't get killed by low-on-memory signal. */
664 sa.sa_handler = catch_danger;
665 sigemptyset(&sa.sa_mask);
666 sa.sa_flags = SA_RESTART;
668 (void) sigaction(SIGDANGER, &sa, NULL);
671 # endif /* not HAVE_DAEMON */
672 # endif /* SYS_WINNT */
674 # endif /* NODETACH */
677 setup_logfile(); /* We lost any redirect when we daemonized */
681 * SCO OpenServer's system clock offers much more precise timekeeping
682 * on the base CPU than the other CPUs (for multiprocessor systems),
683 * so we must lock to the base CPU.
686 int fd = open("/dev/at1", O_RDONLY);
689 if (ioctl(fd, ACPU_LOCK, &zero) < 0)
690 msyslog(LOG_ERR, "cannot lock to base CPU: %m");
693 * If we can't open the device, this probably just isn't
694 * a multiprocessor system, so we're A-OK.
699 #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE)
700 # ifdef HAVE_SETRLIMIT
702 * Set the stack limit to something smaller, so that we don't lock a lot
703 * of unused stack memory.
708 /* HMS: must make the rlim_cur amount configurable */
709 if (getrlimit(RLIMIT_STACK, &rl) != -1
710 && (rl.rlim_cur = 50 * 4096) < rl.rlim_max)
712 if (setrlimit(RLIMIT_STACK, &rl) == -1)
715 "Cannot adjust stack limit for mlockall: %m");
718 # ifdef RLIMIT_MEMLOCK
720 * The default RLIMIT_MEMLOCK is very low on Linux systems.
721 * Unless we increase this limit malloc calls are likely to
722 * fail if we drop root privlege. To be useful the value
723 * has to be larger than the largest ntpd resident set size.
725 rl.rlim_cur = rl.rlim_max = 32*1024*1024;
726 if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) {
727 msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m");
729 # endif /* RLIMIT_MEMLOCK */
731 # endif /* HAVE_SETRLIMIT */
733 * lock the process into memory
735 if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
736 msyslog(LOG_ERR, "mlockall(): %m");
737 #else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
742 * set the stack limit for AIX for plock().
743 * see get_aix_stack() for more info.
745 if (ulimit(SET_STACKLIM, (get_aix_stack() - 8*4096)) < 0)
747 msyslog(LOG_ERR,"Cannot adjust stack limit for plock on AIX: %m");
751 * lock the process into memory
753 if (plock(PROCLOCK) < 0)
754 msyslog(LOG_ERR, "plock(PROCLOCK): %m");
755 # else /* not PROCLOCK */
760 if (plock(TXTLOCK) < 0)
761 msyslog(LOG_ERR, "plock(TXTLOCK) error: %m");
762 # else /* not TXTLOCK */
763 msyslog(LOG_ERR, "plock() - don't know what to lock!");
764 # endif /* not TXTLOCK */
765 # endif /* not PROCLOCK */
766 # endif /* HAVE_PLOCK */
767 #endif /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
770 * Set up signals we pay attention to locally.
773 (void) signal_no_reset(SIGDIE1, finish);
776 (void) signal_no_reset(SIGDIE2, finish);
779 (void) signal_no_reset(SIGDIE3, finish);
782 (void) signal_no_reset(SIGDIE4, finish);
786 (void) signal_no_reset(SIGBUS, finish);
789 #if !defined(SYS_WINNT) && !defined(VMS)
791 (void) signal_no_reset(MOREDEBUGSIG, moredebug);
792 (void) signal_no_reset(LESSDEBUGSIG, lessdebug);
794 (void) signal_no_reset(MOREDEBUGSIG, no_debug);
795 (void) signal_no_reset(LESSDEBUGSIG, no_debug);
797 #endif /* !SYS_WINNT && !VMS */
800 * Set up signals we should never pay attention to.
803 (void) signal_no_reset(SIGPIPE, SIG_IGN);
807 * Call the init_ routines to initialize the data structures.
809 * Exactly what command-line options are we expecting here?
823 set_process_priority();
824 init_proto(); /* Call at high priority */
827 mon_start(MON_ON); /* monitor on by default now */
828 /* turn off in config if unwanted */
831 * Get the configuration. This is done in a separate module
832 * since this will definitely be different for the gizmo board.
835 getconfig(argc, argv);
837 loop_config(LOOP_DRIFTCOMP, old_drift / 1e6);
845 /* Drop super-user privileges and chroot now if the OS supports this */
847 #ifdef HAVE_LINUX_CAPABILITIES
848 /* set flag: keep privileges accross setuid() call (we only really need cap_sys_time): */
849 if( prctl( PR_SET_KEEPCAPS, 1L, 0L, 0L, 0L ) == -1 ) {
850 msyslog( LOG_ERR, "prctl( PR_SET_KEEPCAPS, 1L ) failed: %m" );
854 /* we need a user to switch to */
856 msyslog(LOG_ERR, "Need user name to drop root privileges (see -u flag!)" );
859 #endif /* HAVE_LINUX_CAPABILITIES */
862 if (isdigit((unsigned char)*user)) {
863 sw_uid = (uid_t)strtoul(user, &endp, 0);
868 if ((pw = getpwnam(user)) != NULL) {
872 msyslog(LOG_ERR, "Cannot find user `%s'", user);
878 if (isdigit((unsigned char)*group)) {
879 sw_gid = (gid_t)strtoul(group, &endp, 0);
884 if ((gr = getgrnam(group)) != NULL) {
888 msyslog(LOG_ERR, "Cannot find group `%s'", group);
895 /* make sure cwd is inside the jail: */
896 if( chdir(chrootdir) ) {
897 msyslog(LOG_ERR, "Cannot chdir() to `%s': %m", chrootdir);
900 if( chroot(chrootdir) ) {
901 msyslog(LOG_ERR, "Cannot chroot() to `%s': %m", chrootdir);
905 if (group && setgid(sw_gid)) {
906 msyslog(LOG_ERR, "Cannot setgid() to group `%s': %m", group);
909 if (group && setegid(sw_gid)) {
910 msyslog(LOG_ERR, "Cannot setegid() to group `%s': %m", group);
913 if (user && setuid(sw_uid)) {
914 msyslog(LOG_ERR, "Cannot setuid() to user `%s': %m", user);
917 if (user && seteuid(sw_uid)) {
918 msyslog(LOG_ERR, "Cannot seteuid() to user `%s': %m", user);
922 #ifndef HAVE_LINUX_CAPABILITIES
924 * for now assume that the privilege to bind to privileged ports
925 * is associated with running with uid 0 - should be refined on
926 * ports that allow binding to NTP_PORT with uid != 0
928 disable_dynamic_updates |= (sw_uid != 0); /* also notifies routing message listener */
931 if (disable_dynamic_updates && interface_interval) {
932 interface_interval = 0;
933 msyslog(LOG_INFO, "running in unprivileged mode disables dynamic interface tracking");
936 #ifdef HAVE_LINUX_CAPABILITIES
939 * We may be running under non-root uid now, but we still hold full root privileges!
940 * We drop all of them, except for the crucial one or two: cap_sys_time and
941 * cap_net_bind_service if doing dynamic interface tracking.
944 char *captext = interface_interval ?
945 "cap_sys_time,cap_net_bind_service=ipe" :
947 if( ! ( caps = cap_from_text( captext ) ) ) {
948 msyslog( LOG_ERR, "cap_from_text() failed: %m" );
951 if( cap_set_proc( caps ) == -1 ) {
952 msyslog( LOG_ERR, "cap_set_proc() failed to drop root privileges: %m" );
957 #endif /* HAVE_LINUX_CAPABILITIES */
959 } /* if( droproot ) */
960 #endif /* HAVE_DROPROOT */
963 * Report that we're up to any trappers
965 report_event(EVNT_SYSRESTART, (struct peer *)0);
968 * Use select() on all on all input fd's for unlimited
969 * time. select() will terminate on SIGALARM or on the
970 * reception of input. Using select() means we can't do
971 * robust signal handling and we get a potential race
972 * between checking for alarms and doing the select().
973 * Mostly harmless, I think.
975 /* On VMS, I suspect that select() can't be interrupted
976 * by a "signal" either, so I take the easy way out and
977 * have select() time out after one second.
978 * System clock updates really aren't time-critical,
979 * and - lacking a hardware reference clock - I have
980 * yet to learn about anything else that is.
982 #if defined(HAVE_IO_COMPLETION_PORT)
985 GetReceivedBuffers();
986 #else /* normal I/O */
988 BLOCK_IO_AND_ALARM();
992 # if !defined(HAVE_SIGNALED_IO)
993 extern fd_set activefds;
994 extern int maxactivefd;
1000 if (alarm_flag) /* alarmed? */
1006 if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE)
1009 * Nothing to do. Wait for something.
1011 # ifndef HAVE_SIGNALED_IO
1013 # if defined(VMS) || defined(SYS_VXWORKS)
1014 /* make select() wake up after one second */
1018 t1.tv_sec = 1; t1.tv_usec = 0;
1019 nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
1023 nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
1024 (fd_set *)0, (struct timeval *)0);
1032 (void)input_handler(&ts);
1034 else if (nfound == -1 && errno != EINTR)
1035 netsyslog(LOG_ERR, "select() error: %m");
1038 netsyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
1040 # else /* HAVE_SIGNALED_IO */
1043 # endif /* HAVE_SIGNALED_IO */
1044 if (alarm_flag) /* alarmed? */
1053 UNBLOCK_IO_AND_ALARM();
1055 * Out here, signals are unblocked. Call timer routine
1056 * to process expiry.
1060 BLOCK_IO_AND_ALARM();
1063 #endif /* HAVE_IO_COMPLETION_PORT */
1074 rbuf = get_full_recv_buffer();
1075 while (rbuf != NULL)
1082 UNBLOCK_IO_AND_ALARM();
1085 { /* avoid timer starvation during lengthy I/O handling */
1091 * Call the data procedure to handle each received
1094 if (rbuf->receiver != NULL) /* This should always be true */
1099 L_SUB(&dts, &rbuf->recv_time);
1100 DPRINTF(2, ("processing timestamp delta %s (with prec. fuzz)\n", lfptoa(&dts, 9)));
1101 collect_timing(rbuf, "buffer processing delay", 1, &dts);
1104 (rbuf->receiver)(rbuf);
1106 msyslog(LOG_ERR, "receive buffer corruption - receiver found to be NULL - ABORTING");
1110 BLOCK_IO_AND_ALARM();
1112 rbuf = get_full_recv_buffer();
1118 collect_timing(NULL, "processing", bufcount, &tsb);
1119 DPRINTF(2, ("processing time for %d buffers %s\n", bufcount, lfptoa(&tsb, 9)));
1128 UNBLOCK_IO_AND_ALARM();
1135 * finish - exit gracefully
1143 msyslog(LOG_NOTICE, "ntpd exiting on signal %d", sig);
1145 #ifdef HAVE_DNSREGISTRATION
1147 DNSServiceRefDeallocate(mdns);
1154 printf("\nfinish(SIGBUS)\n");
1157 case 0: /* Should never happen... */
1163 #endif /* SIGDIE2 */
1169 * moredebug - increase debugging verbosity
1176 int saved_errno = errno;
1181 msyslog(LOG_DEBUG, "debug raised to %d", debug);
1183 errno = saved_errno;
1187 * lessdebug - decrease debugging verbosity
1194 int saved_errno = errno;
1199 msyslog(LOG_DEBUG, "debug lowered to %d", debug);
1201 errno = saved_errno;
1204 #else /* not DEBUG */
1207 * no_debug - We don't do the debug here.
1214 int saved_errno = errno;
1216 msyslog(LOG_DEBUG, "ntpd not compiled for debugging (signal %d)", sig);
1217 errno = saved_errno;
1219 #endif /* not SYS_WINNT */
1220 #endif /* not DEBUG */