File: ntpd-vs-openbsd.diff

package info (click to toggle)
openntpd 3.9p1-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 952 kB
  • ctags: 725
  • sloc: ansic: 4,379; sh: 2,730; yacc: 354; awk: 323; makefile: 218
file content (323 lines) | stat: -rw-r--r-- 8,491 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
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 <sys/types.h>
 #include <sys/uio.h>
 
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 <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
@@ -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 <errno.h>
 #include <stdarg.h>
 #include <stdio.h>
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 <sys/param.h>
 #include <sys/time.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <paths.h>
-#include <poll.h>
+#ifdef HAVE_PATHS_H
+# include <paths.h>
+#endif
+#ifdef HAVE_POLL_H
+# include <poll.h>
+#endif
 #include <pwd.h>
 #include <signal.h>
 #include <stdlib.h>
@@ -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 <henning@openbsd.org>
@@ -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 <sys/types.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <netinet/in.h>
 #include <errno.h>
-#include <poll.h>
+#ifdef HAVE_POLL_H
+# include <poll.h>
+#endif
 #include <pwd.h>
 #include <resolv.h>
 #include <signal.h>
@@ -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 <sys/types.h>
 #include <sys/uio.h>
 #include <sys/socket.h>
-#include <sys/queue.h>
+#include "openbsd-compat/sys-queue.h"
 #include <sys/time.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -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 <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
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 <sys/types.h>
 #include <sys/socket.h>
 #include <errno.h>
-#include <ifaddrs.h>
+#include <netinet/in.h>
+#ifdef HAVE_IFADDRS_H
+# include <ifaddrs.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>