Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jan 2000 17:14:26 -0500 (EST)
From:      Ben Rosengart <ben@skunk.org>
To:        hackers@freebsd.org
Subject:   locked accounts and adduser
Message-ID:  <Pine.BSF.4.21.0001181706100.64214-200000@penelope.skunk.org>

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

[-- Attachment #1 --]
I thought it would be nice if one could create locked accounts with
adduser.  So I asked my nice Perl-hacking coworker Evan Leon to come up
with a patch.

Enter password []: 
Use an empty password or lock the password? lock no [yes]: lock

...

# grep user /etc/master.passwd 
user:*:1001:1001::0:0:Joe User:/home/user:/bin/sh

The patch is attached.  Anyone like it?  Any chance it could be
committed?  I find it useful in two situations:

1) Sometimes I want to install someone's public key instead of giving
   them a password.  That way, I don't need a secure channel over which
   to communicate the password.
2) Other times, I'm going to be pasting a hashed password directly into
   the master.passwd file, and this is a convenient way of locking the
   account until I do that.

Another idea I have is to allow adduser to accept a hashed password
instead of a plaintext one.  Perhaps if this goes over well, Evan and I
will work on that next.

--
 Ben Rosengart

UNIX Systems Engineer, Skunk Group
StarMedia Network, Inc.


[-- Attachment #2 --]
--- /usr/sbin/adduser	Thu Jan 13 12:20:38 2000
+++ adduser	Tue Jan 18 16:57:05 2000
@@ -649,13 +649,17 @@
 	    last if $password eq $newpass;
 	    print "They didn't match, please try again\n";
 	}
-	elsif (&confirm_yn("Use an empty password?", "yes")) {
-	    last;
-	}
+        else {
+           $lockpass = &confirm_list("Use an empty password or lock the password?", 0, "yes", "no", "lock");
+           if ($lockpass ne "no") {
+            last;
+           }
+        }
+    }  
+    if ($lockpass == "lock") {
+      $password = "*"; 
     }
-
-    return $password;
-}
+}   
 
 
 sub new_users {
@@ -703,7 +707,12 @@
 	    $new_users_ok = 1;
 
 	    $cryptpwd = "";
-	    $cryptpwd = crypt($password, &salt) if $password ne "";
+            if ($passwd == "*") {
+              $cryptpwd = "*";
+            } 
+            else {
+              $cryptpwd = crypt($password, &salt) if $password ne "";
+            }
 	    # obscure perl bug
 	    $new_entry = "$name\:" . "$cryptpwd" .
 		"\:$u_id\:$g_id\:$class\:0:0:$fullname:$userhome:$sh";
@@ -1392,3 +1401,5 @@
 &new_users;	     # add new users
 
 #end
+
+

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0001181706100.64214-200000>