From owner-svn-src-all@FreeBSD.ORG Wed Jan 20 09:29:07 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 97983106566B; Wed, 20 Jan 2010 09:29:07 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 87AC38FC13; Wed, 20 Jan 2010 09:29:07 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0K9T7WJ072169; Wed, 20 Jan 2010 09:29:07 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0K9T7m0072167; Wed, 20 Jan 2010 09:29:07 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201001200929.o0K9T7m0072167@svn.freebsd.org> From: Hiroki Sato Date: Wed, 20 Jan 2010 09:29:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202686 - head/usr.sbin/ypserv X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jan 2010 09:29:07 -0000 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);