Commit 2beb1824 authored by Mike Hibler's avatar Mike Hibler

Fix for local homedirs getting left as owned by root.

See emulab-devel issue 227 for details.

Also, on a "reset" clean out the correct BDB files. It has been
a long time since they used ".db" as the suffix. Now there are
".pag" and ".dir" files. We haven't noticed because we don't really
use the "reset" operation. The prepare script just removes
everything in /var/emulab/db.
parent f162f8bb
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2004-2010 University of Utah and the Flux Group. # Copyright (c) 2004-2017 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -411,11 +411,26 @@ sub doboot() ...@@ -411,11 +411,26 @@ sub doboot()
print "Adding: $login/$uid/$gid/$root/$name/$hdir/$glist\n"; print "Adding: $login/$uid/$gid/$root/$name/$hdir/$glist\n";
push(@addedUsers, $login); push(@addedUsers, $login);
if ($doit && if ($doit) {
os_useradd($login, $uid, $gid, $pswd, #
"$glist", $hdir, $name, $root, $shell)) { # XXX when "tmcc mount" returns FSTYPE=LOCAL, we may
warning("Error adding new user $login"); # have created homedirs in rc.mounts that will be
next; # owned by root (since there were no accounts at that
# time!). Fix up the owner/group here for those dirs.
# XXX we are very conservative so we don't accidentally
# change the ownership of a directory that we didn't
# create in rc.mounts.
#
if (-e $hdir && os_islocaldir($hdir) &&
(stat($hdir))[4] == 0 && -e "$hdir/.emulabcreated") {
unlink("$hdir/.emulabcreated");
chown($uid, $gid, $hdir);
}
if (os_useradd($login, $uid, $gid, $pswd,
"$glist", $hdir, $name, $root, $shell)) {
warning("Error adding new user $login");
next;
}
} }
if (PLAB() && ! -e $hdir) { if (PLAB() && ! -e $hdir) {
...@@ -676,19 +691,8 @@ sub docleanup() ...@@ -676,19 +691,8 @@ sub docleanup()
$retval = os_account_cleanup($updatemasterpasswdfiles); $retval = os_account_cleanup($updatemasterpasswdfiles);
} }
my $pdb = $PASSDB . ".db"; unlink("$PASSDB", "$PASSDB.db", "$PASSDB.dir", "$PASSDB.pag");
my $gdb = $GROUPDB . ".db"; unlink("$GROUPDB", "$GROUPDB.db", "$GROUPDB.dir", "$GROUPDB.pag");
# RHL9 sillyness; they do not append the .db suffix!
unlink $PASSDB
if (-e $PASSDB);
unlink $GROUPDB
if (-e $GROUPDB);
unlink $pdb
if (-e $pdb);
unlink $gdb
if (-e $gdb);
return $retval; return $retval;
} }
......
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# Copyright (c) 2004-2015 University of Utah and the Flux Group. # Copyright (c) 2004-2017 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -193,6 +193,16 @@ sub doboot() ...@@ -193,6 +193,16 @@ sub doboot()
warning("Could not make directory $local"); warning("Could not make directory $local");
next; next;
} }
#
# XXX if we make the directory, we tag it so that
# rc.accounts can fix up the owner/group later.
# This is a little bit paranoid, but we want to make
# sure that rc.accounts doesn't change the owner/group
# of an arbitrary directory if something gets out of sync.
#
if ($dolocaldirs) {
system("cp /dev/null $remote/.emulabcreated");
}
} }
if (!$dolocaldirs) { if (!$dolocaldirs) {
...@@ -253,8 +263,18 @@ sub doboot() ...@@ -253,8 +263,18 @@ sub doboot()
if ($localfsdir ne "/") { if ($localfsdir ne "/") {
$remote = "$localfsdir$local"; $remote = "$localfsdir$local";
} }
if (! -d "$remote" && !os_mkdir($remote, "0770")) { if (! -d "$remote") {
fatal("Could not make directory $remote: $!"); if (!os_mkdir($remote, "0770")) {
fatal("Could not make directory $remote: $!");
}
#
# XXX if we make the directory, we tag it so that
# rc.accounts can fix up the owner/group later.
# This is a little bit paranoid, but we want to make
# sure that rc.accounts doesn't change the owner/group
# of an arbitrary directory if something gets out of sync.
#
system("cp /dev/null $remote/.emulabcreated");
} }
# #
...@@ -548,13 +568,8 @@ sub doreconfig() ...@@ -548,13 +568,8 @@ sub doreconfig()
# #
sub docleanup() sub docleanup()
{ {
my $mdb = $MOUNTDB . ".db"; unlink("$MOUNTDB.db", "$MOUNTDB.dir", "$MOUNTDB.pag");
my $sdb = $SFSMOUNTDB . ".db"; unlink("$SFSMOUNTDB.db", "$SFSMOUNTDB.dir", "$SFSMOUNTDB.pag");
unlink $mdb
if (-e $mdb);
unlink $sdb
if (-e $sdb);
} }
# #
......
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