diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/timed/timed/acksend.c | 11 | ||||
-rw-r--r-- | usr.sbin/timed/timed/byteorder.c | 8 | ||||
-rw-r--r-- | usr.sbin/timed/timed/candidate.c | 15 | ||||
-rw-r--r-- | usr.sbin/timed/timed/cksum.c | 8 | ||||
-rw-r--r-- | usr.sbin/timed/timed/correct.c | 12 | ||||
-rw-r--r-- | usr.sbin/timed/timed/globals.h | 4 | ||||
-rw-r--r-- | usr.sbin/timed/timed/master.c | 51 | ||||
-rw-r--r-- | usr.sbin/timed/timed/measure.c | 11 | ||||
-rw-r--r-- | usr.sbin/timed/timed/networkdelta.c | 8 | ||||
-rw-r--r-- | usr.sbin/timed/timed/readmsg.c | 11 | ||||
-rw-r--r-- | usr.sbin/timed/timed/slave.c | 73 | ||||
-rw-r--r-- | usr.sbin/timed/timed/timed.8 | 31 | ||||
-rw-r--r-- | usr.sbin/timed/timed/timed.c | 167 | ||||
-rw-r--r-- | usr.sbin/timed/timedc/cmds.c | 72 | ||||
-rw-r--r-- | usr.sbin/timed/timedc/cmdtab.c | 4 | ||||
-rw-r--r-- | usr.sbin/timed/timedc/timedc.8 | 12 | ||||
-rw-r--r-- | usr.sbin/timed/timedc/timedc.c | 23 | ||||
-rw-r--r-- | usr.sbin/timed/timedc/timedc.h | 2 |
18 files changed, 287 insertions, 236 deletions
diff --git a/usr.sbin/timed/timed/acksend.c b/usr.sbin/timed/timed/acksend.c index c84f52de46d0..8197bc2713c0 100644 --- a/usr.sbin/timed/timed/acksend.c +++ b/usr.sbin/timed/timed/acksend.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)acksend.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.6 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" @@ -56,7 +56,8 @@ xmit(type, seq, addr) msg.tsp_type = type; msg.tsp_seq = seq; msg.tsp_vers = TSPVERSION; - (void)strcpy(msg.tsp_name, hostname); + (void)strncpy(msg.tsp_name, hostname, sizeof msg.tsp_name-1); + msg.tsp_name[sizeof msg.tsp_name-1] = '\0'; bytenetorder(&msg); if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0, (struct sockaddr*)addr, sizeof(struct sockaddr)) < 0) { diff --git a/usr.sbin/timed/timed/byteorder.c b/usr.sbin/timed/timed/byteorder.c index deb4d0eb035c..3a6ef02d535a 100644 --- a/usr.sbin/timed/timed/byteorder.c +++ b/usr.sbin/timed/timed/byteorder.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)byteorder.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.1.1.1 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" diff --git a/usr.sbin/timed/timed/candidate.c b/usr.sbin/timed/timed/candidate.c index 38700bc45d87..2a4f2a111da2 100644 --- a/usr.sbin/timed/timed/candidate.c +++ b/usr.sbin/timed/timed/candidate.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)candidate.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.1.1.1 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" @@ -80,7 +80,8 @@ again: fprintf(fd, "This machine is a candidate time master\n"); msg.tsp_type = TSP_ELECTION; msg.tsp_vers = TSPVERSION; - (void)strcpy(msg.tsp_name, hostname); + (void)strncpy(msg.tsp_name, hostname, sizeof msg.tsp_name-1); + msg.tsp_name[sizeof msg.tsp_name-1] = '\0'; bytenetorder(&msg); if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0, (struct sockaddr*)&net->dest_addr, @@ -139,7 +140,9 @@ again: /* no master for another round */ htp = addmach(resp->tsp_name,&from,fromnet); msg.tsp_type = TSP_REFUSE; - (void)strcpy(msg.tsp_name, hostname); + (void)strncpy(msg.tsp_name, hostname, + sizeof msg.tsp_name-1); + msg.tsp_name[sizeof msg.tsp_name-1] = '\0'; answer = acksend(&msg, &htp->addr, htp->name, TSP_ACK, 0, htp->noanswer); if (!answer) { diff --git a/usr.sbin/timed/timed/cksum.c b/usr.sbin/timed/timed/cksum.c index 3d15af3cf1a0..14cbf52a6145 100644 --- a/usr.sbin/timed/timed/cksum.c +++ b/usr.sbin/timed/timed/cksum.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)cksum.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.3 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include <sys/types.h> diff --git a/usr.sbin/timed/timed/correct.c b/usr.sbin/timed/timed/correct.c index 569d2e1ddac3..423731188b90 100644 --- a/usr.sbin/timed/timed/correct.c +++ b/usr.sbin/timed/timed/correct.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)correct.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.16 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" #include <math.h> @@ -84,7 +84,9 @@ correct(avdelta) mstotvround(&to.tsp_time, corr); to.tsp_type = TSP_ADJTIME; } - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; answer = acksend(&to, &htp->addr, htp->name, TSP_ACK, 0, 0); if (!answer) { diff --git a/usr.sbin/timed/timed/globals.h b/usr.sbin/timed/timed/globals.h index 92aed3ee7c78..f91f91f973c5 100644 --- a/usr.sbin/timed/timed/globals.h +++ b/usr.sbin/timed/timed/globals.h @@ -34,7 +34,7 @@ */ #ifdef sgi -#ident "$Revision: 1.15 $" +#ident "$Revision: 1.1.1.1 $" #endif #include <sys/param.h> @@ -44,6 +44,7 @@ #include <netinet/in.h> #include <arpa/inet.h> +#include <err.h> #include <errno.h> #include <limits.h> #include <netdb.h> @@ -66,7 +67,6 @@ #define SECDAY (24*SECHR) #endif /* sgi */ -extern int errno; extern int sock; /* Best expected round trip for a measurement. diff --git a/usr.sbin/timed/timed/master.c b/usr.sbin/timed/timed/master.c index 1de737da8d3b..97fb4899000f 100644 --- a/usr.sbin/timed/timed/master.c +++ b/usr.sbin/timed/timed/master.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)master.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.1.1.1 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" #include <sys/file.h> @@ -150,7 +150,9 @@ loop: to.tsp_vers = TSPVERSION; to.tsp_seq = sequence++; to.tsp_hopcnt = MAX_HOPCNT; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; bytenetorder(&to); if (sendto(sock, (char *)&to, sizeof(struct tsp), 0, @@ -179,7 +181,9 @@ loop: #ifdef sgi (void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec); #else - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + (void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec), + sizeof newdate-1); + newdate[sizeof newdate-1] = '\0'; #endif /* sgi */ if (!good_host_name(msg->tsp_name)) { syslog(LOG_NOTICE, @@ -200,7 +204,9 @@ loop: #ifdef sgi (void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec); #else - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + (void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec), + sizeof newdate-1); + newdate[sizeof newdate-1] = '\0'; #endif /* sgi */ htp = findhost(msg->tsp_name); if (htp == 0) { @@ -248,9 +254,12 @@ loop: (void)addmach(msg->tsp_name, &from,fromnet); } taddr = from; - (void)strcpy(tname, msg->tsp_name); + (void)strncpy(tname, msg->tsp_name, sizeof tname-1); + tname[sizeof tname-1] = '\0'; to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; answer = acksend(&to, &taddr, tname, TSP_ACK, 0, 1); if (answer == NULL) { @@ -267,7 +276,9 @@ loop: */ if (!fromnet || fromnet->status != MASTER) break; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; /* The other master often gets into the same state, * with boring results if we stay at it forever. @@ -275,7 +286,9 @@ loop: ntp = fromnet; /* (acksend() can leave fromnet=0 */ for (i = 0; i < 3; i++) { to.tsp_type = TSP_RESOLVE; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; answer = acksend(&to, &ntp->dest_addr, ANYADDR, TSP_MASTERACK, ntp, 0); @@ -320,7 +333,9 @@ loop: */ htp = addmach(msg->tsp_name, &from,fromnet); to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; answer = acksend(&to, &htp->addr, htp->name, TSP_ACK, 0, 1); if (!answer) { @@ -364,11 +379,13 @@ mchgdate(msg) char olddate[32]; struct timeval otime, ntime; - (void)strcpy(tname, msg->tsp_name); + (void)strncpy(tname, msg->tsp_name, sizeof tname-1); + tname[sizeof tname-1] = '\0'; xmit(TSP_DATEACK, msg->tsp_seq, &from); - (void)strcpy(olddate, date()); + (void)strncpy(olddate, date(), sizeof olddate-1); + olddate[sizeof olddate-1] = '\0'; /* adjust time for residence on the queue */ (void)gettimeofday(&otime, 0); @@ -503,7 +520,8 @@ spreadtime() dictate = 2; for (htp = self.l_fwd; htp != &self; htp = htp->l_fwd) { to.tsp_type = TSP_SETTIME; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; (void)gettimeofday(&to.tsp_time, 0); answer = acksend(&to, &htp->addr, htp->name, TSP_ACK, 0, htp->noanswer); @@ -787,7 +805,8 @@ newslave(msg) if (now.tv_sec >= fromnet->slvwait.tv_sec+3 || now.tv_sec < fromnet->slvwait.tv_sec) { to.tsp_type = TSP_SETTIME; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; (void)gettimeofday(&to.tsp_time, 0); answer = acksend(&to, &htp->addr, htp->name, TSP_ACK, diff --git a/usr.sbin/timed/timed/measure.c b/usr.sbin/timed/timed/measure.c index 2b49eaa4ed8d..6cdb527cb98e 100644 --- a/usr.sbin/timed/timed/measure.c +++ b/usr.sbin/timed/timed/measure.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)measure.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.2 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" #include <netinet/in_systm.h> @@ -274,8 +274,7 @@ quit: } } else if (print) { if (errno != 0) - fprintf(stderr, "measure %s: %s\n", hname, - strerror(errno)); + warn("measure %s", hname); } else { if (errno != 0) { syslog(LOG_ERR, "measure %s: %m", hname); diff --git a/usr.sbin/timed/timed/networkdelta.c b/usr.sbin/timed/timed/networkdelta.c index d64640ae02e2..aeb4a5154e7e 100644 --- a/usr.sbin/timed/timed/networkdelta.c +++ b/usr.sbin/timed/timed/networkdelta.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)networkdelta.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.4 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" diff --git a/usr.sbin/timed/timed/readmsg.c b/usr.sbin/timed/timed/readmsg.c index 3e8f4d255a61..13e390bfd688 100644 --- a/usr.sbin/timed/timed/readmsg.c +++ b/usr.sbin/timed/timed/readmsg.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)readmsg.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.17 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" @@ -393,7 +393,8 @@ masterack() resp = msgin; resp.tsp_vers = TSPVERSION; - (void)strcpy(resp.tsp_name, hostname); + (void)strncpy(resp.tsp_name, hostname, sizeof resp.tsp_name-1); + resp.tsp_name[sizeof resp.tsp_name-1] = '\0'; switch(msgin.tsp_type) { diff --git a/usr.sbin/timed/timed/slave.c b/usr.sbin/timed/timed/slave.c index 7c71d7ab4985..d0e2dc0708e0 100644 --- a/usr.sbin/timed/timed/slave.c +++ b/usr.sbin/timed/timed/slave.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.1.1.1 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "globals.h" #include <setjmp.h> @@ -151,7 +151,9 @@ loop: to.tsp_vers = TSPVERSION; to.tsp_seq = sequence++; to.tsp_hopcnt = MAX_HOPCNT; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; bytenetorder(&to); if (sendto(sock, (char *)&to, sizeof(struct tsp), 0, (struct sockaddr*)&ntp->dest_addr, @@ -265,8 +267,11 @@ loop: * the following line is necessary due to syslog * calling ctime() which clobbers the static buffer */ - (void)strcpy(olddate, date()); - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + (void)strncpy(olddate, date(), sizeof olddate-1); + olddate[sizeof olddate-1] = '\0'; + (void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec), + sizeof newdate-1); + newdate[sizeof newdate-1] = '\0'; #endif /* sgi */ if (!good_host_name(msg->tsp_name)) { @@ -357,7 +362,9 @@ loop: #ifdef sgi (void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec); #else - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + (void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec), + sizeof newdate-1); + newdate[sizeof newdate-1] = '\0'; #endif /* sgi */ schgdate(msg, newdate); break; @@ -368,7 +375,9 @@ loop: #ifdef sgi (void)cftime(newdate, "%D %T", &msg->tsp_time.tv_sec); #else - (void)strcpy(newdate, ctime(&msg->tsp_time.tv_sec)); + (void)strncpy(newdate, ctime(&msg->tsp_time.tv_sec), + sizeof newdate-1); + newdate[sizeof newdate-1] = '\0'; #endif /* sgi */ htp = findhost(msg->tsp_name); if (0 == htp) { @@ -422,8 +431,12 @@ loop: refusetime = ntime.tv_sec + 30; } taddr = from; - (void)strcpy(tname, msg->tsp_name); - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(tname, msg->tsp_name, + sizeof tname-1); + tname[sizeof tname-1] = '\0'; + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; answerdelay(); if (!acksend(&to, &taddr, tname, TSP_ACK, 0, 0)) @@ -434,7 +447,9 @@ loop: } else { /* fromnet->status == MASTER */ htp = addmach(msg->tsp_name, &from,fromnet); to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; if (!acksend(&to, &htp->addr, htp->name, TSP_ACK, 0, htp->noanswer)) { syslog(LOG_ERR, @@ -453,7 +468,9 @@ loop: * more than one master: the first slave to * come up will notify here the situation. */ - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; /* The other master often gets into the same state, * with boring results. @@ -487,7 +504,9 @@ loop: to.tsp_type = TSP_MSITEREQ; to.tsp_vers = TSPVERSION; to.tsp_seq = 0; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; answer = acksend(&to, &slavenet->dest_addr, ANYADDR, TSP_ACK, slavenet, 0); @@ -495,11 +514,14 @@ loop: && good_host_name(answer->tsp_name)) { setmaster(answer); to.tsp_type = TSP_ACK; - (void)strcpy(to.tsp_name, answer->tsp_name); + (void)strncpy(to.tsp_name, answer->tsp_name, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; bytenetorder(&to); if (sendto(sock, (char *)&to, sizeof(struct tsp), 0, - (struct sockaddr*)&taddr, sizeof(taddr)) < 0) { + (struct sockaddr*)&taddr, + sizeof(taddr)) < 0) { trace_sendto_err(taddr.sin_addr); } } @@ -544,9 +566,13 @@ loop: if (answer == NULL) break; taddr = from; - (void)strcpy(tname, answer->tsp_name); + (void)strncpy(tname, answer->tsp_name, + sizeof tname-1); + tname[sizeof tname-1] = '\0'; to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; if (!acksend(&to, &taddr, tname, TSP_ACK, 0, 1)) { syslog(LOG_ERR, @@ -599,7 +625,9 @@ loop: htp = addmach(answer->tsp_name, &from,ntp); to.tsp_type = TSP_QUIT; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, + sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; if (!acksend(&to,&htp->addr,htp->name, TSP_ACK, 0, htp->noanswer)) { syslog(LOG_ERR, @@ -635,7 +663,9 @@ setmaster(msg) && (slavenet != old_slavenet || strcmp(msg->tsp_name, master_name) || old_status != status)) { - (void)strcpy(master_name, msg->tsp_name); + (void)strncpy(master_name, msg->tsp_name, + sizeof master_name-1); + master_name[sizeof master_name-1] = '\0'; old_slavenet = slavenet; old_status = status; @@ -683,7 +713,8 @@ schgdate(msg, newdate) to.tsp_type = TSP_SETDATEREQ; to.tsp_time = msg->tsp_time; - (void)strcpy(to.tsp_name, hostname); + (void)strncpy(to.tsp_name, hostname, sizeof to.tsp_name-1); + to.tsp_name[sizeof to.tsp_name-1] = '\0'; if (!acksend(&to, &slavenet->dest_addr, ANYADDR, TSP_DATEACK, slavenet, 0)) diff --git a/usr.sbin/timed/timed/timed.8 b/usr.sbin/timed/timed/timed.8 index 101592d84e75..a8eb74ec0124 100644 --- a/usr.sbin/timed/timed/timed.8 +++ b/usr.sbin/timed/timed/timed.8 @@ -53,7 +53,7 @@ at boot time from the file. It synchronizes the host's time with the time of other machines in a local area network running -.Nm timed . +.Nm Ns . These time servers will slow down the clocks of some machines and speed up the clocks of others to bring them to the average network time. The average network time is computed from measurements of clock differences @@ -62,11 +62,11 @@ using the timestamp request message. .Pp The service provided by -.Nm timed +.Nm is based on a master-slave scheme. When -.Nm timed +.Nm is started on a machine, it asks the master for the network time and sets the host's clock to that time. After that, it accepts synchronization messages periodically sent by @@ -85,7 +85,7 @@ a new master from among slaves running with the .Fl M flag. A -.Nm timed +.Nm running without the .Fl M or @@ -104,8 +104,9 @@ The .Fl d flag is for debugging the daemon. It causes the program to not put itself into the background. +.Pp Normally -.Nm timed +.Nm checks for a master time server on each network to which it is connected, except as modified by the options described below. It will request synchronization service from the first master server @@ -153,7 +154,9 @@ If it finds masters on more than one network, it chooses one network on which to be a "slave," and then periodically checks the other networks to see if the masters there have disappeared. .Pp -One way to synchronize a group of machines is to use an NTP daemon to +One way to synchronize a group of machines is to use an +.Tn NTP +daemon to synchronize the clock of one machine to a distant standard or a radio receiver and .Fl F Ar hostname @@ -173,10 +176,10 @@ Complaints about machines that failed to respond to initial time settings are often associated with "multi-homed" machines that looked for time masters on more than one network and eventually chose to become a slave on the other network. -.Sh WARNING +.Sh WARNINGS If two or more time daemons, whether -.Nm timed , -.Xr NTP , +.Nm Ns , +.Tn NTP , try to adjust the same clock, temporal chaos will result. If both .Nm @@ -184,11 +187,15 @@ and another time daemon are run on the same machine, ensure that the .Fl F flag is used, so that -.Nm timed +.Nm never attempts to adjust the local clock. .Pp -The protocol is based on UDP/IP broadcasts. All machines within -the range of a broadcast that are using the TSP protocol must cooperate. +The protocol is based on +.Tn UDP/IP +broadcasts. All machines within +the range of a broadcast that are using the +.Tn TSP +protocol must cooperate. There cannot be more than a single administrative domain using the .Fl F flag among all machines reached by a broadcast packet. diff --git a/usr.sbin/timed/timed/timed.c b/usr.sbin/timed/timed/timed.c index 2c129de4f277..c5e0f2222b05 100644 --- a/usr.sbin/timed/timed/timed.c +++ b/usr.sbin/timed/timed/timed.c @@ -32,19 +32,19 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1985, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)timed.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ -#ifdef sgi -#ident "$Revision: 1.3 $" -#endif /* sgi */ - #define TSPTYPES #include "globals.h" #include <net/if.h> @@ -113,6 +113,7 @@ double tot_ticks, hr_ticks; int bufspace = 60*1024; #endif +static void usage __P((void)); /* * The timedaemons synchronize the clocks of hosts in a local area network. @@ -150,22 +151,12 @@ main(argc, argv) struct sockaddr_in server; u_short port; char c; - extern char *optarg; - extern int optind, opterr; #ifdef sgi FILE *timetrim_st; #endif -#define IN_MSG "timed: -i and -n make no sense together\n" #ifdef sgi struct tms tms; -#define USAGE "timed: [-dtM] [-i net|-n net] [-F host1 host2 ...] [-G netgp] [-P trimfile]\n" -#else -#ifdef HAVENIS -#define USAGE "timed: [-dtM] [-i net|-n net] [-F host1 host2 ...] [-G netgp]\n" -#else -#define USAGE "timed: [-dtM] [-i net|-n net] [-F host1 host2 ...]\n" -#endif /* HAVENIS */ #endif /* sgi */ #ifdef lint @@ -178,7 +169,7 @@ main(argc, argv) #ifdef sgi if (0 > syssgi(SGI_GETTIMETRIM, &timetrim)) { - perror("timed: syssgi(GETTIMETRIM)"); + warn("syssgi(GETTIMETRIM)"); timetrim = 0; } tot_ticks = hr_ticks = times(&tms); @@ -197,8 +188,7 @@ main(argc, argv) case 'n': if (iflag) { - fprintf(stderr, IN_MSG); - exit(1); + errx(1, "-i and -n make no sense together"); } else { nflag = ON; addnetname(optarg); @@ -207,8 +197,7 @@ main(argc, argv) case 'i': if (nflag) { - fprintf(stderr, IN_MSG); - exit(1); + errx(1, "-i and -n make no sense together"); } else { iflag = ON; addnetname(optarg); @@ -225,10 +214,8 @@ main(argc, argv) debug = 1; break; case 'G': - if (goodgroup != 0) { - fprintf(stderr,"timed: only one net group\n"); - exit(1); - } + if (goodgroup != 0) + errx(1, "only one net group"); goodgroup = optarg; break; #ifdef sgi @@ -237,8 +224,7 @@ main(argc, argv) timetrim_st = fopen(timetrim_fn, "r+"); if (0 == timetrim_st) { if (errno != ENOENT) { - (void)fprintf(stderr,"timed: "); - perror(timetrim_fn); + warn("%s", timetrim_fn); timetrim_fn = 0; } } else { @@ -255,13 +241,13 @@ main(argc, argv) || (i == 3 && trim != rint(adj*CLK_TCK/ticks))) { if (trace && i != EOF) - (void)fprintf(stderr, - "timed: unrecognized contents in %s\n", + warn( + "unrecognized contents in %s", timetrim_fn); } else { if (0 > syssgi(SGI_SETTIMETRIM, trim)) { - perror("timed: syssgi(SETTIMETRIM)"); + warn("syssgi(SETTIMETRIM)"); } else { timetrim = trim; } @@ -276,15 +262,12 @@ main(argc, argv) #endif /* sgi */ default: - fprintf(stderr, USAGE); - exit(1); + usage(); break; } } - if (optind < argc) { - fprintf(stderr, USAGE); - exit(1); - } + if (optind < argc) + usage(); /* If we care about which machine is the master, then we must * be willing to be a master @@ -292,10 +275,8 @@ main(argc, argv) if (0 != goodgroup || 0 != goodhosts) Mflag = 1; - if (gethostname(hostname, sizeof(hostname) - 1) < 0) { - perror("gethostname"); - exit(1); - } + if (gethostname(hostname, sizeof(hostname) - 1) < 0) + err(1, "gethostname"); self.l_bak = &self; self.l_fwd = &self; self.h_bak = &self; @@ -307,29 +288,23 @@ main(argc, argv) add_good_host(hostname,1); srvp = getservbyname("timed", "udp"); - if (srvp == 0) { - fprintf(stderr, "unknown service 'timed/udp'\n"); - exit(1); - } + if (srvp == 0) + errx(1, "unknown service 'timed/udp'"); port = srvp->s_port; bzero(&server, sizeof(struct sockaddr_in)); server.sin_port = srvp->s_port; server.sin_family = AF_INET; sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock < 0) { - perror("socket"); - exit(1); - } + if (sock < 0) + err(1, "socket"); if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (char *)&on, - sizeof(on)) < 0) { - perror("setsockopt"); - exit(1); - } + sizeof(on)) < 0) + err(1, "setsockopt"); if (bind(sock, (struct sockaddr*)&server, sizeof(server))) { if (errno == EADDRINUSE) - fprintf(stderr,"timed: time daemon already running\n"); + warnx("time daemon already running"); else - perror("bind"); + warn("bind"); exit(1); } #ifdef sgi @@ -337,10 +312,8 @@ main(argc, argv) * handle many slaves with our buffer */ if (0 > setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (char*)&bufspace, - sizeof(bufspace))) { - perror("setsockopt"); - exit(1); - } + sizeof(bufspace))) + err(1, "setsockopt"); #endif /* sgi */ /* choose a unique seed for random number generation */ @@ -366,14 +339,11 @@ main(argc, argv) if (nentp != 0) { nt->net = nentp->n_net; } else if (nt->net == INADDR_NONE) { - fprintf(stderr, "timed: unknown net %s\n", nt->name); - exit(1); + errx(1, "unknown net %s", nt->name); } else if (nt->net == INADDR_ANY) { - fprintf(stderr, "timed: bad net %s\n", nt->name); - exit(1); + errx(1, "bad net %s", nt->name); } else { - fprintf(stderr, - "timed: warning: %s unknown in /etc/networks\n", + warnx("warning: %s unknown in /etc/networks", nt->name); } @@ -386,10 +356,8 @@ main(argc, argv) } ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; - if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) { - perror("timed: get interface configuration"); - exit(1); - } + if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) + err(1, "get interface configuration"); ntp = NULL; #ifdef sgi #define size(p) (sizeof(*ifr) - sizeof(ifr->ifr_name)) /* XXX hack. kludge */ @@ -411,7 +379,7 @@ main(argc, argv) ifreqf = *ifr; if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreqf) < 0) { - perror("get interface flags"); + warn("get interface flags"); continue; } if ((ifreqf.ifr_flags & IFF_UP) == 0) @@ -423,7 +391,7 @@ main(argc, argv) if (ioctl(sock, SIOCGIFNETMASK, (char *)&ifreq) < 0) { - perror("get netmask"); + warn("get netmask"); continue; } ntp->mask = ((struct sockaddr_in *) @@ -431,7 +399,7 @@ main(argc, argv) if (ifreqf.ifr_flags & IFF_BROADCAST) { if (ioctl(sock, SIOCGIFBRDADDR, (char *)&ifreq) < 0) { - perror("get broadaddr"); + warn("get broadaddr"); continue; } ntp->dest_addr = *(struct sockaddr_in *)&ifreq.ifr_broadaddr; @@ -442,7 +410,7 @@ main(argc, argv) } else { if (ioctl(sock, SIOCGIFDSTADDR, (char *)&ifreq) < 0) { - perror("get destaddr"); + warn("get destaddr"); continue; } ntp->dest_addr = *(struct sockaddr_in *)&ifreq.ifr_dstaddr; @@ -455,7 +423,7 @@ main(argc, argv) if (ntp->net.s_addr == htonl(nt->net)) break; } - if (nflag && !nt || iflag && nt) + if ((nflag && !nt) || (iflag && nt)) continue; ntp->next = NULL; @@ -469,10 +437,8 @@ main(argc, argv) } if (ntp) (void) free((char *)ntp); - if (nettab == NULL) { - fprintf(stderr, "timed: no network usable\n"); - exit(1); - } + if (nettab == NULL) + errx(1, "no network usable"); #ifdef sgi @@ -568,9 +534,26 @@ main(argc, argv) slave(); } /* NOTREACHED */ -#ifdef lint return(0); -#endif +} + +static void +usage() +{ +#ifdef sgi + fprintf(stderr, "%s\n%s\n", +"usage: timed [-dtM] [-i net|-n net] [-F host1 host2 ...]", +" [-G netgp] [-P trimfile]"); +#else +#ifdef HAVENIS + fprintf(stderr, +"usage: timed [-dtM] [-i net|-n net] [-F host1 host2 ...] [-G netgp]\n"); +#else + fprintf(stderr, +"usage: timed [-dtM] [-i net|-n net] [-F host1 host2 ...]\n"); +#endif /* HAVENIS */ +#endif /* sgi */ + exit(1); } /* @@ -590,7 +573,8 @@ suppress(addr, name,net) if (trace) fprintf(fd, "suppress: %s\n", name); tgt = *addr; - (void)strcpy(tname, name); + (void)strncpy(tname, name, sizeof tname-1); + tname[sizeof tname-1] = '\0'; while (0 != readmsg(TSP_ANY, ANYADDR, &wait, net)) { if (trace) @@ -600,7 +584,8 @@ suppress(addr, name,net) syslog(LOG_NOTICE, "suppressing false master %s", tname); msg.tsp_type = TSP_QUIT; - (void)strcpy(msg.tsp_name, hostname); + (void)strncpy(msg.tsp_name, hostname, sizeof msg.tsp_name-1); + msg.tsp_name[sizeof msg.tsp_name-1] = '\0'; (void)acksend(&msg, &tgt, tname, TSP_ACK, 0, 1); } @@ -618,7 +603,8 @@ lookformaster(ntp) /* look for master */ resp.tsp_type = TSP_MASTERREQ; - (void)strcpy(resp.tsp_name, hostname); + (void)strncpy(resp.tsp_name, hostname, sizeof resp.tsp_name-1); + resp.tsp_name[sizeof resp.tsp_name-1] = '\0'; answer = acksend(&resp, &ntp->dest_addr, ANYADDR, TSP_MASTERACK, ntp, 0); if (answer != 0 && !good_host_name(answer->tsp_name)) { @@ -673,7 +659,8 @@ lookformaster(ntp) } ntp->status = SLAVE; - (void)strcpy(mastername, answer->tsp_name); + (void)strncpy(mastername, answer->tsp_name, sizeof mastername-1); + mastername[sizeof mastername-1] = '\0'; masteraddr = from; /* @@ -691,7 +678,9 @@ lookformaster(ntp) if (answer != NULL && strcmp(answer->tsp_name, mastername) != 0) { conflict.tsp_type = TSP_CONFLICT; - (void)strcpy(conflict.tsp_name, hostname); + (void)strncpy(conflict.tsp_name, hostname, + sizeof conflict.tsp_name-1); + conflict.tsp_name[sizeof conflict.tsp_name-1] = '\0'; if (!acksend(&conflict, &masteraddr, mastername, TSP_ACK, 0, 0)) { syslog(LOG_ERR, @@ -853,10 +842,8 @@ addnetname(name) while (*netlist) netlist = &((*netlist)->next); *netlist = (struct nets *)malloc(sizeof **netlist); - if (*netlist == 0) { - fprintf(stderr,"malloc failed\n"); - exit(1); - } + if (*netlist == 0) + errx(1, "malloc failed"); bzero((char *)*netlist, sizeof(**netlist)); (*netlist)->name = name; } @@ -884,7 +871,7 @@ add_good_host(name, perm) hentp = gethostbyname(name); if (0 == hentp && perm) - (void)fprintf(stderr, "unknown host %s\n", name); + warnx("unknown host %s", name); } @@ -897,9 +884,11 @@ get_goodgroup(force) # define NG_DELAY (30*60*CLK_TCK) /* 30 minutes */ static unsigned long last_update = -NG_DELAY; unsigned long new_update; - struct hosttbl *htp; struct goodhost *ghp, **ghpp; +#ifdef HAVENIS + struct hosttbl *htp; char *mach, *usr, *dom; +#endif /* HAVENIS */ struct tms tm; diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c index 9e0aa21288e1..750543803ce3 100644 --- a/usr.sbin/timed/timedc/cmds.c +++ b/usr.sbin/timed/timedc/cmds.c @@ -32,12 +32,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.10 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "timedc.h" #include <sys/file.h> @@ -46,6 +46,7 @@ static char sccsid[] = "@(#)cmds.c 8.1 (Berkeley) 6/6/93"; #include <netinet/ip.h> #include <netinet/ip_icmp.h> +#include <err.h> #include <stdlib.h> #include <strings.h> #include <unistd.h> @@ -103,7 +104,7 @@ daydiff(hostname) sec = 0; if (sendto(sock, &sec, sizeof(sec), 0, (struct sockaddr*)&dayaddr, sizeof(dayaddr)) < 0) { - perror("sendto(sock)"); + warn("sendto(sock)"); return 0; } @@ -113,9 +114,9 @@ daydiff(hostname) i = select(sock+1, &ready, (fd_set *)0, (fd_set *)0, &tout); if (i < 0) { - if (errno = EINTR) + if (errno == EINTR) continue; - perror("select(date read)"); + warn("select(date read)"); return 0; } if (0 == i) @@ -124,14 +125,13 @@ daydiff(hostname) fromlen = sizeof(from); if (recvfrom(sock,&sec,sizeof(sec),0, &from,&fromlen) < 0) { - perror("recvfrom(date read)"); + warn("recvfrom(date read)"); return 0; } sec = ntohl(sec); if (sec < BU) { - fprintf(stderr, - "%s says it is before 1970: %lu", + warnx("%s says it is before 1970: %lu", hostname, sec); return 0; } @@ -143,7 +143,7 @@ daydiff(hostname) } /* if we get here, we tried too many times */ - fprintf(stderr,"%s will not tell us the date\n", hostname); + warnx("%s will not tell us the date", hostname); return 0; } @@ -181,7 +181,7 @@ clockdiff(argc, argv) struct servent *sp; if (argc < 2) { - printf("Usage: clockdiff host ... \n"); + printf("usage: timedc clockdiff host ...\n"); return; } @@ -190,8 +190,7 @@ clockdiff(argc, argv) /* get the address for the date ready */ sp = getservbyname(DATE_PORT, DATE_PROTO); if (!sp) { - (void)fprintf(stderr, "%s/%s is an unknown service\n", - DATE_PORT, DATE_PROTO); + warnx("%s/%s is an unknown service", DATE_PORT, DATE_PROTO); dayaddr.sin_port = 0; } else { dayaddr.sin_port = sp->s_port; @@ -201,8 +200,7 @@ clockdiff(argc, argv) argc--; argv++; hp = gethostbyname(*argv); if (hp == NULL) { - fprintf(stderr, "timedc: %s: ", *argv); - herror(0); + warnx("%s: %s", *argv, hstrerror(h_errno)); continue; } @@ -285,13 +283,13 @@ msite(argc, argv) char *tgtname; if (argc < 1) { - printf("Usage: msite [hostname]\n"); + printf("usage: timedc msite [host ...]\n"); return; } srvp = getservbyname("timed", "udp"); if (srvp == 0) { - fprintf(stderr, "udp/timed: unknown service\n"); + warnx("udp/timed: unknown service"); return; } dest.sin_port = srvp->s_port; @@ -303,20 +301,20 @@ msite(argc, argv) tgtname = (i >= argc) ? myname : argv[i]; hp = gethostbyname(tgtname); if (hp == 0) { - fprintf(stderr, "timedc: %s: ", tgtname); - herror(0); + warnx("%s: %s", tgtname, hstrerror(h_errno)); continue; } bcopy(hp->h_addr, &dest.sin_addr.s_addr, hp->h_length); - (void)strcpy(msg.tsp_name, myname); + (void)strncpy(msg.tsp_name, myname, sizeof msg.tsp_name-1); + msg.tsp_name[sizeof msg.tsp_name-1] = '\0'; msg.tsp_type = TSP_MSITE; msg.tsp_vers = TSPVERSION; bytenetorder(&msg); if (sendto(sock, &msg, sizeof(struct tsp), 0, (struct sockaddr*)&dest, sizeof(struct sockaddr)) < 0) { - perror("sendto"); + warn("sendto"); continue; } @@ -330,7 +328,7 @@ msite(argc, argv) cc = recvfrom(sock, &msg, sizeof(struct tsp), 0, &from, &length); if (cc < 0) { - perror("recvfrom"); + warn("recvfrom"); continue; } bytehostorder(&msg); @@ -372,13 +370,13 @@ testing(argc, argv) struct tsp msg; if (argc < 2) { - printf("Usage: election host1 [host2 ...]\n"); + printf("usage: timedc election host1 [host2 ...]\n"); return; } srvp = getservbyname("timed", "udp"); if (srvp == 0) { - fprintf(stderr, "udp/timed: unknown service\n"); + warnx("udp/timed: unknown service"); return; } @@ -386,8 +384,7 @@ testing(argc, argv) argc--; argv++; hp = gethostbyname(*argv); if (hp == NULL) { - fprintf(stderr, "timedc: %s: ", *argv); - herror(0); + warnx("%s: %s", *argv, hstrerror(h_errno)); argc--; argv++; continue; } @@ -403,7 +400,7 @@ testing(argc, argv) if (sendto(sock, &msg, sizeof(struct tsp), 0, (struct sockaddr*)&sin, sizeof(struct sockaddr)) < 0) { - perror("sendto"); + warn("sendto"); } } } @@ -428,13 +425,13 @@ tracing(argc, argv) struct servent *srvp; if (argc != 2) { - printf("Usage: tracing { on | off }\n"); + printf("usage: timedc trace { on | off }\n"); return; } srvp = getservbyname("timed", "udp"); if (srvp == 0) { - fprintf(stderr, "udp/timed: unknown service\n"); + warnx("udp/timed: unknown service"); return; } dest.sin_port = srvp->s_port; @@ -452,12 +449,13 @@ tracing(argc, argv) onflag = OFF; } - (void)strcpy(msg.tsp_name, myname); + (void)strncpy(msg.tsp_name, myname, sizeof msg.tsp_name-1); + msg.tsp_name[sizeof msg.tsp_name-1] = '\0'; msg.tsp_vers = TSPVERSION; bytenetorder(&msg); if (sendto(sock, &msg, sizeof(struct tsp), 0, (struct sockaddr*)&dest, sizeof(struct sockaddr)) < 0) { - perror("sendto"); + warn("sendto"); return; } @@ -470,7 +468,7 @@ tracing(argc, argv) cc = recvfrom(sock, &msg, sizeof(struct tsp), 0, &from, &length); if (cc < 0) { - perror("recvfrom"); + warn("recvfrom"); return; } bytehostorder(&msg); @@ -494,7 +492,7 @@ priv_resources() sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) { - perror("opening socket"); + warn("opening socket"); return(-1); } @@ -505,20 +503,20 @@ priv_resources() if (bind(sock, (struct sockaddr*)&sin, sizeof (sin)) >= 0) break; if (errno != EADDRINUSE && errno != EADDRNOTAVAIL) { - perror("bind"); + warn("bind"); (void) close(sock); return(-1); } } if (port == IPPORT_RESERVED / 2) { - fprintf(stderr, "all reserved ports in use\n"); + warnx("all reserved ports in use"); (void) close(sock); return(-1); } sock_raw = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); if (sock_raw < 0) { - perror("opening raw socket"); + warn("opening raw socket"); (void) close(sock); return(-1); } diff --git a/usr.sbin/timed/timedc/cmdtab.c b/usr.sbin/timed/timedc/cmdtab.c index ad5bbb66a988..85b4bee2ae4e 100644 --- a/usr.sbin/timed/timedc/cmdtab.c +++ b/usr.sbin/timed/timedc/cmdtab.c @@ -32,7 +32,11 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#)cmdtab.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include "timedc.h" diff --git a/usr.sbin/timed/timedc/timedc.8 b/usr.sbin/timed/timedc/timedc.8 index bb302e015662..7647e08613e9 100644 --- a/usr.sbin/timed/timedc/timedc.8 +++ b/usr.sbin/timed/timedc/timedc.8 @@ -56,21 +56,21 @@ Measure the differences between machines' clocks, Find the location where the master time server is running, .It Enable or disable tracing of messages received by -.Xr timed , +.Xr timed 8 , and .It Perform various debugging actions. .El .Pp Without any arguments, -.Nm timedc +.Nm will prompt for commands from the standard input. If arguments are supplied, -.Nm timedc +.Nm interprets the first argument as a command and the remaining arguments as parameters to the command. The standard input may be redirected causing -.Nm timedc +.Nm to read commands from a file. Commands may be abbreviated; recognized commands are: @@ -97,9 +97,9 @@ Show the master time server for specified host(s). Enable or disable the tracing of incoming messages to .Xr timed in the file -.Pa /var/log/timed.log. +.Pa /var/log/timed.log . .Pp -.It Ic election Ar host +.It Ic election Ar host1 Op Ar host2 ... Asks the daemon on the target host to reset its "election" timers and to ensure that a time master has been elected. diff --git a/usr.sbin/timed/timedc/timedc.c b/usr.sbin/timed/timedc/timedc.c index 02d086a8ad8b..4187f618cad8 100644 --- a/usr.sbin/timed/timedc/timedc.c +++ b/usr.sbin/timed/timedc/timedc.c @@ -32,27 +32,28 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1985, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)timedc.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ - -#ifdef sgi -#ident "$Revision: 1.6 $" #endif +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "timedc.h" -#include <strings.h> -#include <signal.h> #include <ctype.h> +#include <err.h> #include <setjmp.h> -#include <unistd.h> +#include <signal.h> #include <stdlib.h> +#include <strings.h> #include <syslog.h> +#include <unistd.h> int trace = 0; FILE *fd = 0; @@ -75,10 +76,8 @@ main(argc, argv) /* * security dictates! */ - if (priv_resources() < 0) { - fprintf(stderr, "Could not get privileged resources\n"); - exit(1); - } + if (priv_resources() < 0) + errx(1, "could not get privileged resources"); (void) setuid(getuid()); if (--argc > 0) { diff --git a/usr.sbin/timed/timedc/timedc.h b/usr.sbin/timed/timedc/timedc.h index 67716809bdbb..dfdc2f56e1f1 100644 --- a/usr.sbin/timed/timedc/timedc.h +++ b/usr.sbin/timed/timedc/timedc.h @@ -46,8 +46,6 @@ #include <netdb.h> #include <stdio.h> -extern int errno; - #define ON 1 #define OFF 0 |