summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-07-20 12:14:52 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-07-20 12:14:52 +0000
commit41dda74b6ab048d254d6093dc924979d8ab493f4 (patch)
tree2c02e099cf62b8d9495df66779dc2bedc5e8a3fb /usr.sbin
parent9ed2c8f8e5b5254615df0f4f855c5d05a5de5318 (diff)
try to make pingsock and rpcsock resv too
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ypbind/ypbind.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.sbin/ypbind/ypbind.c b/usr.sbin/ypbind/ypbind.c
index fa020db4afb..05ec34f0d15 100644
--- a/usr.sbin/ypbind/ypbind.c
+++ b/usr.sbin/ypbind/ypbind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ypbind.c,v 1.45 2002/06/29 07:32:15 deraadt Exp $ */
+/* $OpenBSD: ypbind.c,v 1.46 2002/07/20 12:14:51 deraadt Exp $ */
/*
* Copyright (c) 1997,1998 Theo de Raadt <deraadt@OpenBSD.org>
@@ -35,7 +35,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$OpenBSD: ypbind.c,v 1.45 2002/06/29 07:32:15 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ypbind.c,v 1.46 2002/07/20 12:14:51 deraadt Exp $";
#endif
#include <sys/param.h>
@@ -441,6 +441,7 @@ main(int argc, char *argv[])
exit(1);
}
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sin.sin_port = 0;
if (bind(lsock, (struct sockaddr *)&sin, len) != 0) {
syslog(LOG_ERR, "cannot bind local udp: %m");
exit(1);
@@ -464,6 +465,7 @@ main(int argc, char *argv[])
exit(1);
}
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ sin.sin_port = 0;
if (bind(lsock, (struct sockaddr *)&sin, len) == -1) {
syslog(LOG_ERR, "cannot bind udp: %m");
exit(1);
@@ -478,10 +480,21 @@ main(int argc, char *argv[])
perror("socket");
return -1;
}
+ memset(&sin, 0, sizeof sin);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = htonl(INADDR_ANY);
+ sin.sin_port = 0;
+ bindresvport(rpcsock, &sin);
+
if ((pingsock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
perror("socket");
return -1;
}
+ memset(&sin, 0, sizeof sin);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = htonl(INADDR_ANY);
+ sin.sin_port = 0;
+ bindresvport(pingsock, &sin);
fcntl(rpcsock, F_SETFL, fcntl(rpcsock, F_GETFL, 0) | FNDELAY);
fcntl(pingsock, F_SETFL, fcntl(pingsock, F_GETFL, 0) | FNDELAY);