Commit c8cbdf70 authored by Leigh Stoller's avatar Leigh Stoller

Add LINUX_FSNODE support contributed by Maarten Dewispelaere at

intec.ugent.be

These are not complete changes, but enough to support the usage these
guys need. In this case, I think it is a hand crafted linux node that
allows boss to ssh in and do the exports setup stuff. But hey, it is a
start on actually supporting a linux FS node.
parent a8076871
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -48,6 +48,7 @@ my $DISABLED = "@DISABLE_EXPORTS_SETUP@";
my $WINSUPPORT = @WINSUPPORT@;
my $ISOLATEADMIN= @ISOLATEADMINS@;
my $NOSHAREDFS = @NOSHAREDFS@;
my $LINUX_FSNODE= @LINUX_FSNODE@;
# XXX for TESTMODE: output to stdout
my $TOSTDOUT = 0;
......@@ -63,7 +64,8 @@ my $smbconftail = "/var/tmp/smbconf.tail";
my @row;
# For determining file server mountpoints (XXX BSD specific)
my $MOUNTPROG = "/sbin/mount";
my $MOUNTPROG = ($LINUX_FSNODE ? "/bin/mount" : "/sbin/mount");
# Need the linux equiv for this.
my $EXPORT_PAT = q(on ([\S]+)\s\(.*NFS exported.*\));
#
......@@ -393,10 +395,16 @@ sub sortbyip {
foreach my $str ( keys(%ipgroups) ) {
my @iplist = sort sortbyip @{ $ipgroups{$str} };
print MAP "$str -maproot=root @iplist\n";
print "$str -maproot=root @iplist\n"
if ($debug);
if ($LINUX_FSNODE) {
print MAP "$str -rw,no_root_squash,no_subtree_check @iplist\n";
print "$str -rw,no_root_squash,no_subtree_check @iplist\n"
if ($debug);
}
else {
print MAP "$str -maproot=root @iplist\n";
print "$str -maproot=root @iplist\n"
if ($debug);
}
}
print MAP "\n";
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -25,6 +25,7 @@ getopts('S', \%opts);
# Configure variables
#
my $TBOPS = "@TBOPSEMAIL@";
my $LINUX_FSNODE= @LINUX_FSNODE@;
my $etcdir;
my $exports;
......@@ -37,7 +38,7 @@ my $daemon;
# Are we modifying the Samba config file or the NFS exports?
if (defined($opts{'S'})) {
$etcdir = "/usr/local/etc";
$etcdir = ($LINUX_FSNODE ? "/etc/samba" : "/usr/local/etc");
$exports = "$etcdir/smb.conf";
$exportsnew = "$etcdir/smb.conf.new";
$exportsback = "$etcdir/smb.conf.backup";
......@@ -55,6 +56,7 @@ else {
$exportstail = "$etcdir/exports.tail";
$pidfile = "/var/run/mountd.pid";
$daemon = "mountd";
$exportfs = ($LINUX_FSNODE ? "/usr/sbin/exportfs -ra" : undef);
}
my $dbg = 0;
......@@ -137,22 +139,36 @@ system("mv $exportsnew $exports") == 0 or
# Avoid accidental editing.
chmod(0444, $exports);
#
# I have little faith in HUPing mountd, but do it anyway.
#
my $daemonpid = `cat $pidfile`;
$daemonpid =~ s/\n//;
# untaint
if ($daemonpid =~ /^([-\@\w.]+)$/) {
$daemonpid = $1;
if (!$LINUX_FSNODE) {
#
# I have little faith in HUPing mountd, but do it anyway.
#
my $daemonpid = `cat $pidfile`;
$daemonpid =~ s/\n//;
# untaint
if ($daemonpid =~ /^([-\@\w.]+)$/) {
$daemonpid = $1;
}
if (kill('HUP', $daemonpid) == 0) {
fatal("Could not kill(HUP) process $daemonpid ($daemon): $!");
}
}
if (kill('HUP', $daemonpid) == 0) {
fatal("Could not kill(HUP) process $daemonpid ($daemon): $!");
else {
# Not supporting Samba at this time.
if (! defined($opts{'S'})) {
#
# run exportfs. linux handles exports changes much more gracefully
# then freebsd does.
#
system($exportfs) == 0 or
fatal("Could not run $exportfs\n");
}
}
#
# Allow time to react since HUP'ing mountd causes all mounts to briefly
# become invalid, and this causes problems for our scripts (and for users).
# In FreeBSD, must allow time to react since HUP'ing mountd causes all
# mounts to briefly become invalid, and this causes problems for our
# scripts (and for users). Not a problem in Linux.
#
sleep(1);
......
......@@ -2,7 +2,7 @@
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2009, 2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -21,12 +21,14 @@ sub usage()
}
sub fatal($;$);
sub chowner($$$);
#
# Configure variables
#
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
my $LINUX_FSNODE= @LINUX_FSNODE@;
#
# Turn off line buffering on output
......@@ -107,7 +109,7 @@ if (! chmod(0770, "$eid")) {
exit($exitval);
}
if (! chown($UID, $unix_gid, "$eid")) {
if (! chowner($UID, $unix_gid, "$eid")) {
$exitval = $ERRNO;
print "Could not chown $eid to $UID/$unix_gid in $expdir: $!\n";
rmdir($eid);
......@@ -148,7 +150,7 @@ if (! -e $workdir) {
if (! mkdir($workdir, 0775)) {
fatal("Could not create $workdir: $!");
}
if (! chown($UID, $unix_gid, "$workdir")) {
if (! chowner($UID, $unix_gid, "$workdir")) {
fatal("Could not chown $workdir to $UID/$unix_gid: $!");
}
}
......@@ -162,7 +164,7 @@ if (! -e $expinfo) {
if (! mkdir($expinfo, 0777)) {
fatal("Could not create $expinfo: $!");
}
if (! chown($UID, $unix_gid, "$expinfo")) {
if (! chowner($UID, $unix_gid, "$expinfo")) {
fatal("Could not chown $expinfo to $UID/$unix_gid: $!");
}
}
......@@ -198,3 +200,23 @@ sub fatal($;$)
exit($exitval);
}
sub chowner($$$)
{
my ($uid, $gid, $file) = @_;
if (0 && $LINUX_FSNODE) {
#
# use chgrp because linux NFS does not allow to chown !!
# set chgrp suid root -- only on boss !!!
#
# XXX I do not think this is the case for linux in general, so
# change the if expression above if you must.
#
system("/usr/bin/chgrp", $gid, $file);
return ($? ? 0 : 1);
}
else {
return chown($uid, $gid, $file);
}
}
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