From 324c7dcaed2cfa8824be9ae99a4e23db01510bb0 Mon Sep 17 00:00:00 2001 From: Austin Clements <aclement@flux.utah.edu> Date: Tue, 20 Aug 2002 22:05:59 +0000 Subject: [PATCH] Fixed error in doaccounts when SFS isn't running --- tmcd/common/libsetup.pm | 128 ++++++++++++++++++++-------------------- tmcd/libsetup.pm | 128 ++++++++++++++++++++-------------------- 2 files changed, 130 insertions(+), 126 deletions(-) diff --git a/tmcd/common/libsetup.pm b/tmcd/common/libsetup.pm index 163a73cae1..70bdb86ad7 100644 --- a/tmcd/common/libsetup.pm +++ b/tmcd/common/libsetup.pm @@ -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; } diff --git a/tmcd/libsetup.pm b/tmcd/libsetup.pm index 163a73cae1..70bdb86ad7 100644 --- a/tmcd/libsetup.pm +++ b/tmcd/libsetup.pm @@ -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; } -- GitLab