Bug 173005 - [patch] pw(8) - 'pw usermod' causes Segmentation fault: 11 (core dumped)
Summary: [patch] pw(8) - 'pw usermod' causes Segmentation fault: 11 (core dumped)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Baptiste Daroussin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-23 23:20 UTC by jb.1234abcd
Modified: 2013-05-31 13:55 UTC (History)
0 users

See Also:


Attachments
pw_empty_group.patch (574 bytes, patch)
2012-10-28 05:36 UTC, Mark Johnston
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jb.1234abcd 2012-10-23 23:20:00 UTC
# pw usermod moo4 -g ""
Segmentation fault: 11 (core dumped)
#

How-To-Repeat: as above
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2012-10-24 04:17:33 UTC
On 23 October 2012 18:19, jb <jb.1234abcd@gmail.com> wrote:
>>Description:
> # pw usermod moo4 -g ""
> Segmentation fault: 11 (core dumped)

note to the person who fixes this: this is reproducible as root on

FreeBSD radar 10.0-CURRENT FreeBSD 10.0-CURRENT #1 r239951: Fri Aug 31
10:32:27 PDT 2012     eitan@radar:/usr/obj/more/src/sys/GENERIC  amd64

if the user exists.

-- 
Eitan Adler
Comment 2 Mark Johnston 2012-10-28 05:36:57 UTC
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
Comment 3 jb.1234abcd 2012-10-28 09:03:36 UTC
Well done, except for error message.

It should be:
# pw usermod mark -g ""
pw: group `' is not defined

which would be consistent with:
# pw useradd mark -g ""
pw: group `' is not defined

jb
Comment 4 Mark Johnston 2012-10-28 18:53:29 UTC
With my patch the error message is consistent:

# pw useradd mark -g ""
pw: group `' does not exist
# pw usermod mark -g ""
pw: group `' does not exist
#
Comment 5 jb.1234abcd 2012-10-28 19:41:50 UTC
This is the current (unpatched) state:

# pw useradd moo -g moo
pw: group `moo' does not exist
# pw useradd moo -g boo
pw: group `boo' does not exist
# pw useradd moo -g ""
pw: group `' is not defined

As you can see there is a distinction between error msgs
based on user input of primary group (or lack of it).
That's why I asked you to be consistent with past and
current user experience.
jb
Comment 6 Mark Johnston 2012-10-29 04:15:55 UTC
The error messages aren't different by design though - the different
behaviour for -g "" is a side-effect of the change I mentioned in the
first email. There is no practical distinction between those two errors
anyway - they come from two essentially identical checks at different points
in the code.

In fact, the "... is not defined" check is redundant and can be
removed/simplified if my patch is applied. Specifically, that check only
fails with -g "" in the unpatched pw(8).

-Mark
Comment 7 jb.1234abcd 2012-10-29 06:15:10 UTC
Simplifying for user is good.
So, go ahead - that segmentation fault looks bad :-)
jb
Comment 8 Baptiste Daroussin freebsd_committer freebsd_triage 2012-10-30 08:11:28 UTC
Responsible Changed
From-To: freebsd-bugs->bapt

I'll take it.
Comment 9 Baptiste Daroussin freebsd_committer freebsd_triage 2013-05-31 13:55:56 UTC
State Changed
From-To: open->closed

This has been fixed long ago, forgot to close, thanks for reporting