Commit 7c162ce4 authored by Kirk Webb's avatar Kirk Webb

Merge branch 'win7devel'

parents a0bb7954 7a3d7967
......@@ -3,7 +3,7 @@ VERSION export-subst
# that require them should be added to the list below.
clientside/sensors/slothd/idlemon.vbs -crlf
clientside/tmcc/cygwinseven/SetupComplete.cmd -crlf
clientside/tmcc/cygwinseven/unattend-x86.xml -crlf
clientside/tmcc/cygwinseven/unattend-x86.xml.in -crlf
clientside/tmcc/cygwinxp/cygwin-tcsh.bat -crlf
clientside/tmcc/cygwinxp/resolv.conf -crlf
clientside/tmcc/cygwinxp/site-lisp/cygwin-mount.el -crlf
......
......@@ -723,6 +723,10 @@ LOG_TESTBED
TBLOGFACIL
OUTERBOSS_NODENAME
WINSUPPORT
WINDOWS_ORGNAME
WINDOWS_OWNER
WINDOWS_TIMEZONE
WINDOWS_KEY_7PRO_X86
PYTHON
GREP
EGREP
......@@ -733,8 +737,8 @@ LTLIBOBJS'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_windows
with_TBDEFS
enable_windows
enable_elvin_compat
enable_TPM
'
......@@ -4191,6 +4195,14 @@ _ACEOF
OUTERBOSS_NODENAME=""
WINSUPPORT=0
#
# Variables for Windows Unattended setup files.
#
#
# Allow tbdefs file that is supplied to full emulab build
#
......@@ -4929,6 +4941,7 @@ outfiles="Makeconf GNUmakefile setversion \
tmcc/freebsd9/GNUmakefile tmcc/freebsd9/netif-emulab \
tmcc/freebsd10/GNUmakefile tmcc/freebsd10/netif-emulab \
tmcc/cygwinxp/GNUmakefile tmcc/dp/GNUmakefile \
tmcc/cygwinseven/GNUmakefile tmcc/cygwinseven/unattend-x86.xml \
tmcc/openbsd/GNUmakefile tmcc/ron/GNUmakefile \
tmcc/plab/GNUmakefile tmcc/cygwinseven/GNUmakefile \
os/GNUmakefile os/syncd/GNUmakefile \
......
......@@ -122,6 +122,14 @@ AC_SUBST(WINSUPPORT)
OUTERBOSS_NODENAME=""
WINSUPPORT=0
#
# Variables for Windows Unattended setup files.
#
AC_SUBST(WINDOWS_ORGNAME)
AC_SUBST(WINDOWS_OWNER)
AC_SUBST(WINDOWS_TIMEZONE)
AC_SUBST(WINDOWS_KEY_7PRO_X86)
#
# Allow tbdefs file that is supplied to full emulab build
#
......@@ -258,6 +266,7 @@ outfiles="Makeconf GNUmakefile setversion \
tmcc/freebsd9/GNUmakefile tmcc/freebsd9/netif-emulab \
tmcc/freebsd10/GNUmakefile tmcc/freebsd10/netif-emulab \
tmcc/cygwinxp/GNUmakefile tmcc/dp/GNUmakefile \
tmcc/cygwinseven/GNUmakefile tmcc/cygwinseven/unattend-x86.xml \
tmcc/openbsd/GNUmakefile tmcc/ron/GNUmakefile \
tmcc/plab/GNUmakefile tmcc/cygwinseven/GNUmakefile \
os/GNUmakefile os/syncd/GNUmakefile \
......
......@@ -225,7 +225,7 @@ sub doboot()
if ($exists) {
if (WINDOWS()) {
# Windows needs to know all of the groups by name.
os_groupgid($group, $gid);
os_groupgid($gid, $group);
}
else {
if ($gid != $curgid) {
......
......@@ -22,7 +22,6 @@
#
#
# XXX ONLY RUN THIS INSTALL ON A CYGWIN / WINDOWS XP NODE!
# Similar to linux9, cygwinseven is an overlay on linux, which is an overlay
# on common.
#
......@@ -63,10 +62,10 @@ SYSPREP = $(SYSTEM32)/sysprep
SPSCRIPTS = $(WINDOWS)/Setup/Scripts
install client-install: baselinux-install common-install etc-install \
sup-install script-install ##bin-install
sup-install script-install bin-install
@echo "Remember to install the PEM files if necessary"
simple-install: common-install script-install ##bin-install
simple-install: common-install script-install
dir-install:
......@@ -81,21 +80,10 @@ 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
$(INSTALL) -m 755 $(SRCDIR)/usrtogrp.exe $(BINDIR)/usrtogrp.exe
# Setx is run under CMD early in the user login to make HOME for Emacs.
$(INSTALL) -m 755 $(SRCDIR)/setx.exe $(SYSTEM32)/setx.exe
# Devcon is used by rc.cygwin and rc.ifc to disable/enable NIC's.
$(INSTALL) -m 755 $(SRCDIR)/devcon.exe $(BINDIR)/devcon.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-install
sysetc-install: dir-install ###ifcfgs
sysetc-install: dir-install
# Watchdog assumes the ssh keys are in /etc/ssh.
mkdir -p /etc/ssh
ln -f -s /etc/ssh* /etc/ssh
......@@ -110,24 +98,17 @@ script-install: dir-install $(SCRIPTS)
$(INSTALL) -m 755 $(SRCDIR)/prepare $(BINDIR)/prepare
$(INSTALL) -m 755 $(SRCDIR)/tbshutdown $(BINDIR)/tbshutdown
$(INSTALL) -c -m 755 -o root -d /sbin
#$(INSTALL) -m 755 $(SRCDIR)/reboot /sbin/reboot
# Put the tcsh desktop startup script in the CygWin root directory.
#$(INSTALL) -m 755 $(SRCDIR)/cygwin-tcsh.bat /
ln -f -s /bin/shutdown /sbin/shutdown
ln -f -s /bin/reboot /sbin/reboot
# Everybody is in the Administrators group already, so sudo is irrelevant.
$(INSTALL) -m 755 $(SRCDIR)/sudo.dummy /bin/sudo
#$(INSTALL) -m 755 $(SRCDIR)/rc.firstboot $(BINDIR)/rc/rc.firstboot
$(INSTALL) -m 755 $(SRCDIR)/rc.cygwinseven $(BINDIR)/rc/rc.cygwin
#$(INSTALL) -m 755 $(SRCDIR)/clean_logonui $(BINDIR)/clean_logonui
$(INSTALL) -m 755 $(SRCDIR)/rc.reboot $(BINDIR)/rc/rc.reboot
$(INSTALL) -m 755 $(SRCDIR)/rc.lmhosts $(BINDIR)/rc/rc.lmhosts
$(INSTALL) -m 755 $(SRCDIR)/netbt $(BINDIR)/netbt
$(INSTALL) -m 755 $(SRCDIR)/unattend-x86.xml $(SYSPREP)/unattend-src.xml
$(INSTALL) -c -m 755 -o Administrators -d $(SPSCRIPTS)
$(INSTALL) -m 755 $(SRCDIR)/setupnode.ps1 $(SPSCRIPTS)/setupnode.ps1
$(INSTALL) -m 755 $(SRCDIR)/SetupComplete.cmd $(SPSCRIPTS)/SetupComplete.cmd
$(INSTALL) -m 755 $(SRCDIR)/reboot.sh /bin/reboot
$(INSTALL) -m 755 $(SRCDIR)/hookservices $(BINDIR)/hookservices
sfs-install:
......
#
# Copyright (c) 2012 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
# Directives for turning a vanilla Windows 7 machine into an emulab node.
# Phase 1.
#
# hostname of ntp server
defvar ntpserver ;; ntp1
# Where the devcon utility should go.
defvar devconpath ;; C:\Windows\System32
# grab root password
readvar rootpass ;; Type password for root user ;; secure
log Disabling User Access Controls
addreg HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System ;; EnableLUA ;; Dword ;; 0
log Disabling Automatic Activation and Activation Notification
addreg HKLM\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Activation ;; Manual ;; Dword ;; 1
addreg HKLM\Software\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Activation ;; NotificationDisabled ;; Dword ;; 1
log Disabling Windows Firewall
runcmd netsh.exe ;; advfirewall set AllProfiles state off ;; 0
log Disabling Windows Defender
runcmd sc.exe ;; config WinDefend start= disabled ;; 0
log Disabling Action Center
addreg HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer ;; HideSCAHealth ;; Dword ;; 1
runcmd sc.exe ;; config wscsvc start= disabled ;; 0
log Disabling Volume Control Icon
addreg HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer ;; HideSCAVolume ;; Dword ;; 1
log Disabling IPv6
addreg HKLM\System\CurrentControlSet\Services\tcpip6\Parameters ;; DisabledComponents ;; Dword ;; 0xffffffff
log Disabling TCP Chimney offload
runcmd netsh.exe ;; int tcp set global chimney=disabled ;; 0
log Enable global IP Forwarding
addreg HKLM\system\currentcontrolset\services\tcpip\parameters ;; IPEnableRouter ;; Dword ;; 1
log Disabling LLTDIO Mapper
runcmd sc.exe ;; config lltdio start= disabled ;; 0
log Disabling SSDP and UPnP services
runcmd sc.exe ;; config SSDPSRV start= disabled ;; 0
runcmd sc.exe ;; config upnphost start= disabled ;; 0
log Disabling WMP network service
runcmd sc.exe ;; config WMPNetworkSvc start= disabled ;; 0
log Disabling Windows Error Reporting
addreg HKLM\Software\Microsoft\Windows\Windows Error Reporting ;; Disabled ;; Dword ;; 1
log Disabling automatic updating
addreg HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update ;; AUOptions ;; Dword ;; 1
runcmd sc.exe ;; config wuauserv start= disabled ;; 0
log Disabling hibernate
runcmd powercfg.exe ;; /H off ;; 0
log Disabling scheduled defragmentation
runcmd schtasks.exe ;; /change /TN "\Microsoft\Windows\Defrag\ScheduledDefrag" /disable ;; 0
log Enabling Remote Desktop Protocol connections
addreg HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server ;; fDenyTSConnections ;; Dword ;; 0
log Creating local root user
adduser root ;; %rootpass% ;; makeadmin
# XXX: Ugh... What a mess!
log Setting up the clock
addreg HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation ;; RealTimeIsUniversal ;; Dword ;; 1
runcmd w32tm.exe ;; /register
runcmd sc.exe ;; config w32time start= auto ;; 0
runcmd sc.exe ;; triggerinfo w32time start/networkon stop/networkoff ;; 0
runcmd net.exe ;; start w32time
runcmd w32tm.exe ;; /config /manualpeerlist:%ntpserver% /syncfromflags:manual /update
log Finished! Please be sure to put Microsoft's devcon utility into %devconpath%
log Also, copy in ssh host keys from another of your Emulab nodes and replace the existing ones on this machine.
#
# Copyright (c) 2012 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
# Stash area for installers, source, etc.
defvar swdir ;; C:\Software
# Where to put the Cygwin source bits.
defvar cygsrc ;; %swdir%\Cygwin
# Cygwin installation path
defvar cygdest ;; C:\Cygwin
# Where to fetch the Cygwin sources
defvar cyg_mirror ;; http://mirror.emulab.net/cygwin
# The name of the Cygwin setup executable.
defvar setup_exec ;; setup.exe
# Emulab source
defvar elab_dld ;; http://www.emulab.net/downloads
defvar pubsubsrc ;; pubsub-0.95
defvar pubsub_tarball ;; %pubsubsrc%.tar.gz
defvar elabsw ;; %swdir%\Emulab
# The list of Cygwin packages to install.
defvar cyg_pkgs ;; boost-devel,bison,byacc,cygrunsrv,flex,gawk,gcc4,g++4,inetutils,make,emulab-openssh,openssl-devel,perl,perl-libwin32,perl_vendor,psmisc,python,shutdown,swig,sysvinit,tcsh,util-linux,w32api,bc,cvs,ed,emacs,file,gdb,git,nano,nc,patch,rcs,rpm,rsync,rxvt,vim,wget,unzip,zip
# Get cygwin user password
readvar sshpass ;; Please supply a password for the Cygwin SSH user ;; secure
log Downloading Cygwin setup executable.
mkdir %cygsrc%
getfile %cyg_mirror%/%setup_exec% ;; %cygsrc%\%setup_exec%
log Running Cygwin installer.
runcmd %cygsrc%\%setup_exec% ;; -X -l %cygsrc% -s %cyg_mirror% -O -R %cygdest% -q -P %cyg_pkgs%
modpathenv %cygdest%\bin ;; append
log Cygwin Setup Complete.
log Setting up syslogd
runcyg syslogd-config -y ;; 0
log Setting up sshd
mkdir %cygdest%\etc\sshkeys
runcyg ssh-host-config -y -u cyg_sshd -w %sshpass% -c '' --privileged ;; 0
runcyg sed -e 's|^AuthorizedKeysFile.*$|AuthorizedKeysFile /sshkeys/%u/authorized_keys|' /etc/sshd_config > /etc/sshd_config.new ;; 0
runcyg mv -f /etc/sshd_config.new /etc/sshd_config ;; 0
mkdir %cygdest%\etc\ssh
runcyg ln -f -s /etc/ssh?* /etc/ssh ;; 0
log Setting up agetty
runcmd bcdedit.exe ;; /ems off ;; 0
runcyg init-config -y ;; 0
runcyg sed -e 's|^.*agetty.*$|S0:2345:respawn:/usr/sbin/agetty -L ttyS0 115200 vt100|' /etc/inittab > /etc/inittab.new ;; 0
runcyg mv -f /etc/inittab.new /etc/inittab ;; 0
log Configuring wget
runcyg grep -q 'check-certificate' /etc/wgetrc || echo 'check-certificate = off' >> /etc/wgetrc ;; 0
log Creating dummy sudo command
runcyg echo -e '#!/bin/sh\n$*\n' > /bin/sudo && chmod a+rx /bin/sudo ;; 0
log Adding security rights to root account
runcyg editrights -u root -a SeCreateTokenPrivilege -a SeAssignPrimaryTokenPrivilege -a SeIncreaseQuotaPrivilege -a SeServiceLogonRight -l ;; 0
log Fixing up /etc/passwd and /etc/group
runcyg mkpasswd | sed -e '{ s/^root:unused:[0-9]\+:\(.*\)$/root:unused:0:\1/; s%^\(cyg_sshd.*\):.*$%\1:/bin/false% }' > /etc/passwd.new && mv -f /etc/passwd.new /etc/passwd ;; 0
runcyg mkgroup | sed -e '/^Administrators/ { p; s/Administrators/wheel/ }' > /etc/group.new && mv -f /etc/group.new /etc/group ;; 0
log Downloading pubsub source
mkdir %elabsw%
getfile %elab_dld%/%pubsub_tarball% ;; %elabsw%\%pubsub_tarball%
log Unpacking pubsub source and building
runcyg cd '%elabsw%' && tar -zxf %pubsub_tarball% ;; 0
runcyg cd '%elabsw%\%pubsubsrc%' && touch .noelvin && make && make install ;; 0
#!/usr/bin/perl -w
#
# Copyright (c) 2012 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#
use English;
use Win32;
use Win32API::Net qw(:User);
use Term::ReadKey;
# 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;
$ENV{'PATH'} .= ":/cygdrive/c/Windows/System32:/cygdrive/c/Windows";
}
#
# Load the OS independent support library. It will load the OS dependent
# library and initialize itself.
#
use libsetup;
use liblocsetup;
use librc;
# Global vars / constants
my $ULEVEL = 1;
sub usage() {
print "$0 [-p <root_password>]\n".
"\n(re)hook the Emulab Windows services.\n";
exit 1;
}
sub modpasswd($$)
{
my($user, $pswd) = @_;
my %uh = ();
my $error;
if (!UserGetInfo("", $user, $ULEVEL, \%uh)) {
my $err = Win32::GetLastError();
warning("UserGetInfo failed for $user: $err\n");
return 0;
}
if ($pswd) {
$uh{password} = $pswd;
if (!UserSetInfo("", $user, $ULEVEL, \%uh, \$error)) {
my $err = Win32::GetLastError();
warning("UserSetInfo failed: $err, $error\n");
return 0;
}
}
return 1;
}
sub get_passwd($) {
my ($user) = @_;
my $passwd = "";
my $vpasswd = "";
while ($passwd eq "") {
print "Enter a password for $user: ";
ReadMode 'noecho';
$passwd = ReadLine 0;
chomp $passwd;
ReadMode 'normal';
print "\n";
}
while ($vpasswd eq "" || $passwd ne $vpasswd) {
print "Didn't match, try again.\n"
if $vpasswd ne "" && $passwd ne $vpasswd;
print "Re-enter password: ";
ReadMode 'noecho';
$vpasswd = ReadLine 0;
chomp $vpasswd;
ReadMode 'normal';
print "\n";
}
return $passwd;
}
my $optlist = "p:";
my $rootpwd = "";
# Parse command line.
use Getopt::Std;
if (! getopts($optlist, \%options)) {
usage();
}
if (defined($options{'p'})) {
$rootpwd = $options{'p'};
} else {
$rootpwd = get_passwd("root");
}
#
# Sync Cygwin passwd and group files with Windows
#
if (os_accounts_sync() != 0) {
print "Error syncing Windows and Cygwin user and group databases!";
exit 1;
}
# Set the root password to make sure it matches. We also set this to be
# the Administrator password, to match the sysprep.inf file entry below.
print "\nSetting root password.\n";
modpasswd("root", $rootpwd) or die "Couldn't set root's password!";
#
# Windows stores the password as part of the definition of services that
# run as a real user, such as root, rather than as SYSTEM. Redefine them
# with the current password. Otherwise, Windows will refuse to start them
# up at reboot.
#
my $mybash = "/bin/bash";
print "\nRedefining Pubsub service.\n";
my $pubsub = "/usr/local/libexec/pubsubd";
my $pubsublog = "/var/log/pubsub.log";
system("cygrunsrv -R pubsub > /dev/null 2>&1");
# pubsub runs as the 'SYSTEM' user.
system("cygrunsrv.exe -I pubsub -d 'CYGWIN pubsub' -t auto -y tcpip ".
"-n -p $pubsub -a \"-d -l '$pubsublog'\"");
system("cygrunsrv -VQ pubsub");
my $tbshutdown = "/usr/local/etc/emulab/tbshutdown";
print "\nRedefining EmulabShutdown.\n";
system("cygrunsrv -R EmulabShutdown > /dev/null 2>&1");
system("cygrunsrv -I EmulabShutdown -u root -w '$rootpwd'" .
" --shutdown --type manual -p $mybash " .
" -a \"--norc --noprofile -c '$tbshutdown'\"");
system("cygrunsrv -VQ EmulabShutdown");
print "\nRedefining EmulabStartup.\n";
my $bootsetup = "/usr/local/etc/emulab/rc/rc.bootsetup";
my $progrun = "cygrunsrv -S ProgAgent";
my $bootlog = "/var/log/bootsetup.log";
system("cygrunsrv -R EmulabStartup > /dev/null 2>&1");
system("cygrunsrv -I EmulabStartup -u root -w '$rootpwd'" .
" --dep DHCP --dep iphlpsvc --dep pubsub --dep W32Time" .
" -p $mybash -a \"--norc --noprofile -c " .
" '( $bootsetup; $progrun ) >& $bootlog'\"");
system("cygrunsrv -VQ EmulabStartup");
system("sc config EmulabStartup start= delayed-auto");
exit 0;
......@@ -48,7 +48,7 @@ sub VERSION() { return 1.0; }
# Must come after package declaration!
use English;
use Win32;
use Win32API::Net qw(:User);
use Win32API::Net qw(:User :LocalGroup);
use Win32::Registry;
# Load up the paths. Its conditionalized to be compatabile with older images.
......@@ -119,10 +119,11 @@ my $GATED = "/usr/sbin/gated";
my $ROUTE = "$NTS/route";
my $SHELLS = "/etc/shells";
my $DEFSHELL = "/bin/tcsh";
my $winusersfile = "$BOOTDIR/winusers";
#my $winusersfile = "$BOOTDIR/winusers";
my $usershellsfile = "$BOOTDIR/usershells";
my $XIMAP = "$BOOTDIR/xif_map";
my $ULEVEL = 1;
my $GLEVEL = 0;
#
# Goo for setting up speed and duplex under Windows
......@@ -303,7 +304,7 @@ sub os_accounts_sync()
if (system("$cmd") != 0) {
warning("Nonzero exit status while generating /etc/group file: $?\n");
}
return 0;
}
......@@ -517,67 +518,98 @@ sub os_etchosts_line($$$)
}
#
# On Windows NT, accumulate an input file for the addusers command.
# See "AddUsers Automates Creation of a Large Number of Users",
# http://support.microsoft.com/default.aspx?scid=kb;en-us;199878
#
# The file format is comma-delimited, as follows:
#
# [Users]
# User Name,Full name,Password,Description,HomeDrive,Homepath,Profile,Script
# Setup some initial state and open some files while creating accounts under
# Windows.
#
# [Global] or [Local]
# Group Name,Comment,UserName,...
#
my @groupNames;
my %groupsByGid;
my %groupMembers;
sub os_accounts_start()
{
# Remember group info to be put out at the end.
@groupNames = ();
%groupsByGid = ();
%groupMembers = ();
if (! open(WINUSERS, "> $winusersfile")) {
warning("os_accounts_start: Cannot create $winusersfile .\n");
return -1;
}
# Don't wipe out previous user shell preferences, just add new ones.
if (! open(USERSHELLS, ">> $usershellsfile")) {
warning("os_accounts_start: Cannot create or append to $usershellsfile .\n");
return -1;
}
# Users come before groups in the addusers.exe account stream.
# Notice the <CR><LF>'s! It's a Windows file.
print WINUSERS "[Users]\r\n";
return 0;
}
#
# Remember the mapping from an existing group GID to its name.
# Windows helper function.
# Create a mapping from gid to group name if both parameters are specified.
# Return the group name in any case (i.e., performs a lookup if no group
# name is specified).
#
sub os_groupgid($$)
sub os_groupgid($;$)
{
my($group, $gid) = @_;
my($gid, $gname) = @_;
$groupsByGid{$gid} = $group; # Remember the name associated with the gid.
if (defined($gname)) {
# Remember the name associated with the gid.
$groupsByGid{$gid} = $gname;
}
return 0;
if (int($gid) == 0) {
$gname = "Administrators";
}
return $groupsByGid{$gid};
}
#
# Add a new group
#
# Under Windows we also create a gid -> group name mapping for future
# reference, and initialize an array for holding group members (users).
#
sub os_groupadd($$)
{
my($group, $gid) = @_;
push(@groupNames, $group); # Remember all of the group names.
os_groupgid($group, $gid);
os_groupgid($gid, $group);
$groupMembers{$group} = [];
my %gh = (
'name' => $group,
);
my $error;
if (!LocalGroupAdd("",$GLEVEL,\%gh,\$error)) {
my $err = Win32::GetLastError();
warning("GroupAdd failed: $err, $error\n");
return -1;
}
return 0;