From iaint@css.tuu.utas.edu.au  Thu May 22 22:20:40 1997
Received: from css.tuu.utas.edu.au (css.tuu.utas.edu.au [131.217.115.65])
          by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id WAA01714
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 22 May 1997 22:20:36 -0700 (PDT)
Received: (from root@localhost)
	by css.tuu.utas.edu.au (8.8.5/8.8.5) id PAA26341;
	Fri, 23 May 1997 15:20:39 +1000 (EST)
Message-Id: <199705230520.PAA26341@css.tuu.utas.edu.au>
Date: Fri, 23 May 1997 15:20:39 +1000 (EST)
From: iaint@css.tuu.utas.edu.au
Reply-To: iain@ugh.net.au
To: FreeBSD-gnats-submit@freebsd.org
Subject: /usr/sbin/pw has error reading skeleton directories
X-Send-Pr-Version: 3.2

>Number:         3666
>Category:       bin
>Synopsis:       /usr/sbin/pw has error reading skeleton directories
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 22 22:30:01 PDT 1997
>Closed-Date:    Sat May 24 20:44:52 EST 1997
>Last-Modified:  Sat May 24 20:46:14 EST 1997
>Originator:     Iain Templeton
>Release:        FreeBSD 2.2.1-RELEASE i386
>Organization:
UgH!
>Environment:

	Standard 2.2.1 release
	
>Description:

	/usr/sbin/pw has trouble during useradd when trying to use the -k
	(skeleton directory) option. It claims that the directory specified
	does not exist. However that was not the case. Using directories which
	I knew existed (such as /root), it still failed.
	
>How-To-Repeat:

	pw useradd -n test -c 'Test User' -g test -m -k /usr/share/skel
	Or just use any variant of useradd with -k

>Fix:
	
	On line 232 of the file /usr/src/usr.sbin/pw/pw_user.c there is a test
	on whether a stat()'ed file is a directory (S_ISDIR()). The logical
	sense of this should be the other way around, as it will cause an error
	if the directory does exist. The following context diff has what I 
	did to change the problem.

	Note: Some of the lines appear to wrap on a narrow display.


*** pw_user.c.orig	Fri May 23 14:46:08 1997
--- pw_user.c	Fri May 23 14:47:39 1997
***************
*** 229,235 ****
  			cnf->groups[i++] = NULL;
  	}
  	if ((arg = getarg(args, 'k')) != NULL) {
! 		if (stat(cnf->dotdir = arg->val, &st) == -1 || S_ISDIR(st.st_mode))
  			cmderr(EX_OSFILE, "skeleton `%s' is not a directory or does not exist\n", cnf->dotdir);
  	}
  	if ((arg = getarg(args, 's')) != NULL)
--- 229,235 ----
  			cnf->groups[i++] = NULL;
  	}
  	if ((arg = getarg(args, 'k')) != NULL) {
! 		if (stat(cnf->dotdir = arg->val, &st) == -1 || !S_ISDIR(st.st_mode))
  			cmderr(EX_OSFILE, "skeleton `%s' is not a directory or does not exist\n", cnf->dotdir);
  	}
  	if ((arg = getarg(args, 's')) != NULL)
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: davidn 
State-Changed-When: Sat May 24 20:44:52 EST 1997 
State-Changed-Why:  
Checking in pw_user.c; 
/home/ncvs/src/usr.sbin/pw/pw_user.c,v  <--  pw_user.c 
new revision: 1.1.1.1.2.8; previous revision: 1.1.1.1.2.7 
done 

Patch applied (to all three branches), thanks! 
>Unformatted:
