From 5c4475471b54db19b87ef805ea2f5761611769f7 Mon Sep 17 00:00:00 2001 From: "Leigh B. Stoller" <stoller@flux.utah.edu> Date: Wed, 21 Aug 2002 20:04:05 +0000 Subject: [PATCH] Some minor SFS related changes. --- tmcd/common/libsetup.pm | 137 +++++++++++++++++++++------------------- tmcd/libsetup.pm | 137 +++++++++++++++++++++------------------- 2 files changed, 146 insertions(+), 128 deletions(-) diff --git a/tmcd/common/libsetup.pm b/tmcd/common/libsetup.pm index 70bdb86ad7..5ce4e18251 100644 --- a/tmcd/common/libsetup.pm +++ b/tmcd/common/libsetup.pm @@ -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(); } diff --git a/tmcd/libsetup.pm b/tmcd/libsetup.pm index 70bdb86ad7..5ce4e18251 100644 --- a/tmcd/libsetup.pm +++ b/tmcd/libsetup.pm @@ -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(); } -- GitLab