Commit 39af463c authored by Russ Fish's avatar Russ Fish

Second installment of cygwinxp support with remote mounted homedirs,

autologin of the swap-in user, and a user sshd on port 2222.
parent f30132c9
......@@ -83,6 +83,16 @@ if (MFS()) {
"rc.hostnames", "rc.keys", "rc.tarfiles",
"rc.rpms", "rc.startcmd");
}
elsif (WINDOWS()) {
@bootscripts = ("rc.misc", "rc.localize", "rc.keys",
# Do accounts first so we have passwords for Samba.
"rc.accounts","rc.mounts");
##"rc.topomap",
##"rc.route", "rc.tunnels", "rc.ifconfig", "rc.delays",
##"rc.hostnames", "rc.syncserver", "rc.trafgen",
##"rc.tarfiles", "rc.rpms", "rc.progagent", "rc.linkagent",
##"rc.startcmd", "rc.simulator");
}
else {
@bootscripts = ("rc.misc", "rc.localize", "rc.keys", "rc.mounts",
"rc.topomap", "rc.accounts",
......
......@@ -166,6 +166,18 @@ sub doboot()
return;
}
# On Cygwin, the Samba mount is set up per-user by rc.cygwinxp-user, and what is
# available through the mount is controlled by the smb.conf file on the file
# server. All that's left is to wrap the //fs names in symlinks.
if (WINDOWS()) {
while (($remote, $local) = each %mounts) {
my $host="fs";
print "Link $local to //$host\n";
os_samba_mount($local, $host, 0);
}
return;
}
dbmopen(%MDB, $MOUNTDB, 0660) or
fatal("Could not open $MOUNTDB");
......
......@@ -23,7 +23,7 @@ use Exporter;
TBDebugTimeStamp TBDebugTimeStampsOn
MFS REMOTE CONTROL JAILED PLAB LOCALROOTFS IXP USESFS
MFS REMOTE CONTROL WINDOWS JAILED PLAB LOCALROOTFS IXP USESFS
SIMTRAFGEN SIMHOST ISDELAYNODEPATH JAILHOST DELAYHOST
CONFDIR TMDELAY TMJAILNAME TMSIMRC TMCC
......@@ -255,6 +255,11 @@ sub REMOTE() { if (-e "$ETCDIR/isrem") { return 1; } else { return 0; } }
#
sub CONTROL() { if (-e "$ETCDIR/isctrl") { return 1; } else { return 0; } }
#
# Same for a Windows (CygWinXP) node.
#
sub WINDOWS() { if (-e "$ETCDIR/iscygwin") { return 1; } else { return 0; } }
#
# Are we jailed? See above.
#
......
......@@ -146,7 +146,7 @@ sub doboot()
}
}
if (-x "$BINDIR/tbshutdown") {
if (-x "$BINDIR/tbshutdown" && ! WINDOWS()) {
print("Starting up shutdown notification daemon\n");
system("$BINDIR/tbshutdown");
if ($?) {
......@@ -154,7 +154,7 @@ sub doboot()
}
}
if (-x "$RCDIR/rc.ipod") {
if (-x "$RCDIR/rc.ipod" && ! WINDOWS()) {
print("Setting up Ping of Death\n");
system("$RCDIR/rc.ipod");
# This is allowed to fail; ipod might not be supported.
......@@ -172,13 +172,13 @@ sub doboot()
#
# This stuff is run regardless of reservation status.
#
if (-x "$RCDIR/rc.healthd") {
if (-x "$RCDIR/rc.healthd" && ! WINDOWS()) {
print("Starting node health monitoring daemon\n");
system("$RCDIR/rc.healthd start");
# If it fails, that is okay. Keep going.
}
if (-x "$RCDIR/rc.slothd") {
if (-x "$RCDIR/rc.slothd" && ! WINDOWS()) {
print("Starting slothd usage detector\n");
system("$RCDIR/rc.slothd start");
if ($?) {
......@@ -186,7 +186,7 @@ sub doboot()
}
}
if (-x "$BINDIR/watchdog") {
if (-x "$BINDIR/watchdog" && ! WINDOWS()) {
print("Starting testbed update watchdog\n");
system("$BINDIR/watchdog start");
if ($?) {
......@@ -214,7 +214,7 @@ sub doboot()
#
# Start the elvin proxy.
#
if (-x "$BINDIR/evproxy") {
if (-x "$BINDIR/evproxy" && ! WINDOWS()) {
print("Starting elvin proxy daemon\n");
system("$BINDIR/evproxy -s event-server -e $pid/$eid");
if ($?) {
......@@ -236,7 +236,7 @@ sub doboot()
# Start the linktest daemon. This script will exit without running
# linktest is the node is hosting SIM or JAILS.
#
if (-x "$RCDIR/rc.linktest") {
if (-x "$RCDIR/rc.linktest" && ! WINDOWS()) {
system("$RCDIR/rc.linktest start");
if ($?) {
fatal("Error running $RCDIR/rc.linktest");
......
......@@ -57,6 +57,9 @@ common-install: dir-install
sup-install: dir-install
bin-install: dir-install
# These are found in the /share/windows directory.
$(INSTALL) -m 755 $(SRCDIR)/WSName.exe $(BINDIR)/WSName.exe
$(INSTALL) -m 755 $(SRCDIR)/addusers.exe $(BINDIR)/addusers.exe
etc-install: dir-install sysetc-remove sysetc-install
......@@ -65,13 +68,15 @@ sysetc-install: dir-install ###ifcfgs
sysetc-remove:
script-install: dir-install $(SCRIPTS)
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp-user $(BINDIR)/rc/rc.cygwinxp-user
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp $(BINDIR)/rc/rc.cygwinxp
$(INSTALL) -m 755 $(SRCDIR)/liblocsetup.pm $(BINDIR)/liblocsetup.pm
$(INSTALL) -m 755 $(SRCDIR)/emount $(BINDIR)/emount
$(INSTALL) -m 755 $(SRCDIR)/eumount $(BINDIR)/eumount
$(INSTALL) -m 755 $(SRCDIR)/startsshd $(BINDIR)/startsshd
$(INSTALL) -m 755 $(SRCDIR)/stopsshd $(BINDIR)/stopsshd
-mkdir -m 755 /sbin
$(INSTALL) -m 755 $(SRCDIR)/reboot /sbin/reboot
ln -f -s /bin/shutdown /sbin/shutdown
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp $(BINDIR)/rc/rc.cygwinxp
# The following will fail if the user login script is still busy in a shell.
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp-user $(BINDIR)/rc/rc.cygwinxp-user
sfs-install:
......
......@@ -20,7 +20,8 @@ use Exporter;
os_ifconfig_veth
os_routing_enable_forward os_routing_enable_gated
os_routing_add_manual os_routing_del_manual os_homedirdel
os_groupdel os_getnfsmounts os_getnfsmountpoints os_noisycmd
os_groupdel os_samba_mount
os_getnfsmounts os_getnfsmountpoints os_noisycmd
os_fwconfig_line os_fwrouteconfig_line
);
......@@ -44,7 +45,7 @@ BEGIN
}
#
# Various programs and things specific to Linux and that we want to export.
# Various programs and things specific to CygWin on XP and that we want to export.
#
$CP = "/bin/cp";
$LN = "/bin/ln";
......@@ -542,7 +543,47 @@ sub MapShell($)
return $fullpath;
}
# Extract the local mount point from a remote mount path.
sub os_samba_mount($$)
{
my ($local, $host, $verbose) = @_;
# Make the CygWin symlink from the local path to the driveletter automount point.
my $localdir = $sambapath = $local;
$localdir =~ s|(.*)/.*|$1|;
$sambapath =~ s|.*/(.*)|//$host/$1|;
if (length($localdir) && ! -e $localdir) {
print "os_samba_mount: Making CygWin '$localdir' directory for symlinks.\n"
if ($verbose);
if (! os_mkdir($localdir, "0777")) { # Writable so anybody can make symlinks.
print STDERR "os_samba_mount: Failed CygWin mkdir, $cmd.\n";
exit(1);
}
}
if (-e $local) {
print "Removing previous CygWin symlink '$local'.\n"
if ($verbose);
$cmd = "$CHOWN `id -un` $local";
if (system($cmd) != 0) {
print STDERR
"os_samba_mount: Failed to take ownership of symlink, $cmd.\n";
}
$cmd = "$RM -f $local";
if (system($cmd) != 0) {
print STDERR
"os_samba_mount: Failed to remove previous CygWin symlink, $cmd.\n";
exit(1);
}
}
print "Making CygWin symlink '$local' to '$sambapath'.\n"
if ($verbose);
$cmd = "$LN -f -s $sambapath $local";
if (system($cmd) != 0) {
print STDERR "os_samba_mount: Failed CygWin symlink, $cmd.\n";
exit(1);
}
}
# Extract the local mount point from a remote NFS mount path.
sub os_mountlocal($)
{
my ($remote) = @_;
......
......@@ -4,13 +4,37 @@
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
# CygWin startup. Run as a service named EmulabStartup.
# rc.cygwinxp - CygWin-specific startup. Run by rc.bootsetup on CygWin.
# Make sure the node name is right.
nodeid=`/usr/local/etc/emulab/tmcc.bin nodeid`
hostname=`/bin/hostname`
# Do some logging.
# Enable logging.
logfile=/var/log/EmulabStartup.log
chmod -f g+w $logfile
# Enable WINDOWS() in libsetup.pm .
iscygwin=/etc/emulab/iscygwin
chmod -f g+w $iscygwin
uname -r > $iscygwin
chmod g+w $iscygwin
# Set up for autologin as the swapin user.
tmcc=/usr/local/etc/emulab/tmcc.bin
swapper=`$tmcc creator | sed 's|.*SWAPPER=\([^ ]*\).*|\1|'`
echo "`date`: Set to autologin as $swapper." >> $logfile
autologin=/tmp/autologin.reg
rm -f $autologin
cat <<EOF > $autologin
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"AutoAdminLogon"="1"
"DefaultUserName"="$swapper"
EOF
chmod g+rw $autologin
regedit -s $autologin
# Make sure the computer name is right, reboots to change it if necessary.
nodeid=`$tmcc nodeid`
hostname=`/bin/hostname`
datehost="`date`: Host name '$hostname'"
if [ $nodeid == $hostname ]; then
echo "$datehost matches nodeid '$nodeid'." >> $logfile
......
......@@ -11,44 +11,37 @@
PATH=/usr/local/etc/emulab:$PATH
# Mounts are local to the Win32 login session context.
if [ -e /cygdrive/s ]; then /cygdrive/c/SFU/common/umount S: > /dev/null; fi
echo emount fs.emulab.net:/share /share
emount fs.emulab.net:/share /share
if [ -e /cygdrive/p ]; then /cygdrive/c/SFU/common/umount P: > /dev/null ; fi
proj=`tmcc.bin status | sed 's|ALLOCATED=\([^/]*\)/.*|\1|'`
echo emount fs.emulab.net:/q/proj/$proj /proj/$proj
emount fs.emulab.net:/q/proj/$proj /proj/$proj
# Where do we find out the group information for an optional Q: mount?
if [ -e /cygdrive/h ]; then /cygdrive/c/SFU/common/umount H: > /dev/null ; fi
creator=`tmcc.bin creator | sed 's|.*CREATOR=\([^ ]*\).*|\1|'`
echo emount fs.emulab.net:/users/$creator /users/$creator
emount fs.emulab.net:/users/$creator /users/$creator
if [ -e /cygdrive/i ]; then /cygdrive/c/SFU/common/umount I: > /dev/null ; fi
swapper=`tmcc.bin creator | sed 's|.*SWAPPER=\([^ ]*\).*|\1|'`
if [ $swapper != $creator ]; then
echo emount fs.emulab.net:/users/$swapper /users/$swapper
emount fs.emulab.net:/users/$swapper /users/$swapper
fi
# Make sure the user's homedir is mounted if neither creator nor swapper.
if [ -e /cygdrive/j ]; then /cygdrive/c/SFU/common/umount J: > /dev/null ; fi
# Root has a local home directory, and is handled by the SYSTEM sshd on port 22.
user=`id -un`
if [[ $user != $creator && $user != $swapper && $user != root ]]; then
echo emount -d J: fs.emulab.net:/users/$user /users/$user
emount -d J: fs.emulab.net:/users/$user /users/$user
if [ $user = root ]; then
exit 0
fi
# Shares are local to the Win32 login session context.
# We must process a user name and password for the first one to be opened.
###host=fs
host=pc88
pswd=`tmcc accounts | awk '/LOGIN='$user' /{print substr($0,index($0," PSWD=")+9,8)}'`
echo "Connecting to //$host as $user."
while ! net use Z: '\\'$host'\'$user "$pswd" /user:$user /persistent:no > /dev/null
do
read -p "Connection failed, try again? [y]: " -n 1 chr
echo ""
if [[ "$chr" != [yY] ]]; then break; fi
echo ""
echo "Re-trying Connection to //$host as $user."
done
# Set the homedir for ssh in case we don't get through rc.mounts .
ln -f -s //$host/$user /users/$user
# Run the SSH daemon in the Win32 login session context, so ssh client sessions
# will see the same set of mounts when they come in AS THIS SAME USER.
echo ""
startsshd
echo ""
echo "Hit <Enter> to dismiss this window."
echo "Hit <Enter> to stop the sshd when you're ready to log out."
read
stopsshd
#!/bin/bash
#
# EMULAB-COPYRIGHT
# Copyright (c) 2004 University of Utah and the Flux Group.
# All rights reserved.
#
# Installed as /sbin/reboot on CygWin, invoked with no arguments by Emulab.
#
# The CygWin /bin/reboot is a symlink to their shutdown.exe, not the Windows one.
# It requires a shutdown time argument. Give it one here.
#
# Supplying this also means we don't have to put the CygWin bin first on
# the Windows path with the possibility of causing other problems.
/bin/shutdown -r -f now
......@@ -32,14 +32,17 @@ if [ $running ]; then
kill $pid
fi
# Hijack the file permissions needed for sshd to run as this user.
# Set permissions on the key files needed for sshd to start up as this user.
# Can't steal permissions on the system ones, disables root@boss management via ssh.
# These copies were made as root after configuring sshd.
user=`id -un`
chown $user /etc/ssh*key
chmod o-r /etc/ssh*key
chown $user /var/empty
chmod go-w /var/empty
chown $user /etc/ssh*key.user
chmod o-r /etc/ssh*key.user
# Start sshd in the background, orphaned so it doesn't get SIGINT from here.
# The pidfile is updated by sshd itself.
# Don't use privilege separation, because it requires taking ownership of
# /var/empty, which kills key exchange for the SYSTEM root sshd.
echo "Starting new sshd daemon as $user."
(CYGWIN="ntsec tty" /usr/sbin/sshd &)
(CYGWIN="ntsec tty" /usr/sbin/sshd -p 2222 -o "UsePrivilegeSeparation no" \
-h /etc/ssh_host_key.user -h /etc/ssh_host_dsa_key.user &)
......@@ -20,10 +20,3 @@ if [ $running ]; then
ps -ef | awk '$2=='$pid'{print}'
kill $pid
fi
# Restore the file permissions needed for sshd to run as a service.
user=`id -un`
chown SYSTEM /etc/ssh*key
chmod o-r /etc/ssh*key
chown SYSTEM /var/empty
chmod go-w /var/empty
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