Commit 44f8bd49 authored by Russ Fish's avatar Russ Fish

Enable turning Windows file sharing between experiment nodes.

parent 90ba7732
......@@ -99,6 +99,7 @@ script-install: dir-install $(SCRIPTS)
$(INSTALL) -m 755 $(SRCDIR)/rc.firstboot $(BINDIR)/rc/rc.firstboot
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp $(BINDIR)/rc/rc.cygwin
$(INSTALL) -m 755 $(SRCDIR)/rc.reboot $(BINDIR)/rc/rc.reboot
$(INSTALL) -m 755 $(SRCDIR)/netbt $(BINDIR)/netbt
sfs-install:
......
#! /bin/bash
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# All rights reserved.
#
function usage () {
echo "Usage: netbt [-r] off|on"
exit
}
# The NetBT (Netbios over TCP) protocol is used to announce shared directories
# (folders) from one Windows machine to others. (See the Name and Session
# services in http://en.wikipedia.org/wiki/Netbios)
#
# The SMB (Server Message Block) protocol is used to actually serve
# files. (See http://en.wikipedia.org/wiki/Server_Message_Block)
#
# In Emulab, we normally disable NetBT on experiment nodes, because it
# chatters and messes up slothd network idle detection, and is not needed for
# the usual SMB mounts of /users, /proj, and /share dirs, which are served
# from a Samba service on "fs".
#
# However, NetBT *does* have to be enabled on the experiment nodes if you want
# to make Windows file shares between them. The netbt script sets the registry
# keys on the Windows interface objects. Run it on the server nodes (the ones
# containing directories which you want to share) and reboot them afterwards
# to activate. There is an optional -r argument to reboot the node.
#
# If you use netbt to turn on NetBT, it persists across reboots.
#
# No reboot is necessary if you use Network Connections in the Control Panel
# to turn on NetBT. It takes effect immediately, but is turned off at reboot.
# Right-click Local Area Connection (or the name of another connection, if
# appropriate), click Properties, click Internet Protocol (TCP/IP), and then
# click the Properties button. On the Internet Protocol (TCP/IP) Properties
# page, click the Advanced button, and click the WINS tab. Select Enable or
# Disable NetBIOS over TCP/IP.
#
# "ipconfig /all" reports "NetBIOS over Tcpip . . . : Disabled" on interfaces
# where NetBT is disabled, and says nothing where NetBT is enabled.
#
# To start sharing a directory, on the node, use the "net share" command, or
# turn on network sharing on the Sharing tab of the Properties of a directory
# (folder.) On XP-SP2 or above, when you first do this, the "Network sharing
# and security" subdialog says:
# As a security measure, Windows has disabled remote
# access to this computer. However, you can enable
# remote access and safely share files by running
# the _Network_Setup_Wizard_.
#
# _If_you_understand_the_security_risks_but_want_to_share_
# _files_without_running_the_wizard,_click_here._"
# Skip the wizard and click the latter link. Then click "Just enable file
# sharing", and "OK". Then you finally get the click-box to "Share this
# folder on the network".
#
# The machine names for UNC paths sharing are the same as in shell prompts:
# pcXXX, where XXX is the machine number. These will show up in My Network
# Places / Entire Network / Microsoft Windows Network / Emulab .
#
# IP addresses can also be used, giving you a way to share across experimental
# network links. LMHOSTS file lookup will be implemented soon, to provide the
# usual node aliases within an experiment.
ccs=/HKLM/SYSTEM/CurrentControlSet svcs=$ccs/Services cntl=$ccs/Control
nbtp=$svcs/NetBT/Parameters nbtif=$nbtp/Interfaces
if (( "$#" == 0 )); then
usage
fi
if (( "$#" >= 1 )); then
if [ "$1" == "-r" ]; then
reboot=1
shift
fi
fi
if (( "$#" > 1 )); then
usage
fi
# Set or unset a regkey to make it persistent.
if [ "$1" == "on" ]; then
able=1
regtool set -i $nbtp/EmulabOn 1
elif [ "$1" == "off" ]; then
able=2
regtool unset -q $nbtp/EmulabOn
else
usage
fi
for ifc in `regtool list $nbtif`; do
# Set the NetBT interface NetbiosOptions to Enable (1) or Disable (2.)
regtool set -i $nbtif/$ifc/NetbiosOptions $able
done
if [ $reboot ]; then /usr/local/etc/emulab/rc/rc.reboot; fi
......@@ -129,22 +129,24 @@ else
fi
# NetBT (Netbios over TCP) chatters, messes up slothd, and is not needed for
# SMB, so disable it. This doesn't take effect until TCP/IP is restarted, so
# do it before the computer name change below, which reboots the first time.
# SMB, so disable it by default. This doesn't take effect until TCP/IP is
# restarted, so do it before the computer name change below, which reboots the
# first time.
ccs=/HKLM/SYSTEM/CurrentControlSet svcs=$ccs/Services cntl=$ccs/Control
pi=Parameters/Interfaces nbtif=$svcs/NetBT/$pi
nbtp=$svcs/NetBT/Parameters nbtif=$nbtp/Interfaces
for ifc in `regtool list $nbtif`; do
# Set the NetBT interface NetbiosOptions to Disable (2.)
regtool set -i $nbtif/$ifc/NetbiosOptions 2
# Also turn off outgoing DNS registration traffic.
regtool set -i $nbtif/$ifc/DisableDynamicUpdate 1
# Set the NetBT interface NetbiosOptions to Disable (2) or Enable (1.)
if regtool get -q $nbtp/EmulabOn; then able=1; else able=2; fi
regtool set -i $nbtif/$ifc/NetbiosOptions $able
# Also turn off outgoing DNS registration traffic.
regtool set -i $nbtif/$ifc/DisableDynamicUpdate 1
done
# Turn off LMHOSTS lookup to make sure NetBT is not active.
# Sometimes we get errors like this trying to reboot below:
# Error 53 The network path was not found.
nbtp=$svcs/NetBT/Parameters
regtool set -i $nbtp/EnableLMHOSTS 0
# Enable LMHOSTS file lookup on the client side, in case the user runs "netbt"
# to turn NetBT back on again on a server node to share files between nodes.
# rc.lmhosts transforms the /etc/hosts file into a Windows lmhosts file.
regtool set -i $nbtp/EnableLMHOSTS 1
# Turn on IP forwarding if there is more than one experimental net interface.
# Also requires a reboot to take effect.
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
use Getopt::Std;
sub usage()
{
print "Usage: " .
scriptname() . " [-j vnodeid] boot|shutdown|reconfig|reset\n";
exit(1);
}
my $optlist = "j:";
my $action = "boot";
# Only root.
if ($EUID != 0) {
die("*** $0:\n".
" Must be root to run this script!\n");
}
# Turn off line buffering on output
$| = 1;
# Drag in path stuff so we can find emulab stuff.
BEGIN { require "/etc/emulab/paths.pm"; import emulabpaths; }
# Script specific goo
my $LMHOSTS = "/cygdrive/c/WINDOWS/system32/drivers/etc/lmhosts";
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use libsetup;
use liblocsetup;
use libtmcc;
use librc;
#
# Not all clients support this.
#
exit(0)
if (MFS() || (REMOTE() && !(PLAB() || JAILED())));
# Protos.
sub doboot();
sub doshutdown();
sub doreconfig();
sub docleanup();
# Parse command line.
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{'j'})) {
my $vnodeid = $options{'j'};
libsetup_setvnodeid($vnodeid);
}
# Allow default above.
if (@ARGV) {
$action = $ARGV[0];
}
# Execute the action.
SWITCH: for ($action) {
/^boot$/i && do {
doboot();
last SWITCH;
};
/^shutdown$/i && do {
doshutdown();
last SWITCH;
};
/^reconfig$/i && do {
doreconfig();
last SWITCH;
};
/^reset$/i && do {
docleanup();
last SWITCH;
};
fatal("Invalid action: $action\n");
}
exit(0);
#
# Boot Action.
#
sub doboot()
{
# This is only invoked on Windows XP, to generate an lmhosts file
# from the hosts file generated by rc.hostnames .
if (!open(HOSTS, $HOSTSFILE)) { # Path from liblocsetup.
warning("Could not read $HOSTSFILE: $!");
return -1;
}
if (!open(LMHOSTS, "> $LMHOSTS")) {
warning("Could not write $LMHOSTS: $!");
return -1;
}
print STDOUT "Generating lmhosts file from the hosts file ... \n";
while (<HOSTS>) {
print;
chomp;
my @hostsline = split;
my $ip = $hostsline[0];
shift @hostsline;
if ( $ip !~ /^127/ ) {
while ($#hostsline >= 0) { # Multiple aliases on the hosts line.
print LMHOSTS "$ip $hostsline[0] #PRE\r\n"; # Preload the WINS cache.
shift @hostsline;
}
}
}
close(HOSTS);
close(LMHOSTS);
return 0;
}
#
# Shutdown Action.
#
sub doshutdown()
{
# Nothing to do
}
#
# Node Reconfig Action (without rebooting).
#
sub doreconfig()
{
doshutdown();
return doboot();
}
#
# Node cleanup action (node is reset to completely clean state).
#
sub docleanup()
{
# Nothing to do
}
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