diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/buffer.c ./buffer.c --- /usr/src/usr.sbin/ntpd/buffer.c Fri Aug 12 07:48:05 2005 +++ ./buffer.c Tue Apr 4 09:14:34 2006 @@ -16,6 +16,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "includes.h" + #include #include diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/config.c ./config.c --- /usr/src/usr.sbin/ntpd/config.c Wed Aug 10 22:33:40 2005 +++ ./config.c Tue Apr 4 09:14:34 2006 @@ -16,6 +16,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "includes.h" + #include #include #include @@ -75,7 +77,9 @@ if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL) fatal(NULL); sa_in = (struct sockaddr_in *)&h->ss; +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sa_in->sin_len = sizeof(struct sockaddr_in); +#endif sa_in->sin_family = AF_INET; sa_in->sin_addr.s_addr = ina.s_addr; @@ -97,13 +101,17 @@ if ((h = calloc(1, sizeof(struct ntp_addr))) == NULL) fatal(NULL); sa_in6 = (struct sockaddr_in6 *)&h->ss; +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN sa_in6->sin6_len = sizeof(struct sockaddr_in6); +#endif sa_in6->sin6_family = AF_INET6; memcpy(&sa_in6->sin6_addr, &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr, sizeof(sa_in6->sin6_addr)); +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID sa_in6->sin6_scope_id = ((struct sockaddr_in6 *)res->ai_addr)->sin6_scope_id; +#endif freeaddrinfo(res); } @@ -141,12 +149,16 @@ h->ss.ss_family = res->ai_family; if (res->ai_family == AF_INET) { sa_in = (struct sockaddr_in *)&h->ss; +#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN sa_in->sin_len = sizeof(struct sockaddr_in); +#endif sa_in->sin_addr.s_addr = ((struct sockaddr_in *) res->ai_addr)->sin_addr.s_addr; } else { sa_in6 = (struct sockaddr_in6 *)&h->ss; +#ifdef HAVE_STRUCT_SOCKADDR_IN6_SIN6_LEN sa_in6->sin6_len = sizeof(struct sockaddr_in6); +#endif memcpy(&sa_in6->sin6_addr, &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr, sizeof(struct in6_addr)); } diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/log.c ./log.c --- /usr/src/usr.sbin/ntpd/log.c Wed Aug 10 22:33:41 2005 +++ ./log.c Tue Apr 4 09:14:34 2006 @@ -16,6 +16,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "includes.h" + #include #include #include diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/ntp.c ./ntp.c --- /usr/src/usr.sbin/ntpd/ntp.c Thu Aug 11 04:48:28 2005 +++ ./ntp.c Tue Apr 4 09:14:34 2006 @@ -17,13 +17,19 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "includes.h" + #include #include #include #include #include -#include -#include +#ifdef HAVE_PATHS_H +# include +#endif +#ifdef HAVE_POLL_H +# include +#endif #include #include #include @@ -76,6 +82,7 @@ struct stat stb; time_t nextaction; void *newp; + char *chrootdir; switch (pid = fork()) { case -1: @@ -96,11 +103,17 @@ if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) fatal(NULL); - if (stat(pw->pw_dir, &stb) == -1) +#ifdef NTPD_CHROOT_DIR + chrootdir = NTPD_CHROOT_DIR; +#else + chrootdir = pw->pw_dir; +#endif + + if (stat(chrootdir, &stb) == -1) fatal("stat"); if (stb.st_uid != 0 || (stb.st_mode & (S_IWGRP|S_IWOTH)) != 0) fatal("bad privsep dir permissions"); - if (chroot(pw->pw_dir) == -1) + if (chroot(chrootdir) == -1) fatal("chroot"); if (chdir("/") == -1) fatal("chdir(\"/\")"); diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/ntp.h ./ntp.h --- /usr/src/usr.sbin/ntpd/ntp.h Wed Aug 10 22:33:41 2005 +++ ./ntp.h Tue Dec 14 12:22:14 2004 @@ -20,6 +20,8 @@ #ifndef _NTP_H_ #define _NTP_H_ +#include "includes.h" + /* Style borrowed from NTP ref/tcpdump and updated for SNTPv4 (RFC2030). */ /* diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/ntp_msg.c ./ntp_msg.c --- /usr/src/usr.sbin/ntpd/ntp_msg.c Thu Jan 19 18:02:03 2006 +++ ./ntp_msg.c Sat May 13 19:47:13 2006 @@ -64,7 +64,7 @@ { char buf[NTP_MSGSIZE]; char *p = buf; - socklen_t sa_len; + socklen_t salen; #define copyout(p,f) memcpy((p), &(f), sizeof(f)); p += sizeof(f) @@ -87,11 +87,11 @@ copyout(p, msg->xmttime.fractionl); if (sa != NULL) - sa_len = SA_LEN(sa); + salen = SA_LEN(sa); else - sa_len = 0; + salen = 0; - if (sendto(fd, &buf, len, 0, sa, sa_len) != len) { + if (sendto(fd, &buf, len, 0, sa, salen) != len) { if (errno == ENOBUFS || errno == EHOSTUNREACH || errno == ENETDOWN || errno == EHOSTDOWN) { /* logging is futile */ diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/ntpd.8 ./ntpd.8 --- /usr/src/usr.sbin/ntpd/ntpd.8 Thu Jun 23 10:13:49 2005 +++ ./ntpd.8 Tue Apr 4 09:14:34 2006 @@ -53,20 +53,6 @@ .Xr adjtime 2 will be logged. .Pp -.Nm -is usually started at boot time, and can be enabled by -setting the following in -.Pa /etc/rc.conf.local : -.Pp -.Dl ntpd_flags=\&"\&" -.Pp -See -.Xr rc 8 -and -.Xr rc.conf 8 -for more information on the boot process -and enabling daemons. -.Pp When .Nm starts up, it reads settings from a configuration file, @@ -110,8 +96,6 @@ .Xr date 1 , .Xr adjtime 2 , .Xr ntpd.conf 5 , -.Xr rc 8 , -.Xr rc.conf 8 , .Xr rdate 8 , .Xr timed 8 .Rs diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/ntpd.c ./ntpd.c --- /usr/src/usr.sbin/ntpd/ntpd.c Sat Feb 25 11:21:13 2006 +++ ./ntpd.c Tue Apr 4 09:14:34 2006 @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.c,v 1.41 2006/02/21 23:47:00 stevesk Exp $ */ +/* $OpenBSD: ntpd.c,v 1.40 2005/09/06 21:27:10 wvdputte Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -16,12 +16,18 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "includes.h" + +RCSID("$Release: OpenNTPD "OPENNTPD_VERSION" $"); + #include #include #include #include #include -#include +#ifdef HAVE_POLL_H +# include +#endif #include #include #include @@ -83,7 +89,10 @@ const char *conffile; int ch, nfds, timeout = INFTIM; int pipe_chld[2]; + extern char *__progname; + __progname = _compat_get_progname(argv[0]); + conffile = CONFFILE; bzero(&conf, sizeof(conf)); @@ -125,6 +134,10 @@ } endpwent(); +#ifndef HAVE_ARC4RANDOM + seed_rng(); +#endif + if (!conf.settime) { log_init(conf.debug); if (!conf.debug) @@ -292,8 +305,7 @@ if (name[imsg.hdr.len] != '\0' || strlen(name) != imsg.hdr.len) fatalx("invalid IMSG_HOST_DNS received"); - if ((cnt = host_dns(name, &hn)) == -1) - break; + cnt = host_dns(name, &hn); buf = imsg_create(ibuf, IMSG_HOST_DNS, imsg.hdr.peerid, 0, cnt * sizeof(struct sockaddr_storage)); diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/ntpd.h ./ntpd.h --- /usr/src/usr.sbin/ntpd/ntpd.h Thu Jan 19 18:02:03 2006 +++ ./ntpd.h Tue Apr 4 09:14:34 2006 @@ -19,7 +19,7 @@ #include #include #include -#include +#include "openbsd-compat/sys-queue.h" #include #include #include @@ -30,8 +30,10 @@ #include "ntp.h" +#ifndef NTPD_USER #define NTPD_USER "_ntp" -#define CONFFILE "/etc/ntpd.conf" +#endif +#define CONFFILE SYSCONFDIR "/ntpd.conf" #define READ_BUF_SIZE 4096 diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/parse.y ./parse.y --- /usr/src/usr.sbin/ntpd/parse.y Mon Jun 20 23:13:15 2005 +++ ./parse.y Tue Apr 4 09:14:34 2006 @@ -20,6 +20,8 @@ */ %{ +#include "includes.h" + #include #include #include diff -x CVS -x Makefile -ru /usr/src/usr.sbin/ntpd/server.c ./server.c --- /usr/src/usr.sbin/ntpd/server.c Thu Jan 19 22:20:23 2006 +++ ./server.c Tue Apr 4 09:14:34 2006 @@ -17,10 +17,15 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "includes.h" + #include #include #include -#include +#include +#ifdef HAVE_IFADDRS_H +# include +#endif #include #include #include