summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2010-01-20 09:29:07 +0000
committerhrs <hrs@FreeBSD.org>2010-01-20 09:29:07 +0000
commit479b4bd55d3e5c011349f9d309d54f67fcd0a666 (patch)
tree51f1d92e7a5e825d93537bb85bd27e6d2006cb46 /usr.sbin
parent6180083f03d0f1b2533b0fc8af51e539000418a2 (diff)
downloadFreeBSD-src-479b4bd55d3e5c011349f9d309d54f67fcd0a666.zip
FreeBSD-src-479b4bd55d3e5c011349f9d309d54f67fcd0a666.tar.gz
Try a privileged port for binding whenever possible because the
ypbind daemon requires the ypserv daemon is running on a privileged port. Reported by: Andrzej Tobola
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ypserv/yp_main.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c
index 8df5544..7fe2790 100644
--- a/usr.sbin/ypserv/yp_main.c
+++ b/usr.sbin/ypserv/yp_main.c
@@ -303,13 +303,18 @@ create_service(const int sock, const struct netconfig *nconf,
freeaddrinfo(res0);
return -1;
}
- if (bind(s, res->ai_addr,
- res->ai_addrlen) == -1) {
- _msgout("cannot bind %s socket: %s",
- nconf->nc_netid, strerror(errno));
- freeaddrinfo(res0);
- close(sock);
- return -1;
+ if (bindresvport_sa(s, res->ai_addr) == -1) {
+ if ((errno != EPERM) ||
+ (bind(s, res->ai_addr,
+ res->ai_addrlen) == -1)) {
+ _msgout("cannot bind "
+ "%s socket: %s",
+ nconf->nc_netid,
+ strerror(errno));
+ freeaddrinfo(res0);
+ close(sock);
+ return -1;
+ }
}
if (nconf->nc_semantics != NC_TPI_CLTS)
listen(s, SOMAXCONN);
OpenPOWER on IntegriCloud