From 185014d413de9c1d32c1fd8ff240de18f66a5e8d Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Thu, 5 May 2005 21:56:47 +0000
Subject: [PATCH] Change to how we get the password for elabman (firstuser).
 Instruct user to make sure root has a password, and just take the encrypted
 string from the password file. The elabman account is used for very little
 anyway.

Also install the rsync port if it is not present; this is a temp hack
until we figure out the package stuff.
---
 doc/setup.txt           |  6 +++++-
 install/boss-install.in | 24 ++++++++++++++++++++----
 install/ops-install.in  | 19 +++++++++++++++++++
 utils/firstuser.in      | 27 ++++++++++++++++++++-------
 4 files changed, 64 insertions(+), 12 deletions(-)

diff --git a/doc/setup.txt b/doc/setup.txt
index 434b4e54b4..84ebdd5c3e 100644
--- a/doc/setup.txt
+++ b/doc/setup.txt
@@ -79,7 +79,11 @@ to make sure that /usr is at least 8GB and at least a million inodes.
 If you want, you can go ahead and create an account for yourself on boss. For
 now, just stick the home directory somewhere local, and move it to /users/ once
 you've got it mounted from ops (the boss-install script will set this up). In
-general, it's probably simpler to just use 'root' for now.
+general, it's probably simpler to just use 'root' for now. BE SURE to
+give root a password and REMEMBER it! You are going to need it later.  To
+set the root password:
+
+	passwd root
 
 ##### Step 1 - Installing packages
 
diff --git a/install/boss-install.in b/install/boss-install.in
index 8e25a901f1..00cbf2066c 100644
--- a/install/boss-install.in
+++ b/install/boss-install.in
@@ -360,6 +360,25 @@ Phase "ports", "Installing ports", sub {
 	      "then re-run this script.");
 };
 
+# XXX Temporary.
+Phase "portfixup", "Fixing up packages", sub {
+    Phase "rsync", "Looking for rsync", sub {
+	if (!ExecQuiet("$PKG_INFO -x rsync")) {
+	    PhaseSkip("rsync already installed");
+	}
+
+	#
+	# This port is dead-simple, so it's safe to do it from this script
+	#
+ 	my $pwd = `$PWD`;
+	chomp $pwd;
+	chdir "$PORTSDIR/net/rsync" or
+ 	 	PhaseFail "Unable to change to $PORTSDIR/net/rsync: $!";
+	ExecQuietFatal("make -DBATCH install");
+	chdir $pwd;
+    };
+};
+
 Phase "patches", "Applying patches", sub {
     Phase "g++patch", "Patching g++'s STL", sub {
 	if (!ExecQuiet("$PATCH -C -f -R -p0 -i $STL_PATCH")) {
@@ -894,10 +913,7 @@ Phase "named", "Setting up initial named configuration", sub {
 Phase "firstuser", "Setting up initial user (elabman)", sub {
     PhaseSkip("elabman already created")
 	if (-d "/users/elabman");
-    PhaseSkip("Not needed unless in batch mode")
-	if (!$batchmode);
-    ExecQuietFatal("perl $TOP_OBJDIR/utils/firstuser ".
-		   ($batchmode ? " -b" : "") .
+    ExecQuietFatal("perl $TOP_OBJDIR/utils/firstuser -b ".
 		   (defined($password) ? " -p $password" : ""));
 };
 
diff --git a/install/ops-install.in b/install/ops-install.in
index 8de13678c1..6eb3909603 100644
--- a/install/ops-install.in
+++ b/install/ops-install.in
@@ -250,6 +250,25 @@ Phase "ports", "Installing ports", sub {
     };
 };
 
+# XXX Temporary.
+Phase "portfixup", "Fixing up packages", sub {
+    Phase "rsync", "Looking for rsync", sub {
+	if (!ExecQuiet("$PKG_INFO -x rsync")) {
+	    PhaseSkip("rsync already installed");
+	}
+
+	#
+	# This port is dead-simple, so it's safe to do it from this script
+	#
+ 	my $pwd = `$PWD`;
+	chomp $pwd;
+	chdir "$PORTSDIR/net/rsync" or
+ 	 	PhaseFail "Unable to change to $PORTSDIR/net/rsync: $!";
+	ExecQuietFatal("make -DBATCH install");
+	chdir $pwd;
+    };
+};
+
 Phase "patches", "Applying patches", sub {
     Phase "m2cryptopatch", "Patching m2crypto", sub {
         if (!ExecQuiet("$PATCH -C -f -l -R -p0 -i $M2CRYPTO_PATCH")) {
diff --git a/utils/firstuser.in b/utils/firstuser.in
index b696cd2b83..a9c24577d6 100755
--- a/utils/firstuser.in
+++ b/utils/firstuser.in
@@ -30,6 +30,7 @@ my $protoproj       = 'emulab-ops';
 my $protoproj_desc  = 'Operations Meta-Project';
 my $batchmode       = 0;
 my $password;
+my $encpass;
 my %opts;
 
 #
@@ -64,14 +65,26 @@ print "meta-project.\n\n";
 
 # Get a password for the user
 if (!defined($password)) {
-    print "Pick a password for $protouser (warning, will be echoed): ";
-    $password = <>;
-    chomp($password);
+    #
+    # In batch mode, we get it from the root user password entry.
+    # Otherwise prompt user for it.
+    #
+    if ($batchmode) {
+	(undef,$encpass) = getpwnam("root") or
+	    die("No root user!\n");
+    }
+    else {
+	print "Pick a password for $protouser (warning, will be echoed): ";
+	$password = <>;
+	chomp($password);
+    }
+}
+if (!defined($encpass)) {
+    my @salt_chars = ('a'..'z','A'..'Z','0'..'9');
+    my $salt = $salt_chars[rand(@salt_chars)] .
+	       $salt_chars[rand(@salt_chars)];
+    $encpass = crypt($password, "\$1\$${salt}");
 }
-my @salt_chars = ('a'..'z','A'..'Z','0'..'9');
-my $salt = $salt_chars[rand(@salt_chars)] .
-	   $salt_chars[rand(@salt_chars)];
-my $encpass = crypt($password, "\$1\$${salt}");
 
 # Get uid for the user and a gid for the project
 my $uid = 10000;
-- 
GitLab