summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2002-01-19 00:32:05 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2002-01-19 00:32:05 +0000
commit0bed62f1fd692ede867a2f6fcfef3af8b3e89970 (patch)
treeaa759a8c6ec580a0c0eb39f645e3c3c1e86132ce
parent251a2697b63562acfdeb3105c0e4cdf555be4089 (diff)
do not bindresv() udp socket, for clockdiff to work w/ our inetd; millert@ ok
-rw-r--r--usr.sbin/timed/timedc/cmds.c24
-rw-r--r--usr.sbin/timed/timedc/timedc.c9
2 files changed, 17 insertions, 16 deletions
diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c
index 574ec85c33f..c5a73169c67 100644
--- a/usr.sbin/timed/timedc/cmds.c
+++ b/usr.sbin/timed/timedc/cmds.c
@@ -1,4 +1,4 @@
-/* $Id: cmds.c,v 1.11 2001/11/23 03:45:51 deraadt Exp $ */
+/* $Id: cmds.c,v 1.12 2002/01/19 00:32:04 mickey Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@@ -38,7 +38,7 @@ static char sccsid[] = "@(#)cmds.c 5.1 (Berkeley) 5/11/93";
#endif /* not lint */
#ifdef sgi
-#ident "$Revision: 1.11 $"
+#ident "$Revision: 1.12 $"
#endif
#include "timedc.h"
@@ -577,26 +577,30 @@ priv_resources()
{
struct sockaddr_in sin;
+ sock_raw = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
+ if (sock_raw < 0) {
+ perror("opening raw socket");
+ return (-1);
+ }
+
+ (void) seteuid(getuid());
+ (void) setuid(getuid());
+
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
perror("opening socket");
+ (void)close(sock_raw);
return (-1);
}
memset(&sin, 0, sizeof sin);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
- if (bindresvport(sock, &sin) < 0) {
+ if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
fprintf(stderr, "all reserved ports in use\n");
- (void)close(sock);
+ (void)close(sock_raw);
return (-1);
}
- sock_raw = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
- if (sock_raw < 0) {
- perror("opening raw socket");
- (void)close(sock);
- return (-1);
- }
return (1);
}
diff --git a/usr.sbin/timed/timedc/timedc.c b/usr.sbin/timed/timedc/timedc.c
index 33a38a9067a..11af4240679 100644
--- a/usr.sbin/timed/timedc/timedc.c
+++ b/usr.sbin/timed/timedc/timedc.c
@@ -1,4 +1,4 @@
-/* $Id: timedc.c,v 1.5 2001/11/23 03:45:51 deraadt Exp $ */
+/* $Id: timedc.c,v 1.6 2002/01/19 00:32:04 mickey Exp $ */
/*-
* Copyright (c) 1985, 1993 The Regents of the University of California.
@@ -44,7 +44,7 @@ static char sccsid[] = "@(#)timedc.c 5.1 (Berkeley) 5/11/93";
#endif /* not lint */
#ifdef sgi
-#ident "$Revision: 1.5 $"
+#ident "$Revision: 1.6 $"
#endif
#include "timedc.h"
@@ -80,10 +80,7 @@ main(int argc, char *argv[])
fprintf(stderr, "Could not get privileged resources\n");
exit(1);
}
- /* revoke privs */
-
- (void) seteuid(getuid());
- (void) setuid(getuid());
+ /* privs revoked above */
if (--argc > 0) {
c = getcmd(*++argv);