Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-stable
Commits
337dd532
Commit
337dd532
authored
Dec 08, 2004
by
Russ Fish
Browse files
Enable networking and other rc scripts on CygWin.
parent
1ec51476
Changes
9
Hide whitespace changes
Inline
Side-by-side
tmcd/common/config/rc.config
View file @
337dd532
...
...
@@ -84,13 +84,13 @@ if (MFS()) {
"rc.rpms"
,
"rc.startcmd"
);
}
elsif
(
WINDOWS
()) {
@
bootscripts
= (
"rc.misc"
,
#"rc.localize",
@
bootscripts
= (
"rc.misc"
,
#
#"rc.localize",
"rc.keys"
,
"rc.mounts"
,
"rc.accounts"
##, "rc.topomap",
##
"rc.route", "rc.ifconfig",
##
"rc.hostnames", ##"rc.syncserver", "rc.progagent",
##
"rc.tarfiles", "rc.rpms",
##
"rc.startcmd"
"rc.route"
,
"rc.ifconfig"
,
"rc.hostnames"
,
##"rc.syncserver", "rc.progagent",
"rc.tarfiles"
,
"rc.rpms"
,
"rc.startcmd"
);
}
else
{
...
...
tmcd/common/config/rc.mounts
View file @
337dd532
...
...
@@ -171,7 +171,7 @@ sub doboot()
# server. All that's left is to wrap the //fs names in symlinks.
if
(
WINDOWS
())
{
while
((
$remote
,
$local
)
=
each
%mounts
)
{
my
$host
=
"
fs
";
my
$host
=
"
fs.bsd-fs.testbed.emulab.net
";
###
"fs";
print
"
Link
$local
to //
$host
\n
";
os_samba_mount
(
$local
,
$host
,
0
);
}
...
...
tmcd/common/rc.bootsetup
View file @
337dd532
...
...
@@ -118,8 +118,8 @@ sub doboot()
# Check for an os dependent initialization script.
#
my
$os_script
=
"
rc.
"
.
lc
(
$OSNAME
);
if
(
-
x
"
$RCDIR
/
$os_script
")
{
print
("
Running os dependent initialization script
$os_script
\n
");
system
("
$RCDIR
/
$os_script
");
if
(
$?
)
{
fatal
("
Error running
$RCDIR
/
$os_script
");
...
...
@@ -186,7 +186,7 @@ sub doboot()
}
}
if
(
-
x
"
$BINDIR
/watchdog
"
&&
!
WINDOWS
()
)
{
if
(
-
x
"
$BINDIR
/watchdog
")
{
print
("
Starting testbed update watchdog
\n
");
system
("
$BINDIR
/watchdog start
");
if
(
$?
)
{
...
...
tmcd/cygwinxp/GNUmakefile.in
View file @
337dd532
...
...
@@ -56,11 +56,16 @@ common-install: dir-install
sup-install: dir-install
SYSTEM32 = /cygdrive/c/Windows/System32
WBEM = $(SYSTEM32)/Wbem
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
$(INSTALL) -m 755 $(SRCDIR)/addusers.exe $(BINDIR)/usrtogrp.exe
# These are used by tmcd/findif.
$(INSTALL) -m 755 $(SYSTEM32)/getmac.exe $(BINDIR)/getmac.exe
$(INSTALL) -m 755 $(WBEM)/framedyn.dll $(BINDIR)/framedyn.dll
etc-install: dir-install sysetc-remove sysetc-install
...
...
@@ -71,7 +76,12 @@ sysetc-install: dir-install ###ifcfgs
-cp /etc/ssh_host_dsa_key /etc/ssh_host_dsa_key.user
-cp /etc/ssh_host_rsa_key /etc/ssh_host_rsa_key.user
chmod g-r /etc/ssh_host*key /etc/ssh_host*key.user
# Install an /etc/shells file.
# Watchdog assumes the ssh keys are in /etc/ssh.
ln -f -s /etc /etc/ssh
# Boot log files have to be writable by SYSTEM under rc.cygwin.
$(INSTALL) -c -m 775 -o root -g wheel -d /var/log
$(INSTALL) -c -m 775 -o root -g wheel -d /var/db
# Need an /etc/shells file for rc.acounts.
$(INSTALL) -m 755 $(SRCDIR)/shells /etc/shells
sysetc-remove:
...
...
@@ -81,12 +91,12 @@ script-install: dir-install $(SCRIPTS)
$(INSTALL) -m 755 $(SRCDIR)/liblocsetup.pm $(BINDIR)/liblocsetup.pm
$(INSTALL) -m 755 $(SRCDIR)/startsshd $(BINDIR)/startsshd
$(INSTALL) -m 755 $(SRCDIR)/stopsshd $(BINDIR)/stopsshd
-mkdir -m 755
/sbin
$(INSTALL) -c -m 755 -o root -g wheel -d
/sbin
$(INSTALL) -m 755 $(SRCDIR)/reboot /sbin/reboot
ln -f -s /bin/shutdown /sbin/shutdown
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp $(BINDIR)/rc/rc.cygwin
xp
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp $(BINDIR)/rc/rc.cygwin
# 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
-
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinxp-user $(BINDIR)/rc/rc.cygwinxp-user
sfs-install:
...
...
tmcd/cygwinxp/liblocsetup.pm
View file @
337dd532
...
...
@@ -13,7 +13,7 @@ use Exporter;
@ISA
=
"
Exporter
";
@EXPORT
=
qw (
$CP
$LN
$RM
$CHOWN
$EGREP
$NFSMOUNT
$UMOUNT
$SFCMOUNT
$SFCUMOUNT
$NTS
$NET
$NFSMOUNT
$UMOUNT
$SFCMOUNT
$SFCUMOUNT
$NTS
$NET
$HOSTSFILE
$TMPASSWD
$SFSSD
$SFSCD
$RPMCMD
os_account_cleanup
os_accounts_start
os_accounts_end
os_ifconfig_line
os_etchosts_line
...
...
@@ -71,14 +71,18 @@ $SFCUMOUNT = "$SFC/umount";
$NTS
=
"
/cygdrive/c/WINDOWS/system32
";
$NET
=
"
$NTS
/net
";
$NETSH
=
"
$NTS
/netsh
";
$NTE
=
"
$NTS
/drivers/etc
";
$HOSTSFILE
=
"
$NTE
/hosts
";
$BASH
=
"
/bin/bash
";
#
# These are not exported
#
my
$ADDUSERS
=
"
$BINDIR
/addusers.exe
";
my
$IFCONFIGBIN
=
"
/sbin/ifconfig
";
my
$IFCONFIG
=
"
$IFCONFIGBIN
%s inet %s net
mask
%s
";
my
$IFCONFIGBIN
=
"
$NETSH
interface ip set address
";
my
$IFCONFIG
=
"
$IFCONFIGBIN
name=
\"
%s
\"
source=static addr=%s
mask
=
%s
";
my
$IFC_1000MBS
=
"
1000baseTx
";
my
$IFC_100MBS
=
"
100baseTx
";
my
$IFC_10MBS
=
"
10baseT
";
...
...
@@ -132,192 +136,8 @@ sub os_ifconfig_line($$$$$$$;$$)
{
my
(
$iface
,
$inet
,
$mask
,
$speed
,
$duplex
,
$aliases
,
$iface_type
,
$settings
,
$rtabid
)
=
@_
;
my
(
$miirest
,
$miisleep
,
$miisetspd
,
$media
);
my
(
$uplines
,
$downlines
);
#
# Special handling for new style interfaces (which have settings).
# This should all move into per-type modules at some point.
#
if
(
defined
(
$settings
)
&&
exists
(
$settings
->
{"
protocol
"})
&&
$settings
->
{"
protocol
"}
ne
"
ethernet
")
{
#
# Setting the protocol is special and appears to be card specific.
# How stupid is that!
#
my
$protocol
=
$settings
->
{"
protocol
"};
my
$privcmd
=
"";
if
(
$iface_type
eq
"
ath
")
{
$privcmd
=
"
/sbin/iwpriv
$iface
mode
";
SWITCH1:
for
(
$protocol
)
{
/^80211a$/
&&
do
{
$privcmd
.=
"
1
";
last
SWITCH1
;
};
/^80211b$/
&&
do
{
$privcmd
.=
"
2
";
last
SWITCH1
;
};
/^80211g$/
&&
do
{
$privcmd
.=
"
3
";
last
SWITCH1
;
};
}
}
else
{
warn
("
*** WARNING: Unsupported interface type
$iface_type
!
\n
");
return
undef
;
}
#
# At the moment, we expect just the various flavors of 80211, and
# we treat them all the same, configuring with iwconfig and iwpriv.
#
my
$iwcmd
=
"
/sbin/iwconfig
$iface
";
#
# We demand to be given an ssid.
#
if
(
!
exists
(
$settings
->
{"
ssid
"}))
{
warn
("
*** WARNING: No SSID provided for
$iface
!
\n
");
return
undef
;
}
$iwcmd
.=
"
essid
"
.
$settings
->
{"
ssid
"};
# If we do not get a channel, pick one.
if
(
exists
(
$settings
->
{"
channel
"}))
{
$iwcmd
.=
"
channel
"
.
$settings
->
{"
channel
"};
}
else
{
$iwcmd
.=
"
channel 3
";
}
# txpower and rate default to auto if not specified.
if
(
exists
(
$settings
->
{"
rate
"}))
{
$iwcmd
.=
"
rate
"
.
$settings
->
{"
rate
"};
}
else
{
$iwcmd
.=
"
rate auto
";
}
if
(
exists
(
$settings
->
{"
txpower
"}))
{
$iwcmd
.=
"
txpower
"
.
$settings
->
{"
txpower
"};
}
else
{
$iwcmd
.=
"
txpower auto
";
}
# Allow this too.
if
(
exists
(
$settings
->
{"
sensitivity
"}))
{
$iwcmd
.=
"
sens
"
.
$settings
->
{"
sensitivity
"};
}
#
# We demand to be told if we are the master or a peon.
# This needs to be last for some reason.
#
if
(
!
exists
(
$settings
->
{"
accesspoint
"}))
{
warn
("
*** WARNING: No accesspoint provided for
$iface
!
\n
");
return
undef
;
}
my
$accesspoint
=
$settings
->
{"
accesspoint
"};
my
$accesspointwdots
;
# Allow either dotted or undotted notation!
if
(
$accesspoint
=~
/^(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})(\w{2})$/
)
{
$accesspointwdots
=
"
$1:$2:$3:$4:$5:$6
";
}
elsif
(
$accesspoint
=~
/^(\w{2}):(\w{2}):(\w{2}):(\w{2}):(\w{2}):(\w{2})$/
)
{
$accesspointwdots
=
$accesspoint
;
$accesspoint
=
"
${
1
}${
2
}${
3
}${
4
}${
5
}${
6
}
";
}
else
{
warn
("
*** WARNING: Improper format for MAC (
$accesspoint
)
"
.
"
provided for
$iface
!
\n
");
return
undef
;
}
if
(
libsetup::
findiface
(
$accesspoint
)
eq
$iface
)
{
$iwcmd
.=
"
mode Master
";
}
else
{
$iwcmd
.=
"
mode Managed ap
$accesspointwdots
";
}
$uplines
=
sprintf
(
$IFCONFIG
,
$iface
,
$inet
,
$mask
)
.
"
\n
";
$uplines
.=
$privcmd
.
"
\n
";
$uplines
.=
$iwcmd
;
$downlines
=
"
$IFCONFIGBIN
$iface
down
";
return
(
$uplines
,
$downlines
);
}
#
# Need to check units on the speed. Just in case.
#
if
(
$speed
=~
/(\d*)([A-Za-z]*)/
)
{
if
(
$
2
eq
"
Mbps
")
{
$speed
=
$
1
;
}
elsif
(
$
2
eq
"
Kbps
")
{
$speed
=
$
1
/
1000
;
}
else
{
warn
("
*** Bad speed units $2 in ifconfig, default to 100Mbps
\n
");
$speed
=
100
;
}
if
(
$speed
==
1000
)
{
$media
=
$IFC_1000MBS
;
}
elsif
(
$speed
==
100
)
{
$media
=
$IFC_100MBS
;
}
elsif
(
$speed
==
10
)
{
$media
=
$IFC_10MBS
;
}
else
{
warn
("
*** Bad Speed
$speed
in ifconfig, default to 100Mbps
\n
");
$speed
=
100
;
$media
=
$IFC_100MBS
;
}
}
if
(
$duplex
eq
"
full
")
{
$media
=
"
$media
-
$IFC_FDUPLEX
";
}
elsif
(
$duplex
eq
"
half
")
{
$media
=
"
$media
-
$IFC_HDUPLEX
";
}
else
{
warn
("
*** Bad duplex
$duplex
in ifconfig, default to full
\n
");
$duplex
=
"
full
";
$media
=
"
$media
-
$IFC_FDUPLEX
";
}
#
# Linux is apparently changing from mii-tool to ethtool but some drivers
# don't support the new interface (3c59x), some don't support the old
# interface (e1000), and some (eepro100) support the new interface just
# enough that they can report success but not actually do anything. Sweet!
#
my
$ethtool
;
if
(
-
e
"
/sbin/ethtool
")
{
$ethtool
=
"
/sbin/ethtool
";
}
elsif
(
-
e
"
/usr/sbin/ethtool
")
{
$ethtool
=
"
/usr/sbin/ethtool
";
}
if
(
defined
(
$ethtool
))
{
# this seems to work for returning an error on eepro100
$uplines
=
"
if
$ethtool
$iface
>/dev/null 2>&1; then
\n
"
.
"
$ethtool
-s
$iface
autoneg off speed
$speed
duplex
$duplex
\n
"
.
"
else
\n
"
.
"
/sbin/mii-tool --force=
$media
$iface
\n
"
.
"
fi
\n
";
}
else
{
$uplines
=
"
/sbin/mii-tool --force=
$media
$iface
\n
";
}
if
(
$inet
ne
"")
{
$uplines
.=
sprintf
(
$IFCONFIG
,
$iface
,
$inet
,
$mask
);
$downlines
=
"
$IFCONFIGBIN
$iface
down
";
...
...
@@ -342,7 +162,8 @@ sub os_etchosts_line($$$)
{
my
(
$name
,
$ip
,
$aliases
)
=
@_
;
return
sprintf
("
%s
\t
%s %s
",
$ip
,
$name
,
$aliases
);
# Note: space rather than tab after the host name on Windows.
return
sprintf
("
%s %s %s
",
$ip
,
$name
,
$aliases
);
}
#
...
...
tmcd/cygwinxp/rc.cygwinxp
View file @
337dd532
...
...
@@ -18,7 +18,8 @@ uname -r > $iscygwin
chmod
g+w
$iscygwin
chmod
-f
g-w /etc/emulab
# Set up for autologin as the swapin user.
# Set up for autologin as the swapin user after reboot.
# Also run rc.cygwinxp-user as part of all logins.
tmcc
=
/usr/local/etc/emulab/tmcc.bin
swapper
=
`
$tmcc
creator |
sed
's|.*SWAPPER=\([^ ]*\).*|\1|'
`
echo
"
`
date
`
: Set to autologin as
$swapper
."
>>
$logfile
...
...
@@ -26,18 +27,22 @@ alogdir=/var/emulab/boot
autologin
=
$alogdir
/autologin.reg
chmod
-f
g+w
$alogdir
rm
-f
$autologin
# Note the double-doubled backslashes below. Bash and regedit each eat a level.
cat
<<
EOF
>
$autologin
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE
\S
OFTWARE
\M
icrosoft
\W
indows NT
\C
urrentVersion
\W
inlogon]
"AutoAdminLogon"="1"
"DefaultUserName"="
$swapper
"
[HKEY_LOCAL_MACHINE
\S
OFTWARE
\M
icrosoft
\W
indows
\C
urrentVersion
\R
un]
"EmulabLogin"="C:
\\\\
cygwin
\\\\
bin
\\\\
bash /usr/local/etc/emulab/rc/rc.cygwinxp-user"
EOF
chmod
g+rw
$autologin
chmod
-f
g-w
$alogdir
winautologin
=
`
cygpath
-w
$autologin
`
if
!
regedit
-s
$winautologin
;
then
echo
"
`
date
`
: regedit -s
$winautologin
failed with code
$?
."
>>
$logfile
regedit
=
/cygdrive/c/WINDOWS/regedit
if
!
$regedit
-s
"
$winautologin
"
;
then
echo
"
`
date
`
:
$regedit
-s
$winautologin
failed with code
$?
."
>>
$logfile
fi
# Make sure the computer name is right, reboots to change it if necessary.
...
...
tmcd/cygwinxp/rc.cygwinxp-user
View file @
337dd532
...
...
@@ -20,7 +20,8 @@ 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, and it
# has to go onto a drive letter. After that, we can use UNC //host paths freely.
host
=
fs
###host=fs
host
=
fs.bsd-fs.testbed.emulab.net
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
...
...
tmcd/cygwinxp/startsshd
View file @
337dd532
...
...
@@ -51,6 +51,7 @@ chmod o-r /etc/ssh*key.user
echo
"Starting new sshd daemon as
$user
."
(
CYGWIN
=
"ntsec tty"
/usr/sbin/sshd
-p
2222
-o
"UsePrivilegeSeparation no"
\
-h
/etc/ssh_host_key.user
-h
/etc/ssh_host_dsa_key.user &
)
sleep
2
# Remember this one separately from the SYSTEM sshd.
chmod
-f
g+w
$upidfile
...
...
tmcd/findif.c
View file @
337dd532
...
...
@@ -223,7 +223,10 @@ find_iface(char *macaddr)
static
int
find_iface
(
char
*
macaddr
)
{
FILE
*
fp
=
popen
(
"getmac /nh /v /fo csv"
,
"r"
);
/* We copy the Windows getmac.exe and library framedyn.dll into $BINDIR
* because our path gets "untainted" into a pure Unix form in rc scripts.
*/
FILE
*
fp
=
popen
(
"bash -c 'cd $BINDIR; getmac /nh /v /fo csv'"
,
"r"
);
char
buf
[
BUFSIZ
];
while
(
fgets
(
buf
,
BUFSIZ
,
fp
)
!=
NULL
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment