From mblapp@fuchur.lan.attic.ch  Sun Mar 25 04:50:06 2001
Return-Path: <mblapp@fuchur.lan.attic.ch>
Received: from fuchur.lan.attic.ch (fuchur.lan.attic.ch [194.235.47.21])
	by hub.freebsd.org (Postfix) with ESMTP id 1B2DE37B719
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 25 Mar 2001 04:50:04 -0800 (PST)
	(envelope-from mblapp@fuchur.lan.attic.ch)
Received: (from root@localhost)
	by fuchur.lan.attic.ch (8.11.3/8.11.3) id f2PCod939621;
	Sun, 25 Mar 2001 14:50:39 +0200 (CEST)
	(envelope-from mblapp)
Message-Id: <200103251250.f2PCod939621@fuchur.lan.attic.ch>
Date: Sun, 25 Mar 2001 14:50:39 +0200 (CEST)
From: mb@imp.ch
Reply-To: mb@imp.ch
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [Fix] mountd with ipv4 only
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         26068
>Category:       bin
>Synopsis:       [Fix] mountd with ipv4 only
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 25 05:00:00 PST 2001
>Closed-Date:    Sun Mar 25 07:23:53 PST 2001
>Last-Modified:  Wed Oct 26 06:36:41 GMT 2005
>Originator:     Martin Blapp
>Release:        
>Organization:
>Environment:
>Description:

Deal with cases where in /etc/netconfig there are commented out ipv6 entries
or kernels which only provide IPv4 functionality. We should always test both
cases, netconfig and ipv6 support.

Also replace pmap_unset() with rpcb_unset() which fixes the unregistering.

>How-To-Repeat:

>Fix:

http://home.teleport.ch/freebsd/mountd.c.diff

--- sbin/mountd/mountd.c	Mon Mar 19 13:50:01 2001
+++ sbin/mountd/mountd.c	Sat Mar 24 13:02:25 2001
@@ -352,27 +352,29 @@
 	rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL);
 	udpsock  = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
 	tcpsock  = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-	udp6sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
-	tcp6sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
+	udpconf  = getnetconfigent("udp");
+	tcpconf  = getnetconfigent("tcp");
+	if (have_v6) {
+		udp6sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+		tcp6sock = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP);
 	/*
 	 * We're doing host-based access checks here, so don't allow
 	 * v4-in-v6 to confuse things. The kernel will disable it
 	 * by default on NFS sockets too.
 	 */
-	if (udp6sock != -1 && setsockopt(udp6sock, IPPROTO_IPV6,
-		IPV6_BINDV6ONLY, &one, sizeof one) < 0){
-		syslog(LOG_ERR, "can't disable v4-in-v6 on UDP socket");
-		exit(1);
-	}
-	if (tcp6sock != -1 && setsockopt(tcp6sock, IPPROTO_IPV6,
-		IPV6_BINDV6ONLY, &one, sizeof one) < 0){
-		syslog(LOG_ERR, "can't disable v4-in-v6 on UDP socket");
-		exit(1);
+		if (udp6sock != -1 && setsockopt(udp6sock, IPPROTO_IPV6,
+			IPV6_BINDV6ONLY, &one, sizeof one) < 0){
+			syslog(LOG_ERR, "can't disable v4-in-v6 on UDP socket");
+			exit(1);
+		}
+		if (tcp6sock != -1 && setsockopt(tcp6sock, IPPROTO_IPV6,
+			IPV6_BINDV6ONLY, &one, sizeof one) < 0){
+			syslog(LOG_ERR, "can't disable v4-in-v6 on UDP socket");
+			exit(1);
+		}
+		udp6conf = getnetconfigent("udp6");
+		tcp6conf = getnetconfigent("tcp6");
 	}
-	udpconf  = getnetconfigent("udp");
-	tcpconf  = getnetconfigent("tcp");
-	udp6conf = getnetconfigent("udp6");
-	tcp6conf = getnetconfigent("tcp6");
 	if (!resvport_only) {
 		mib[0] = CTL_VFS;
 		mib[1] = vfc.vfc_typenum;
@@ -429,7 +431,7 @@
 			syslog(LOG_WARNING, "can't create TCP service");
 
 	}
-	if (udp6sock != -1 && udp6conf != NULL) {
+	if (have_v6 && udp6sock != -1 && udp6conf != NULL) {
 		bindresvport(udp6sock, NULL);
 		udp6transp = svc_dg_create(udp6sock, 0, 0);
 		if (udp6transp != NULL) {
@@ -449,7 +451,7 @@
 			syslog(LOG_WARNING, "can't create UDP6 service");
 
 	}
-	if (tcp6sock != -1 && tcp6conf != NULL) {
+	if (have_v6 && tcp6sock != -1 && tcp6conf != NULL) {
 		bindresvport(tcp6sock, NULL);
 		listen(tcp6sock, SOMAXCONN);
 		tcp6transp = svc_vc_create(tcp6sock, 0, 0);
@@ -2502,7 +2504,7 @@
 {
 	close(mountdlockfd);
 	unlink(MOUNTDLOCK);
-	pmap_unset(RPCPROG_MNT, 1);
-	pmap_unset(RPCPROG_MNT, 3);
+	rpcb_unset(RPCPROG_MNT, RPCMNT_VER1, NULL);
+	rpcb_unset(RPCPROG_MNT, RPCMNT_VER3, NULL);
 	exit (0);
 }
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: roam 
State-Changed-When: Sun Mar 25 07:23:53 PST 2001 
State-Changed-Why:  
Misfiled; originator shall refile. 


Responsible-Changed-From-To: gnats-admin->bugs 
Responsible-Changed-By: roam 
Responsible-Changed-When: Sun Mar 25 07:23:53 PST 2001 
Responsible-Changed-Why:  
Misfiled. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26068 
>Unformatted:
 System: FreeBSD fuchur.lan.attic.ch 5.0-CURRENT FreeBSD 5.0-CURRENT #8: Tue Mar 20 14:39:22 CET 2001 root@fuchur.lan.attic.ch:/usr/src/sys/compile/MARTIN i386
 
