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.

--- /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
+
+

Reply via email to