diff options
author | Hiroki Sato <hrs@FreeBSD.org> | 2010-01-20 09:29:07 +0000 |
---|---|---|
committer | Hiroki Sato <hrs@FreeBSD.org> | 2010-01-20 09:29:07 +0000 |
commit | d04ef9128c97d23de19fe1a95f53d6b4e70d9f20 (patch) | |
tree | 51f1d92e7a5e825d93537bb85bd27e6d2006cb46 /usr.sbin | |
parent | e5c9c8533d352dd8dd61828f0f009d26eb5876ed (diff) | |
download | src-d04ef9128c97d23de19fe1a95f53d6b4e70d9f20.tar.gz src-d04ef9128c97d23de19fe1a95f53d6b4e70d9f20.zip |
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
Notes
Notes:
svn path=/head/; revision=202686
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ypserv/yp_main.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.sbin/ypserv/yp_main.c b/usr.sbin/ypserv/yp_main.c index 8df5544dedd0..7fe27903a93c 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); |