From land@squid.dnepr.net  Thu Feb  8 09:12:31 2001
Return-Path: <land@squid.dnepr.net>
Received: from squid.dnepr.net (squid.dnepr.net [195.24.156.115])
	by hub.freebsd.org (Postfix) with ESMTP id AAB1737B6E6
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  8 Feb 2001 09:12:27 -0800 (PST)
Received: (from land@localhost)
	by squid.dnepr.net (8.11.2/8.11.1) id f18HCIb01732;
	Thu, 8 Feb 2001 19:12:18 +0200 (EET)
	(envelope-from land)
Message-Id: <200102081712.f18HCIb01732@squid.dnepr.net>
Date: Thu, 8 Feb 2001 19:12:18 +0200 (EET)
From: land@dnepr.net
Reply-To: land@dnepr.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: adduser ignores passwd_format in login.conf
X-Send-Pr-Version: 3.2

>Number:         24953
>Category:       bin
>Synopsis:       adduser ignores passwd_format in login.conf
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    green
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 08 09:20:00 PST 2001
>Closed-Date:    Tue Jul 31 05:55:34 GMT 2007
>Last-Modified:  Tue Jul 31 05:55:34 GMT 2007
>Originator:     Andrey Lakhno
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
>Environment:


>Description:

	adduser ignores passwd_format in login.conf.
	User adds with DES password even if passwd_format=md5.

>How-To-Repeat:


>Fix:



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->green 
Responsible-Changed-By: kris 
Responsible-Changed-When: Tue Feb 20 03:20:02 PST 2001 
Responsible-Changed-Why:  
green added the passwd_format stuff 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24953 

From: Danny Howard <dannyman@tellme.com>
To: freebsd-gnats-submit@FreeBSD.org, land@dnepr.net
Cc:  
Subject: Re: bin/24953: adduser ignores passwd_format in login.conf
Date: Tue, 03 Apr 2001 22:10:08 -0400

 Some time back I wrote a script to replace adduser.  It does not have
 this bug, as it wraps itself around pw.  I wrote it to be easy to modify
 for site-specific installations, and have filed a PR so that it may be
 considered or adapted as a suitable replacement:
 
 http://www.FreeBSD.org/cgi/query-pr.cgi?pr=24439
 
 HTH,
 -dannyman

From: "Sergey N. Voronkov" <serg@tmn.ru>
To: freebsd-gnats-submit@FreeBSD.org
Cc: land@dnepr.net, green@FreeBSD.org
Subject: Re: bin/24953: adduser ignores passwd_format in login.conf
Date: Tue, 22 May 2001 18:02:44 +0600

 Here is a patch to adduser against FreeBSD-4 branch.
 It uses crypt magic feature of salt prefix to apply 
 md5/des encription and DB_File class to read /
 etc/login.conf.db.
 
 It isn't widely tested, but works for my own purposes.
 
 And, also, I like to use my favorite user management stuff 
 which works for a long time. Replacement is probably good
 but not the best think...
 
 Serg N. Voronkov.
 
 --- /usr/src/usr.sbin/adduser/adduser.perl	Sat Aug 28 07:15:11 1999
 +++ adduser.perl	Tue May 22 17:35:29 2001
 @@ -26,6 +26,7 @@
  #
  # $FreeBSD: src/usr.sbin/adduser/adduser.perl,v 1.44 1999/08/28 01:15:11 peter Exp $
  
 +use DB_File;
  
  # read variables
  sub variables {
 @@ -678,6 +679,7 @@
      local($userhome);
      local($groupmembers_bak, $cryptpwd);
      local($new_users_ok) = 1;
 +    local($salt_extended);
  
  
      $new_groups = "no";
 @@ -703,7 +705,10 @@
  	    $new_users_ok = 1;
  
  	    $cryptpwd = "";
 -	    $cryptpwd = crypt($password, &salt) if $password ne "";
 +            $salt_extended = &passwd_format_prefix($class);
 +            $salt_extended .= &salt;
 +		print "\n$salt_extended\n";
 +	    $cryptpwd = crypt($password, $salt_extended) if $password ne "";
  	    # obscure perl bug
  	    $new_entry = "$name\:" . "$cryptpwd" .
  		"\:$u_id\:$g_id\:$class\:0:0:$fullname:$userhome:$sh";
 @@ -775,6 +780,29 @@
  	$last = $e;
      }
      return @array;
 +}
 +
 +# determine and return salt prefix depended on login_class given
 +sub passwd_format_prefix {
 +    local($class) = shift;
 +    local(%hash,$k,$v);
 +    local($ret)="";
 +
 +    tie %hash, 'DB_File', "/etc/login.conf.db", O_RDONLY, 0644, $DB_HASH ||
 +        return "";
 +
 +    $class = "default" if($class eq "");
 +    while(($k,$v) = each %hash) {
 +        if($k eq $class){
 +             $v =~ /passwd_format=([a-z0-9]*):/;
 +             $ret=($1 eq "md5")? "\$1\$": "";
 +             last;
 +        }
 +    }
 +
 +    untie %hash;
 +
 +    return $ret;
  }
  
  # see /usr/src/usr.bin/passwd/local_passwd.c or librcypt, crypt(3)

From: Scott Lampert <scott@lampert.org>
To: freebsd-gnats-submit@FreeBSD.org, land@dnepr.net
Cc:  
Subject: Re: bin/24953: adduser ignores passwd_format in login.conf
Date: Mon, 22 Apr 2002 12:54:04 -0700

 As an alternative, this simple patch merely makes adduser use MD5 since 
 thats the default in FreeBSD now anyway.  This is only tested against 
 4.5-RELEASE, but it probably hasn't changed.
 
 --- adduser.perl.orig   Mon Apr 22 10:37:02 2002
 +++ adduser.perl        Mon Apr 22 10:37:26 2002
 @@ -790,9 +790,12 @@
  sub salt {
      local($salt);              # initialization
      local($i, $rand);
 -    local(@itoa64) = ( '0' .. '9', 'a' .. 'z', 'A' .. 'Z' ); # 0 .. 63
 +    local(@itoa64) = ( '.','/','0' .. '9', 'a' .. 'z', 'A' .. 'Z' ); # 
 0 .. 63
  
      warn "calculate salt\n" if $verbose > 1;
 +
 +    $salt = "\$1\$"; # Make it use MD5
 +
      # to64
      for ($i = 0; $i < 27; $i++) {
         srand(time + $rand + $$);
 

From: Mike Makonnen <mtm@identd.net>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/24953: adduser ignores passwd_format in login.conf
Date: Sat, 22 Feb 2003 18:39:17 -0500

 Brian,
 
 The new adduser.sh script wraps around pw(8) so this issue is no longer
 relevant. This PR is assigned to you, can you close it, please?
 
 Cheers.
 -- 
 Mike Makonnen  | GPG-KEY: http://www.identd.net/~mtm/mtm.asc
 mtm@identd.net | Fingerprint: D228 1A6F C64E 120A A1C9  A3AA DAE1 E2AF DBCC 68B9
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Tue Jul 31 05:54:36 UTC 2007 
State-Changed-Why:  
mtm@ reported some time ago that this had been fixed, so closed, with 
hat: bugmeister. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24953 
>Unformatted:
