From 9f9e7143bed105c663480c9f90a6600328d633c6 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Tue, 23 Nov 2010 13:15:41 +0100 Subject: [PATCH] regress: Backport win32 regress test --- regress/scripts/regress-win32.pl | 85 ++++++++ .../win32-bacula-dir-systemstate.conf.in | 204 ++++++++++++++++++ regress/scripts/win32-bacula-dir.conf.in | 13 ++ 3 files changed, 302 insertions(+) create mode 100644 regress/scripts/win32-bacula-dir-systemstate.conf.in diff --git a/regress/scripts/regress-win32.pl b/regress/scripts/regress-win32.pl index a6ccf0256d..c988f3cb3f 100644 --- a/regress/scripts/regress-win32.pl +++ b/regress/scripts/regress-win32.pl @@ -390,6 +390,42 @@ sub cleandir return "OK\n"; } +sub reboot +{ + Win32::InitiateSystemShutdown('', "\nSystem will now Reboot\!", 2, 0, 1 ); + exit 0; +} + +# boot disabled auto +sub set_service +{ + my ($r) = shift; + + if ($r->url !~ m!^/set_service\?srv=([\w-]+);action=(\w+)$!) { + return "ERR\nIncorrect url\n"; + } + my $out = `sc config $1 start= $2`; + if ($out !~ /SUCCESS/) { + return "ERR\n$out"; + } + return "OK\n"; +} + +# RUNNING, STOPPED +sub get_service +{ + my ($r) = shift; + + if ($r->url !~ m!^/get_service\?srv=([\w-]+);state=(\w+)$!) { + return "ERR\nIncorrect url\n"; + } + my $out = `sc query $1`; + if ($out !~ /$2/) { + return "ERR\n$out"; + } + return "OK\n"; +} + sub add_registry_key { my ($r) = shift; @@ -426,6 +462,50 @@ sub add_registry_key return "$ret\n"; } +sub set_auto_logon +{ + my ($r) = shift; + my $self = $0; + $self =~ s/\\/\\\\/g; + my $p = $^X; + $p =~ s/\\/\\\\/g; + if ($r->url !~ m!^/set_auto_logon\?user=(\w+);pass=([\w\d\,:*+-]*)$!) { + return "ERR\nIncorrect url\n"; + } + my $k = $1; + my $v = $2 || ''; # password can be empty + my $ret = "ERR"; + open(FP, ">c:/autologon.reg") + or return "ERR\nCan't open tmp.reg $!\n"; + print FP "Windows Registry Editor Version 5.00 + +[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon] +\"DefaultUserName\"=\"$k\" +\"DefaultPassword\"=\"$v\" +\"AutoAdminLogon\"=\"1\" + +[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run] +\"regress\"=\"$p $self\" + +"; + close(FP); + system("regedit /s c:\autologon.reg"); + + unlink("tmp2.reg"); + system("regedit /e tmp2.reg \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\""); + + open(FP, "<:encoding(UTF-16LE)", "tmp2.reg") + or return "ERR\nCan't open tmp2.reg $!\n"; + while (my $l = ) { + if ($l =~ /"AutoAdminLogon"="1"/) { + $ret = "OK"; + } + } + close(FP); + unlink("tmp2.reg"); + return "$ret\n"; +} + sub del_registry_key { my ($r) = shift; @@ -487,6 +567,7 @@ sub get_registry_key # When adding an action, fill this hash with the right function my %action_list = ( + nop => sub { return "OK\n"; }, stop => \&stop_fd, start => \&start_fd, install => \&install_fd, @@ -499,6 +580,10 @@ my %action_list = ( del_registry_key => \&del_registry_key, get_registry_key => \&get_registry_key, quit => sub { exit 0; }, + reboot => \&reboot, + set_service => \&set_service, + get_service => \&get_service, + set_auto_logon => \&set_auto_logon, ); # handle client request diff --git a/regress/scripts/win32-bacula-dir-systemstate.conf.in b/regress/scripts/win32-bacula-dir-systemstate.conf.in new file mode 100644 index 0000000000..5f9dc8dd5c --- /dev/null +++ b/regress/scripts/win32-bacula-dir-systemstate.conf.in @@ -0,0 +1,204 @@ +# +# Default Bacula Director Configuration file +# +# The only thing that MUST be changed is to add one or more +# file or directory names in the Include directive of the +# FileSet resource. +# +# +# + +Director { # define myself + Name = @hostname@-dir + DIRPort = @dirport@ # where we listen for UA connections + QueryFile = "@scriptdir@/query.sql" + WorkingDirectory = "@working_dir@" + PidDirectory = "@piddir@" + Maximum Concurrent Jobs = 100 + Password = "pNvX1WiXnwv2C/F7E52LGvw6rKjbbPvu2kyuPa9pVaL3" + Messages = Daemon + FD Connect Timeout = 2min +} + +# +# Define the main nightly save backup job +# By default, this job will back up to disk in /home/kern/bacula/k/regress/tmp +Job { + Name = "SystemstateJob" + Type = Backup + Level = Incremental + Client = @win32_client@ + FileSet = "SystemState Set" + Storage = File + Messages = Standard + Pool = Default + Write Bootstrap = "@working_dir@/NightlySave.bsr" + Maximum Concurrent Jobs = 4 +} + +Job { + Name = "MSSQLJob" + Type = Backup + Level = Incremental + Client = @win32_client@ + FileSet = "MSSQL Set" + Storage = File + Messages = Standard + Pool = Default + Write Bootstrap = "@working_dir@/NightlySave.bsr" + Maximum Concurrent Jobs = 4 +} + +Job { + Name = "SS_SQLJob" + Type = Backup + Level = Incremental + Client = @win32_client@ + FileSet = "SS_SQL Set" + Storage = File + Messages = Standard + Pool = Default + Write Bootstrap = "@working_dir@/NightlySave.bsr" + Maximum Concurrent Jobs = 4 +} + + + +# Standard Restore template, to be changed by Console program +Job { + Name = "RestoreFiles" + Type = Restore + Client = @win32_client@ + FileSet="SystemState Set" + Storage = File + Messages = Standard + Pool = Default +# Where = /home/kern/bacula/k/regress/tmp/bacula-restores +} + + +# List of files to be backed up +FileSet { + Name = "SystemState Set" + Enable VSS = yes + Include { + Options { + signature=MD5; portable=no +# compression=GZIP + } + File = "@win32_file@" + Plugin = "vss:/@SYSTEMSTATE/" + } +} + +# List of files to be backed up +FileSet { + Name = "MSSQL Set" + Enable VSS = yes + Include { + Options { + signature=MD5; portable=no +# compression=GZIP + } + File = "@win32_file@" + Plugin = "vss:/@MSSQL/" + } +} + +FileSet { + Name = "SS_SQL Set" + Enable VSS = yes + Include { + Options { + signature=MD5; portable=no + } + File = "@win32_file@" + Plugin = "vss:/@SYSTEMSTATE/" + Plugin = "vss:/@MSSQL/" + } +} + + +# +# When to do the backups, full backup on first sunday of the month, +# differential (i.e. incremental since full) every other sunday, +# and incremental backups other days +Schedule { + Name = "WeeklyCycle" + Run = Full 1st sun at 1:05 + Run = Differential 2nd-5th sun at 1:05 + Run = Incremental mon-sat at 1:05 +} + +# Client (File Services) to backup +Client { + Name = @win32_client@ + Address = @win32_addr@ + FDPort = @win32_port@ + Catalog = MyCatalog + Password = "@win32_password@" + File Retention = 30d # 30 days + Job Retention = 180d # six months + AutoPrune = yes # Prune expired Jobs/Files + Maximum Concurrent Jobs = 4 +} + +# Definition of File storage device +Storage { + Name = File + Address = @win32_store_addr@ # N.B. Use a fully qualified name here + SDPort = @sdport@ + + Password = "ccV3lVTsQRsdIUGyab0N4sMDavui2hOBkmpBU0aQKOr9" # password for Storage daemon + Device = FileStorage # must be same as Device in Storage daemon + Media Type = File # must be same as MediaType in Storage daemon +# AutoChanger = yes + Maximum Concurrent Jobs = 4 +} + + +# Generic catalog service +Catalog { + Name = MyCatalog + + dbname = regress; user = regress; password = "" +} + +# Reasonable message delivery -- send most everything to email address +# and to the console +Messages { + Name = Standard + mailcommand = "@sbindir@/bsmtp -h localhost -f \"\(Bacula regression\) %r\" -s \"Regression: %t %e of %c %l\" %r" +# operatorcommand = "@sbindir@/bsmtp -h localhost -f \"\(Bacula regression\) %r\" -s \"Regression: Intervention needed for %j\" %r" +# MailOnError = kern@sibbald.com = all, !terminate +# operator = kern@sibbald.com = mount + console = all, !skipped, !terminate, !restored +# +# WARNING! the following will create a file that you must cycle from +# time to time as it will grow indefinitely. However, it will +# also keep all your messages if the scroll off the console. +# + append = "@working_dir@/log" = all, !skipped + catalog = all, !skipped +} + +# +# Message delivery for daemon messages (no job). +Messages { + Name = Daemon + mailcommand = "@sbindir@/bsmtp -h localhost -f \"\(Bacula regression\) %r\" -s \"Regression daemon message\" %r" +# mail = kern@sibbald.com = all, !skipped + console = all, !skipped, !saved + append = "@working_dir@/log" = all, !skipped + catalog = all, !skipped +} + + +# Default pool definition +Pool { + Name = Default + Pool Type = Backup + Recycle = yes # Bacula can automatically recycle Volumes + AutoPrune = yes # Prune expired volumes + Volume Retention = 365d # one year +} diff --git a/regress/scripts/win32-bacula-dir.conf.in b/regress/scripts/win32-bacula-dir.conf.in index 6e342a8965..7c30d54568 100644 --- a/regress/scripts/win32-bacula-dir.conf.in +++ b/regress/scripts/win32-bacula-dir.conf.in @@ -126,6 +126,19 @@ FileSet { } } +# List of files to be backed up +FileSet { + Name = "Plugin Set" + Enable VSS = yes + Include { + Options { + signature=MD5; portable=no +# compression=GZIP + } + File = "@win32_file@" + Plugin = "systemstate:/@SYSTEMSTATE/" + } +} # # When to do the backups, full backup on first sunday of the month, -- 2.39.5