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