Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Oct 2012 05:40:01 GMT
From:      Mark Johnston <markjdb@gmail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/173005: PW(8) - &#39;pw usermod&#39; causes Segmentation fault: 11 (core dumped)
Message-ID:  <201210280540.q9S5e1GS033613@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/173005; it has been noted by GNATS.

From: Mark Johnston <markjdb@gmail.com>
To: bug-followup@FreeBSD.org, jb.1234abcd@gmail.com, lists@eitanadler.com
Cc:  
Subject: Re: bin/173005: PW(8) - &#39;pw usermod&#39; 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/--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210280540.q9S5e1GS033613>