svn commit: r202686 - head/usr.sbin/ypserv
Hiroki Sato
hrs at FreeBSD.org
Wed Jan 20 09:29:07 UTC 2010
Author: hrs
Date: Wed Jan 20 09:29:07 2010
New Revision: 202686
URL: http://svn.freebsd.org/changeset/base/202686
Log:
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
Modified:
head/usr.sbin/ypserv/yp_main.c
Modified: head/usr.sbin/ypserv/yp_main.c
==============================================================================
--- head/usr.sbin/ypserv/yp_main.c Wed Jan 20 09:26:28 2010 (r202685)
+++ head/usr.sbin/ypserv/yp_main.c Wed Jan 20 09:29:07 2010 (r202686)
@@ -303,13 +303,18 @@ create_service(const int sock, const str
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);
More information about the svn-src-all
mailing list