From nobody@FreeBSD.ORG  Tue Aug  8 13:59:09 2000
Return-Path: <nobody@FreeBSD.ORG>
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id BD8CC37BD09; Tue,  8 Aug 2000 13:59:09 -0700 (PDT)
Message-Id: <20000808205909.BD8CC37BD09@hub.freebsd.org>
Date: Tue,  8 Aug 2000 13:59:09 -0700 (PDT)
From: celeste.copeland@usi.net
Sender: nobody@FreeBSD.ORG
To: freebsd-gnats-submit@FreeBSD.org
Subject: pw problems: -w random not working correctly for useradd and usermod
X-Send-Pr-Version: www-1.0

>Number:         20489
>Category:       bin
>Synopsis:       pw problems: -w random not working correctly for useradd and usermod
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    davidn
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 08 14:00:01 PDT 2000
>Closed-Date:    Thu Nov 15 11:53:23 PST 2001
>Last-Modified:  Thu Nov 15 11:54:49 PST 2001
>Originator:     Celeste Copeland
>Release:        4.0
>Organization:
USinternetworking, Inc.
>Environment:
FreeBSD spongebob.usi.net 4.0-RELEASE FreeBSD 4.0-RELEASE #0: Mon Mar 20 22:50:22 GMT 2000     root@monster.cdrom.com:/usr/src/sys/compile/GENERIC  i386
>Description:
The section of code dealing with generating random passwords (-w option) appears to be in the wrong place in the code.  The fix for the -w problem (which Jonathan Bresler and myself came up with) is below.  I am working on a fix for the -m issue.  We need pw fixed for a contract which BSDi has with our company.  Jordan Hubbard (jkh@freebsd.org) is the engineer for this project. 
>How-To-Repeat:
/usr/sbin/pw useradd test1 -c "Test User 1" -d /home/test1 -m -s /bin/sh -w random
/usr/sbin/pw usermod test1 -w random
Does not generate a random password.
>Fix:
# diff pw_user.c.orig pw_user.c
269a270
> /*  CEC/jmb  
272a274
> */
292a295,301
>         /*  CEC/jmb */
>         if ((mode == M_ADD || mode == M_UPDATE) && (arg = getarg(args, 'w')) != NULL) {  
>                 cnf->default_password = boolean_val(arg->val, cnf->default_password);
>         }
> 
> 
> 
583a593,599
> 
>       /* CEC/jmb */
>       if ( mode==M_UPDATE && (arg = getarg(args, 'w')) != NULL && getarg(args, 'h') == NULL) {  
>               pwd->pw_passwd = pw_password(cnf, args, pwd->pw_name);
>               edited = 1;
>       }


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->davidn 
Responsible-Changed-By: sheldonh 
Responsible-Changed-When: Thu Aug 10 02:39:32 PDT 2000 
Responsible-Changed-Why:  
Over to the maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=20489 
State-Changed-From-To: open->closed 
State-Changed-By: asmodai 
State-Changed-When: Thu Nov 15 11:53:23 PST 2001 
State-Changed-Why:  
My 4.4-STABLE box disagrees happily: 

[20:54] [root@purgatory] (3) {0} # /usr/sbin/pw usermod posix -w random      
Password for 'posix' is: LdmRa3fcUzw3lap 
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (4) {0} # /usr/sbin/pw usermod posix -w random 
Password for 'posix' is: 1PBCjiJ6Rld7MF 
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (5) {0} # /usr/sbin/pw usermod posix -w random 
Password for 'posix' is: vi5cLv0zt8 
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (6) {0} # /usr/sbin/pw usermod posix -w random 
Password for 'posix' is: UsL3mXqE4 
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (7) {0} # /usr/sbin/pw usermod posix -w random 
Password for 'posix' is: RDk4f0Y3JRS4fP 
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (8) {0} #  
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (8) {0} # /usr/sbin/pw usermod posix -w random 
Password for 'posix' is: aTss02zxUXzgJ4v 
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (9) {0} # /usr/sbin/pw usermod posix -w random 
Password for 'posix' is: lQokDoJyOq.tB5 
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (10) {0} # /usr/sbin/pw usermod posix -w random 
Password for 'posix' is: Mb7NsUDDPEb 
(/home/asmodai/work/FreeBSD/smpng) 
[20:54] [root@purgatory] (11) {0} # /usr/sbin/pw usermod posix -w random 
Password for 'posix' is: 0jhLwLUTDU9r8 

Seems random enough for me. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=20489 
>Unformatted:
