Commit 5c447547 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Some minor SFS related changes.

parent dcf2d13f
......@@ -162,6 +162,13 @@ sub MFS() { if (-e "$SETUPDIR/ismfs") { return 1; } else { return 0; } }
#
sub REMOTE() { if (-e "$SETUPDIR/isrem") { return 1; } else { return 0; } }
#
# Turn off SFS mode on RON nodes until the the code is fixed.
#
if (REMOTE() && ! -e "/etc/emulab.pkey") {
$USESFS = 0;
}
#
# Open a TMCC connection and return the "stream pointer". Caller is
# responsible for closing the stream and checking return value.
......@@ -460,12 +467,18 @@ sub domounts()
}
if (readlink($local) ne ("/sfs/" . $remote)) {
print STDOUT " Unlinking incorrect symlink $local\n";
if ( ! unlink($local)) {
if (! unlink($local)) {
warn "*** WARNING: Could not unlink $local: $!\n";
next;
}
}
}
elsif (-d $local) {
if (! rmdir($local)) {
warn "*** WARNING: Could not rmdir $local: $!\n";
next;
}
}
$dir = $local;
$dir =~ s/(.*)\/[^\/]*$/$1/;
......@@ -523,7 +536,7 @@ sub domounts()
}
else {
# There were no SFS mounts reported, so disable SFS
$usesfs = 0;
$USESFS = 0;
}
return 0;
......@@ -562,7 +575,7 @@ sub dosfshostid ()
}
}
else {
warn "*** WARNING: Could not retrieve this node's hostid (is sfssd running?)\n";
warn "*** WARNING: Could not retrieve this node's SFShostid!\n";
$USESFS = 0;
}
......@@ -1140,74 +1153,70 @@ sub doaccounts()
# Create sfs_users file and populate it with public SFS keys
#
if ($USESFS) {
do {
if (!open(SFSKEYS, "> /etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not open /etc/sfs/sfs_users.new: $!\n");
next;
}
my $sfsusers = "/etc/sfs/sfs_users";
if (!open(SFSKEYS, "> ${sfsusers}.new")) {
warn("*** WARNING: Could not open ${sfsusers}.new: $!\n");
goto bad;
}
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);
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;
}
# Because sfs_users only contains public keys, sfs_users.pub is
# exactly the same
if (system("cp -p -f ${sfsusers}.new ${sfsusers}.pub.new")) {
warn("*** WARNING Could not copy ${sfsusers}.new to ".
"${sfsusers}.pub.new: $!\n");
goto bad;
}
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, "${sfsusers}.new")) {
warn("*** WARNING: Could not chown ${sfsusers}.new: $!\n");
goto bad;
}
if (!chmod(0600, "${sfsusers}.new")) {
warn("*** WARNING: Could not chmod ${sfsusers}.new: $!\n");
goto bad;
}
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;
}
if (!chown(0, 0, "${sfsusers}.pub.new")) {
warn("*** WARNING: Could not chown ${sfsusers}.pub.new: $!\n");
goto bad;
}
if (!chmod(0644, "${sfsusers}.pub.new")) {
warn("*** WARNING: Could not chmod ${sfsusers}.pub.new: $!\n");
goto bad;
}
# 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");
}
# Save off old key files and move in new ones
foreach my $keyfile ("${sfsusers}", "${sfsusers}.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.old")) {
warn("*** Could not chown $keyfile.old: $!\n");
}
if (system("mv -f $keyfile.new $keyfile")) {
warn("*** Could not mv $keyfile: ~!\n");
if (!chmod(0600, "$keyfile.old")) {
warn("*** Could not chmod $keyfile.old: $!\n");
}
}
# The do-while is an easy way out in case of errors
if (system("mv -f $keyfile.new $keyfile")) {
warn("*** Could not mv $keyfile.new $keyfile.new: ~!\n");
}
}
while 0;
bad:
}
return 0;
......@@ -1667,7 +1676,7 @@ sub bootsetup()
#
# Setup SFS hostid.
#
print STDOUT "Creating node SFS hostid ... \n";
print STDOUT "Setting up for SFS ... \n";
dosfshostid();
}
......@@ -1770,7 +1779,7 @@ sub nodeupdate()
#
# Setup SFS hostid.
#
print STDOUT "Creating node SFS hostid ... \n";
print STDOUT "Setting up for SFS ... \n";
dosfshostid();
}
......
......@@ -162,6 +162,13 @@ sub MFS() { if (-e "$SETUPDIR/ismfs") { return 1; } else { return 0; } }
#
sub REMOTE() { if (-e "$SETUPDIR/isrem") { return 1; } else { return 0; } }
#
# Turn off SFS mode on RON nodes until the the code is fixed.
#
if (REMOTE() && ! -e "/etc/emulab.pkey") {
$USESFS = 0;
}
#
# Open a TMCC connection and return the "stream pointer". Caller is
# responsible for closing the stream and checking return value.
......@@ -460,12 +467,18 @@ sub domounts()
}
if (readlink($local) ne ("/sfs/" . $remote)) {
print STDOUT " Unlinking incorrect symlink $local\n";
if ( ! unlink($local)) {
if (! unlink($local)) {
warn "*** WARNING: Could not unlink $local: $!\n";
next;
}
}
}
elsif (-d $local) {
if (! rmdir($local)) {
warn "*** WARNING: Could not rmdir $local: $!\n";
next;
}
}
$dir = $local;
$dir =~ s/(.*)\/[^\/]*$/$1/;
......@@ -523,7 +536,7 @@ sub domounts()
}
else {
# There were no SFS mounts reported, so disable SFS
$usesfs = 0;
$USESFS = 0;
}
return 0;
......@@ -562,7 +575,7 @@ sub dosfshostid ()
}
}
else {
warn "*** WARNING: Could not retrieve this node's hostid (is sfssd running?)\n";
warn "*** WARNING: Could not retrieve this node's SFShostid!\n";
$USESFS = 0;
}
......@@ -1140,74 +1153,70 @@ sub doaccounts()
# Create sfs_users file and populate it with public SFS keys
#
if ($USESFS) {
do {
if (!open(SFSKEYS, "> /etc/sfs/sfs_users.new")) {
warn("*** WARNING: Could not open /etc/sfs/sfs_users.new: $!\n");
next;
}
my $sfsusers = "/etc/sfs/sfs_users";
if (!open(SFSKEYS, "> ${sfsusers}.new")) {
warn("*** WARNING: Could not open ${sfsusers}.new: $!\n");
goto bad;
}
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);
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;
}
# Because sfs_users only contains public keys, sfs_users.pub is
# exactly the same
if (system("cp -p -f ${sfsusers}.new ${sfsusers}.pub.new")) {
warn("*** WARNING Could not copy ${sfsusers}.new to ".
"${sfsusers}.pub.new: $!\n");
goto bad;
}
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, "${sfsusers}.new")) {
warn("*** WARNING: Could not chown ${sfsusers}.new: $!\n");
goto bad;
}
if (!chmod(0600, "${sfsusers}.new")) {
warn("*** WARNING: Could not chmod ${sfsusers}.new: $!\n");
goto bad;
}
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;
}
if (!chown(0, 0, "${sfsusers}.pub.new")) {
warn("*** WARNING: Could not chown ${sfsusers}.pub.new: $!\n");
goto bad;
}
if (!chmod(0644, "${sfsusers}.pub.new")) {
warn("*** WARNING: Could not chmod ${sfsusers}.pub.new: $!\n");
goto bad;
}
# 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");
}
# Save off old key files and move in new ones
foreach my $keyfile ("${sfsusers}", "${sfsusers}.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.old")) {
warn("*** Could not chown $keyfile.old: $!\n");
}
if (system("mv -f $keyfile.new $keyfile")) {
warn("*** Could not mv $keyfile: ~!\n");
if (!chmod(0600, "$keyfile.old")) {
warn("*** Could not chmod $keyfile.old: $!\n");
}
}
# The do-while is an easy way out in case of errors
if (system("mv -f $keyfile.new $keyfile")) {
warn("*** Could not mv $keyfile.new $keyfile.new: ~!\n");
}
}
while 0;
bad:
}
return 0;
......@@ -1667,7 +1676,7 @@ sub bootsetup()
#
# Setup SFS hostid.
#
print STDOUT "Creating node SFS hostid ... \n";
print STDOUT "Setting up for SFS ... \n";
dosfshostid();
}
......@@ -1770,7 +1779,7 @@ sub nodeupdate()
#
# Setup SFS hostid.
#
print STDOUT "Creating node SFS hostid ... \n";
print STDOUT "Setting up for SFS ... \n";
dosfshostid();
}
......
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