From alm@mclink.com  Sat Aug 23 17:49:11 1997
Received: from mclink.com (mclink.com [207.137.208.2])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id RAA25078
          for <FreeBSD-gnats-submit@freebsd.org>; Sat, 23 Aug 1997 17:49:10 -0700 (PDT)
Received: (from root@localhost)
          by mclink.com (8.8.5/8.8.4)
	  id RAA06333; Sat, 23 Aug 1997 17:49:09 -0700 (PDT)
Message-Id: <199708240049.RAA06333@mclink.com>
Date: Sat, 23 Aug 1997 17:49:09 -0700 (PDT)
From: "Andrew L. Moore" <alm@mclink.com>
Reply-To: alm@mclink.com
To: FreeBSD-gnats-submit@freebsd.org
Cc: alm@mclink.com
Subject: patch for: pw(8) - non-blank `defaultgroup' not accepted
X-Send-Pr-Version: 3.104

>Number:         4365
>Category:       bin
>Synopsis:       patch for: pw(8) - non-blank `defaultgroup' not accepted
>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:   Sat Aug 23 17:50:01 PDT 1997
>Closed-Date:    Mon Sep 1 19:33:28 EST 1997
>Last-Modified:  Mon Sep  1 19:34:40 EST 1997
>Originator:     Andrew L. Moore
>Release:        FreeBSD 2.2-STABLE i386
>Organization:
	
>Environment:
	all versions of pw(8) through -current (3.0)
System: FreeBSD ns.mclink.com 2.2-STABLE FreeBSD 2.2-STABLE #1: Wed May 28 02:06:16 PDT 1997 alm@ns.mclink.com:/u2/home/freebsd/src-2.2/sys/compile/NS i386


>Description:
	If /etc/pw.conf is set with a valid non-blank `defaultgroup', the
	command `pw user add foo' still creates a new group per user.
        Cause: pw_conf.c calls getgrnam(3) with a quoted arg.
>How-To-Repeat:
	# echo "user1:*:100:" >>/etc/group
	# sed 's/^\(defaultgroup\).*/\1 = "user1"/' /etc/pw.conf >/tmp/foo &&
	> mv /tmp/foo /etc/pw.conf
	# pw user add foo -N
>Fix:
	unquote(arg) i.e.:

diff -u -r1.1.1.1.2.1 pw_conf.c
--- pw_conf.c	1996/12/11 00:14:15	1.1.1.1.2.1
+++ pw_conf.c	1997/08/23 23:40:03
@@ -287,7 +287,7 @@
 							? (char *) bourne_shell : newstr(q);
 						break;
 					case _UC_DEFAULTGROUP:
-						config.default_group = (q == NULL || !boolean_val(q, 1) || getgrnam(q) == NULL)
+						config.default_group = ((q = unquote(q)) == NULL || !boolean_val(q, 1) || getgrnam(q) == NULL)
 							? NULL : newstr(q);
 						break;
 					case _UC_EXTRAGROUPS:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: davidn 
State-Changed-When: Mon Sep 1 19:33:28 EST 1997 
State-Changed-Why:  
Fixed in the following revisions: 
/home/ncvs/src/usr.sbin/pw/pw_conf.c,v  <--  pw_conf.c 
new revision: 1.1.1.1.2.2; previous revision: 1.1.1.1.2.1 
/home/ncvs/src/usr.sbin/pw/pw_conf.c,v  <--  pw_conf.c 
new revision: 1.6; previous revision: 1.5 

Thanks for the bug report. 
>Unformatted:
