From d7b2a209e9e1f437bf5b97052551530e01e5ffcc Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Fri, 9 May 2008 13:27:44 +0000
Subject: [PATCH] Minor tweak to allow a "*" (star) password entry to be
 specified in the xml file.

---
 account/newuser.in | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/account/newuser.in b/account/newuser.in
index 4525fb6acf..2a0617495f 100644
--- a/account/newuser.in
+++ b/account/newuser.in
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -wT
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2000-2007 University of Utah and the Flux Group.
+# Copyright (c) 2000-2008 University of Utah and the Flux Group.
 # All rights reserved.
 #
 use English;
@@ -274,23 +274,29 @@ UserError("Email address already in use; please pick another!")
 # Check the password.
 #
 my $pswd = $xmlparse->{'attribute'}->{'password'}->{'value'};
-	
-my $checkpass_args = escapeshellarg($pswd);
-$checkpass_args   .= " " .
-    (exists($newuser_args{'uid'}) ? $newuser_args{'uid'} : "ignored");
-$checkpass_args   .= escapeshellarg($newuser_args{'usr_name'} . ":" .
-				    $newuser_args{'usr_email'});
+
+# Admins can "star" the password entry.
+if ($this_user->IsAdmin() && $pswd eq "*") {
+    $newuser_args{'usr_pswd'} = "*";
+}
+else {
+    my $checkpass_args = escapeshellarg($pswd);
+    $checkpass_args   .= " " .
+	(exists($newuser_args{'uid'}) ? $newuser_args{'uid'} : "ignored");
+    $checkpass_args   .= escapeshellarg($newuser_args{'usr_name'} . ":" .
+					$newuser_args{'usr_email'});
     
-my $pwokay = `$checkpass $checkpass_args`;
-if ($?) {
-    chomp($pwokay);
+    my $pwokay = `$checkpass $checkpass_args`;
+    if ($?) {
+	chomp($pwokay);
     
-    if (! ($pwokay =~ /^ok$/)) {
-	UserError("$pwokay");
+	if (! ($pwokay =~ /^ok$/)) {
+	    UserError("$pwokay");
+	}
+	fatal("Checkpass failed with $?");
     }
-    fatal("Checkpass failed with $?");
+    $newuser_args{'usr_pswd'} = crypt($pswd, "\$1\$" . substr(time(), 0, 8));
 }
-$newuser_args{'usr_pswd'} = crypt($pswd, "\$1\$" . substr(time(), 0, 8));
 
 #
 # Do a check on the pubkey if supplied. The safest thing to do is generate
-- 
GitLab