Bug 202111 - Core dumped in pw usermod
Summary: Core dumped in pw usermod
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.2-STABLE
Hardware: amd64 Any
: --- Affects Many People
Assignee: Baptiste Daroussin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-05 20:08 UTC by gondim
Modified: 2015-08-06 18:01 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description gondim 2015-08-05 20:08:54 UTC
Hi All,

I found the following problem with the pw:

FreeBSD srv.teste.com.br 10.1-STABLE FreeBSD 10.1-STABLE #14 r276979: Wed Jan 21 11:50:11 BRST 2015 root@srv.teste.com.br:/usr/obj/usr/src/sys/TESTE  amd64

# pw useradd foo
# pw usermod foo -u 5000
#

It's OK

But

FreeBSD srv.teste.com.br 10.2-RC2 FreeBSD 10.2-RC2 #1 r286291: Wed Aug  5 10:03:45 BRT 2015 root@srv.teste.com.br:/usr/obj/usr/src/sys/TESTE  amd64

# pw useradd foo
# pw usermod foo -u 5000
Segmentation fault (core dumped)
#
Comment 1 Glen Barber freebsd_committer freebsd_triage 2015-08-05 20:20:46 UTC
This works as expected in 11-CURRENT:

 root@releng2:/ # pw usermod hast -u 5000
 root@releng2:/ # grep hast /etc/passwd
 hast:*:5000:845:HAST unprivileged user:/var/empty:/usr/sbin/nologin

I can reproduce this in 10.2-RC2:

 root@releng1:/usr/src # pw usermod cups -u 194
 Segmentation fault (core dumped)
 root@releng1:/usr/src # grep cups /etc/passwd
 cups:*:193:193:Cups Owner:/nonexistent:/usr/sbin/nologin
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-08-05 20:33:08 UTC
A commit references this bug:

Author: bapt
Date: Wed Aug  5 20:32:08 UTC 2015
New revision: 286340
URL: https://svnweb.freebsd.org/changeset/base/286340

Log:
  Fix segfault were modifying the uid of a user

  Do a direct commit as the code on head has changed a lot and does not fail in
  that case

  PR:		202111
  Reported by:	gondim@bsdinfo.com.br

Changes:
  stable/10/usr.sbin/pw/pw_user.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-08-06 01:39:45 UTC
A commit references this bug:

Author: gjb
Date: Thu Aug  6 01:39:24 UTC 2015
New revision: 286357
URL: https://svnweb.freebsd.org/changeset/base/286357

Log:
  MFS r286340 (bapt):
    Fix segfault in pw(8) when modifying the UID of
    a user.

  PR:		202111
  Approved by:	re (delphij)
  Sponsored by:	The FreeBSD Foundation

Changes:
_U  releng/10.2/
  releng/10.2/usr.sbin/pw/pw_user.c
Comment 4 Glen Barber freebsd_committer freebsd_triage 2015-08-06 01:40:39 UTC
Fixed.  Thank you for the report.
Comment 5 Xin LI freebsd_committer freebsd_triage 2015-08-06 18:01:30 UTC
Assign this to bapt@ who have created the fix for completeness (please ignore: this is already addressed in the affected releng/10.2 branch).