Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Mar 2003 19:49:04 -0800 (PST)
From:      System Admin <kevin_stevens@pursued-with.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        kevin_stevens@pursued-with.net
Subject:    bin/50331: Changing uid with pw causes duplicate username/uid pairs.
Message-ID:  <200303270349.h2R3n4sj065607@babelfish.pursued-with.net>
Resent-Message-ID: <200303270350.h2R3oCnI012612@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         50331
>Category:       bin
>Synopsis:       Changing uid with pw causes duplicate username/uid pairs.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 26 19:50:12 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     kevin_stevens@pursued-with.net
>Release:        FreeBSD 4.7-RELEASE i386
>Organization:
Sporadic
>Environment:
Duplicated in various x86 systems on both 4.7 and 5.0, probably others.
System: FreeBSD babelfish 4.7-RELEASE FreeBSD 4.7-RELEASE #0: Wed Oct 9 15:08:34 GMT 2002 root@builder.freebsdmall.com:/usr/obj/usr/src/sys/GENERIC i386


	
>Description:
	After changing a user's uid with the pw command, files owned by the original uid still
	show the previous username.  Running id -P on both the new and old uids reports the 
	same username, when the old uid should no longer even exist.  Running pwd_mkdb
	/etc/master.passwd manually resolves the errors.

	A suggestion from the freebsd-questions list when I posted this problem was:

	pw may be too smart for its own good.  I bet it calls "pwd_mkdb -u" to only 
	update a single user from /etc/passwd.  The problem is when the uid changes, 
	pwd_mkdb will insert a new record into /etc/pwd.sb and spwd.db, but it doesn't 
	know about the previous uid, so that stays in the db.

>How-To-Repeat:
    % sudo pw user add -n fred -u 1010 -m 
    % id -P fred
    fred:*:1010:1010::0:0:User &:/home/fred:/bin/sh
    % ls -lad /home/fred 
    drwxr-xr-x  2 fred  fred  512 Mar 26 08:01 /home/fred/
    % sudo pw user mod fred -u 1005
    % id -P fred 
    fred:*:1005:1010::0:0:User &:/home/fred:/bin/sh
    % ls -lad /home/fred 
    drwxr-xr-x  2 fred  fred  512 Mar 26 08:01 /home/fred/
    % id -P 1005
    fred:*:1005:1010::0:0:User &:/home/fred:/bin/sh
    % id -P 1010
    fred:*:1010:1010::0:0:User &:/home/fred:/bin/sh
    % sudo grep 1010 /etc/master.passwd 
    fred:*:1005:1010::0:0:User &:/home/fred:/bin/sh

However, running pwd_mkdb(8) seems to cure the problem very effectively:

    % sudo pwd_mkdb /etc/master.passwd 
    % id -P fred 
    fred:*:1005:1010::0:0:User &:/home/fred:/bin/sh
    % id -P 1005 
    fred:*:1005:1010::0:0:User &:/home/fred:/bin/sh
    % id -P 1010
    id: 1010: no such user
    % ls -lad /home/fred
    drwxr-xr-x  2 1010  fred  512 Mar 26 08:01 /home/fred/


>Fix:

	As mentioned, manually running pwd_mkdb seems to resolve the problem.
>Release-Note:
>Audit-Trail:
>Unformatted:



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