From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 28 05:40:01 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7E51AE29 for ; Sun, 28 Oct 2012 05:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (unknown [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 4276A8FC0C for ; Sun, 28 Oct 2012 05:40:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q9S5e1Hh033614 for ; Sun, 28 Oct 2012 05:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q9S5e1GS033613; Sun, 28 Oct 2012 05:40:01 GMT (envelope-from gnats) Date: Sun, 28 Oct 2012 05:40:01 GMT Message-Id: <201210280540.q9S5e1GS033613@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Mark Johnston Subject: Re: bin/173005: PW(8) - 'pw usermod' causes Segmentation fault: 11 (core dumped) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Mark Johnston List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Oct 2012 05:40:01 -0000 The following reply was made to PR bin/173005; it has been noted by GNATS. From: Mark Johnston To: bug-followup@FreeBSD.org, jb.1234abcd@gmail.com, lists@eitanadler.com Cc: Subject: Re: bin/173005: PW(8) - 'pw usermod' causes Segmentation fault: 11 (core dumped) Date: Sun, 28 Oct 2012 01:36:57 -0400 --TB36FDmn/VVEgNH/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Looks like this was introduced by r63596, which itself was a fix for bin/5717: http://www.freebsd.org/cgi/query-pr.cgi?pr=5717 Basically, pw(8) allows '-g ""' when setting the default group for new users; it has a special meaning, described in the man page. I think the right fix is to check for -D before proceeding when running with -g "". With the attached patch, 'pw useradd -D -g ""' still does the right thing, and we also have # pw usermod mark -g "" pw: group `' does not exist # which I think is the right behaviour. Thanks, -Mark --TB36FDmn/VVEgNH/ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pw_empty_group.patch" diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c index 1b72cbd..26d13cf 100644 --- a/usr.sbin/pw/pw_user.c +++ b/usr.sbin/pw/pw_user.c @@ -228,7 +228,8 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) cnf->password_days = atoi(arg->val); if ((arg = getarg(args, 'g')) != NULL) { - if (!*(p = arg->val)) /* Handle empty group list specially */ + /* Handle empty group list specially when defining a default group. */ + if (!*(p = arg->val) && getarg(args, 'D')) cnf->default_group = ""; else { if ((grp = GETGRNAM(p)) == NULL) { --TB36FDmn/VVEgNH/--