diff options
author | 2002-01-19 00:32:04 +0000 | |
---|---|---|
committer | 2002-01-19 00:32:04 +0000 | |
commit | dc397644c2a7ceda1e339345c7d921bb278ce030 (patch) | |
tree | ce490a419e4dfe9015d2d69abe362acbffaf30b2 | |
parent | We don't have <sys/map.h> any more; Tim Tickel (diff) | |
download | wireguard-openbsd-dc397644c2a7ceda1e339345c7d921bb278ce030.tar.xz wireguard-openbsd-dc397644c2a7ceda1e339345c7d921bb278ce030.zip |
do not bindresv() udp socket, for clockdiff to work w/ our inetd; millert@ ok
-rw-r--r-- | usr.sbin/timed/timedc/cmds.c | 24 | ||||
-rw-r--r-- | usr.sbin/timed/timedc/timedc.c | 9 |
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); |