Commit 324c7dca authored by Austin Clements's avatar Austin Clements

Fixed error in doaccounts when SFS isn't running

parent dfc05da2
......@@ -1139,74 +1139,76 @@ sub doaccounts()
#
# Create sfs_users file and populate it with public SFS keys
#
do {
if (!open(SFSKEYS, "> /etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not open /etc/sfs/sfs_users.new: $!\n");
next;
}
print SFSKEYS "#\n";
print SFSKEYS "# DO NOT EDIT! This file auto generated by ".
"Emulab.Net account software.\n";
print SFSKEYS "#\n";
print SFSKEYS "# Please use the web interface to edit your ".
"SFS public key list.\n";
print SFSKEYS "#\n";
foreach my $key (@sfskeys) {
print SFSKEYS "$key\n";
}
close(SFSKEYS);
# Because sfs_users only contains public keys, sfs_users.pub is
# exactly the same
if (system("cp -p -f /etc/sfs/sfs_users.new ".
"/etc/sfs/sfs_users.pub.new")) {
warn("*** Could not copy /etc/sfs/sfs_users.new to ".
"sfs_users.pub.new: $!\n");
next;
}
if (!chown(0, 0, "/etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not chown /etc/sfs/sfs_users.new: $!\n");
next;
}
if (!chmod(0600, "/etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not chmod /etc/sfs/sfs_users.new: $!\n");
next;
}
if (!chown(0, 0, "/etc/sfs/sfs_users.pub.new")) {
warn("*** WARNING: Could not chown /etc/sfs/sfs_users.pub.new: $!\n");
next;
}
if (!chmod(0644, "/etc/sfs/sfs_users.pub.new")) {
warn("*** WARNING: Could not chmod /etc/sfs/sfs_users.pub.new: $!\n");
next;
}
# Save off old key files and move in new ones
foreach my $keyfile ("/etc/sfs/sfs_users",
"/etc/sfs/sfs_users.pub") {
if (-e $keyfile) {
if (system("cp -p -f $keyfile $keyfile.old")) {
warn("*** Could not save off $keyfile: $!\n");
next;
}
if (!chown(0, 0, "$keyfile")) {
warn("*** Could not chown $keyfile: $!\n");
if ($USESFS) {
do {
if (!open(SFSKEYS, "> /etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not open /etc/sfs/sfs_users.new: $!\n");
next;
}
print SFSKEYS "#\n";
print SFSKEYS "# DO NOT EDIT! This file auto generated by ".
"Emulab.Net account software.\n";
print SFSKEYS "#\n";
print SFSKEYS "# Please use the web interface to edit your ".
"SFS public key list.\n";
print SFSKEYS "#\n";
foreach my $key (@sfskeys) {
print SFSKEYS "$key\n";
}
close(SFSKEYS);
# Because sfs_users only contains public keys, sfs_users.pub is
# exactly the same
if (system("cp -p -f /etc/sfs/sfs_users.new ".
"/etc/sfs/sfs_users.pub.new")) {
warn("*** Could not copy /etc/sfs/sfs_users.new to ".
"sfs_users.pub.new: $!\n");
next;
}
if (!chown(0, 0, "/etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not chown /etc/sfs/sfs_users.new: $!\n");
next;
}
if (!chmod(0600, "/etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not chmod /etc/sfs/sfs_users.new: $!\n");
next;
}
if (!chown(0, 0, "/etc/sfs/sfs_users.pub.new")) {
warn("*** WARNING: Could not chown /etc/sfs/sfs_users.pub.new: $!\n");
next;
}
if (!chmod(0644, "/etc/sfs/sfs_users.pub.new")) {
warn("*** WARNING: Could not chmod /etc/sfs/sfs_users.pub.new: $!\n");
next;
}
# Save off old key files and move in new ones
foreach my $keyfile ("/etc/sfs/sfs_users",
"/etc/sfs/sfs_users.pub") {
if (-e $keyfile) {
if (system("cp -p -f $keyfile $keyfile.old")) {
warn("*** Could not save off $keyfile: $!\n");
next;
}
if (!chown(0, 0, "$keyfile")) {
warn("*** Could not chown $keyfile: $!\n");
}
if (!chmod(0600, "$keyfile")) {
warn("*** Could not chmod $keyfile: $!\n");
}
}
if (!chmod(0600, "$keyfile")) {
warn("*** Could not chmod $keyfile: $!\n");
if (system("mv -f $keyfile.new $keyfile")) {
warn("*** Could not mv $keyfile: ~!\n");
}
}
if (system("mv -f $keyfile.new $keyfile")) {
warn("*** Could not mv $keyfile: ~!\n");
}
# The do-while is an easy way out in case of errors
}
# The do-while is an easy way out in case of errors
while 0;
}
while 0;
return 0;
}
......
......@@ -1139,74 +1139,76 @@ sub doaccounts()
#
# Create sfs_users file and populate it with public SFS keys
#
do {
if (!open(SFSKEYS, "> /etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not open /etc/sfs/sfs_users.new: $!\n");
next;
}
print SFSKEYS "#\n";
print SFSKEYS "# DO NOT EDIT! This file auto generated by ".
"Emulab.Net account software.\n";
print SFSKEYS "#\n";
print SFSKEYS "# Please use the web interface to edit your ".
"SFS public key list.\n";
print SFSKEYS "#\n";
foreach my $key (@sfskeys) {
print SFSKEYS "$key\n";
}
close(SFSKEYS);
# Because sfs_users only contains public keys, sfs_users.pub is
# exactly the same
if (system("cp -p -f /etc/sfs/sfs_users.new ".
"/etc/sfs/sfs_users.pub.new")) {
warn("*** Could not copy /etc/sfs/sfs_users.new to ".
"sfs_users.pub.new: $!\n");
next;
}
if (!chown(0, 0, "/etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not chown /etc/sfs/sfs_users.new: $!\n");
next;
}
if (!chmod(0600, "/etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not chmod /etc/sfs/sfs_users.new: $!\n");
next;
}
if (!chown(0, 0, "/etc/sfs/sfs_users.pub.new")) {
warn("*** WARNING: Could not chown /etc/sfs/sfs_users.pub.new: $!\n");
next;
}
if (!chmod(0644, "/etc/sfs/sfs_users.pub.new")) {
warn("*** WARNING: Could not chmod /etc/sfs/sfs_users.pub.new: $!\n");
next;
}
# Save off old key files and move in new ones
foreach my $keyfile ("/etc/sfs/sfs_users",
"/etc/sfs/sfs_users.pub") {
if (-e $keyfile) {
if (system("cp -p -f $keyfile $keyfile.old")) {
warn("*** Could not save off $keyfile: $!\n");
next;
}
if (!chown(0, 0, "$keyfile")) {
warn("*** Could not chown $keyfile: $!\n");
if ($USESFS) {
do {
if (!open(SFSKEYS, "> /etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not open /etc/sfs/sfs_users.new: $!\n");
next;
}
print SFSKEYS "#\n";
print SFSKEYS "# DO NOT EDIT! This file auto generated by ".
"Emulab.Net account software.\n";
print SFSKEYS "#\n";
print SFSKEYS "# Please use the web interface to edit your ".
"SFS public key list.\n";
print SFSKEYS "#\n";
foreach my $key (@sfskeys) {
print SFSKEYS "$key\n";
}
close(SFSKEYS);
# Because sfs_users only contains public keys, sfs_users.pub is
# exactly the same
if (system("cp -p -f /etc/sfs/sfs_users.new ".
"/etc/sfs/sfs_users.pub.new")) {
warn("*** Could not copy /etc/sfs/sfs_users.new to ".
"sfs_users.pub.new: $!\n");
next;
}
if (!chown(0, 0, "/etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not chown /etc/sfs/sfs_users.new: $!\n");
next;
}
if (!chmod(0600, "/etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not chmod /etc/sfs/sfs_users.new: $!\n");
next;
}
if (!chown(0, 0, "/etc/sfs/sfs_users.pub.new")) {
warn("*** WARNING: Could not chown /etc/sfs/sfs_users.pub.new: $!\n");
next;
}
if (!chmod(0644, "/etc/sfs/sfs_users.pub.new")) {
warn("*** WARNING: Could not chmod /etc/sfs/sfs_users.pub.new: $!\n");
next;
}
# Save off old key files and move in new ones
foreach my $keyfile ("/etc/sfs/sfs_users",
"/etc/sfs/sfs_users.pub") {
if (-e $keyfile) {
if (system("cp -p -f $keyfile $keyfile.old")) {
warn("*** Could not save off $keyfile: $!\n");
next;
}
if (!chown(0, 0, "$keyfile")) {
warn("*** Could not chown $keyfile: $!\n");
}
if (!chmod(0600, "$keyfile")) {
warn("*** Could not chmod $keyfile: $!\n");
}
}
if (!chmod(0600, "$keyfile")) {
warn("*** Could not chmod $keyfile: $!\n");
if (system("mv -f $keyfile.new $keyfile")) {
warn("*** Could not mv $keyfile: ~!\n");
}
}
if (system("mv -f $keyfile.new $keyfile")) {
warn("*** Could not mv $keyfile: ~!\n");
}
# The do-while is an easy way out in case of errors
}
# The do-while is an easy way out in case of errors
while 0;
}
while 0;
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment