From owner-freebsd-bugs Thu May 22 22:30:05 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id WAA02033 for bugs-outgoing; Thu, 22 May 1997 22:30:05 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id WAA02019; Thu, 22 May 1997 22:30:02 -0700 (PDT) Resent-Date: Thu, 22 May 1997 22:30:02 -0700 (PDT) Resent-Message-Id: <199705230530.WAA02019@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, iain@ugh.net.au 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 ; 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 X-Send-Pr-Version: 3.2 Subject: bin/3666: /usr/sbin/pw has error reading skeleton directories Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 3666 >Category: bin >Synopsis: /usr/sbin/pw has error reading skeleton directories >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu May 22 22:30:01 PDT 1997 >Last-Modified: >Originator: Iain Templeton >Organization: UgH! >Release: FreeBSD 2.2.1-RELEASE i386 >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) >Audit-Trail: >Unformatted: