Subject: lib/1509: mountd is less than informative on invalid /etc/exports
To: None <gnats-bugs@NetBSD.ORG>
From: None <abs@mono.org>
List: netbsd-bugs
Date: 09/25/1995 10:31:17
>Number:         1509
>Category:       lib
>Synopsis:       mountd is less than informative on invalid /etc/exports
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 25 17:20:01 1995
>Last-Modified:
>Originator:     David Brownlee
>Organization:
Monochrome
>Release:        Aug 22th 1995
>Environment:
sparc, 1.0A, current
System: NetBSD gluon.mono.org 1.0A NetBSD 1.0A (GLUON) #1: monoadm@gluon.mono.org:/mono/u1/NetBSD/src/sys/arch/sparc/compile/GLUON sparc

>Description:
	If mountd is unable to export a filesystem due to an invalid hostname,
	or a hostname specified on two (conflicting) lines or similar it gives
	no indication of which entry caused the problem. This can be a real
	pain when you get into using netgroups...

>How-To-Repeat:
	Add an invalid hostname, or dotted IP address to a line in
	/etc/exports. Or export a filesystem to two netgroups with differing
	permissions and have a hostname in both netgroups. Now try to figure
	out which hostname is the problem.

	The first four lines are from syslog without the patch, the second
	four with the patch.
	
gluon mountd[16959]: Can't change attributes for /mono/netbsd.
gluon mountd[16959]: Bad exports list line /mono/netbsd	-alldirs -maproot
gluon mountd[17101]: Gethostbyname failed
gluon mountd[17101]: Bad exports list line /mono/netbsd	-alldirs -maproot

gluon mountd[16960]: Can't change attributes for /mono/netbsd to nine-inch-nails.city.ac.uk.
gluon mountd[16960]: Bad exports list line /mono/netbsd	-maproot
gluon mountd[17145]: Gethostbyname failed for blobby.
gluon mountd[17145]: Bad exports list line /mono/netbsd	-alldirs -maproot

>Fix:

*** sbin/mountd/mountd.c.orig	Mon Sep 25 09:57:48 1995
--- sbin/mountd/mountd.c	Mon Sep 25 10:18:59 1995
***************
*** 1296,1302 ****
  		if (isdigit(*cp)) {
  			saddr = inet_addr(cp);
  			if (saddr == -1) {
! 				syslog(LOG_ERR, "Inet_addr failed");
  				return (1);
  			}
  			if ((hp = gethostbyaddr((caddr_t)&saddr, sizeof (saddr),
--- 1296,1302 ----
  		if (isdigit(*cp)) {
  			saddr = inet_addr(cp);
  			if (saddr == -1) {
! 				syslog(LOG_ERR, "Inet_addr failed for %s.",cp);
  				return (1);
  			}
  			if ((hp = gethostbyaddr((caddr_t)&saddr, sizeof (saddr),
***************
*** 1310,1316 ****
  				aptr[1] = (char *)NULL;
  			}
  		} else {
! 			syslog(LOG_ERR, "Gethostbyname failed");
  			return (1);
  		}
  	}
--- 1310,1316 ----
  				aptr[1] = (char *)NULL;
  			}
  		} else {
! 			syslog(LOG_ERR, "Gethostbyname failed for %s.",cp);
  			return (1);
  		}
  	}
***************
*** 1543,1549 ****
  				cp = dirp + dirplen - 1;
  			if (errno == EPERM) {
  				syslog(LOG_ERR,
! 				   "Can't change attributes for %s.\n", dirp);
  				return (1);
  			}
  			if (opt_flags & OP_ALLDIRS) {
--- 1543,1556 ----
  				cp = dirp + dirplen - 1;
  			if (errno == EPERM) {
  				syslog(LOG_ERR,
! 				   "Can't change attributes for %s to %s.\n",
! 					dirp,
! 					(grp->gr_type == GT_HOST)
! 					    ?grp->gr_ptr.gt_hostent->h_name
! 					:(grp->gr_type == GT_NET)
! 					    ?grp->gr_ptr.gt_net.nt_name
! 					:"Unknown");
! 				/* XXX: Get address from sockaddr_iso? */
  				return (1);
  			}
  			if (opt_flags & OP_ALLDIRS) {
>Audit-Trail:
>Unformatted: