diff --git a/DartTestfile.txt.in b/DartTestfile.txt.in index 3537f40..e4b677d 100644 --- a/DartTestfile.txt.in +++ b/DartTestfile.txt.in @@ -4,6 +4,7 @@ ADD_TEST(disk:action-on-purge-test "@regressdir@/tests/action-on-purge-test") ADD_TEST(disk:accurate-test "@regressdir@/tests/accurate-test") ADD_TEST(disk:allowcompress-test "@regressdir@/tests/allowcompress-test") ADD_TEST(disk:allowed-scriptdir-test "@regressdir@/tests/allowed-scriptdir-test") +ADD_TEST(disk:allowed-jobcommand-test "@regressdir@/tests/allowed-jobcommand-test") ADD_TEST(disk:auto-label-test "@regressdir@/tests/auto-label-test") ADD_TEST(disk:backup-bareos-test "@regressdir@/tests/backup-bareos-test") ADD_TEST(disk:backup-bareos-passive-test "@regressdir@/tests/backup-bareos-passive-test") diff --git a/all-disk-tests b/all-disk-tests index 98371ba..9065a59 100755 --- a/all-disk-tests +++ b/all-disk-tests @@ -11,6 +11,7 @@ rm -f dumps/* ./run tests/action-on-purge-test ./run tests/allowcompress-test ./run tests/allowed-scriptdir-test +./run tests/allowed-jobcommand-test ./run tests/accurate-test ./run tests/auto-label-test ./run tests/backup-bareos-test diff --git a/configs/allowed-jobcommand-test/bareos-dir.conf.allowed-jobcommand-test.in b/configs/allowed-jobcommand-test/bareos-dir.conf.allowed-jobcommand-test.in new file mode 100644 index 0000000..c241a19 --- /dev/null +++ b/configs/allowed-jobcommand-test/bareos-dir.conf.allowed-jobcommand-test.in @@ -0,0 +1,120 @@ +# +# Default Bareos 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. +# +# You might also want to change the default email address +# from root to your address. See the "mail" and "operator" +# directives in the Messages resource. +# + +Director { # define myself + Name = @hostname@-dir + DIRPort = @dirport@ # where we listen for UA connections + QueryFile = "@scriptdir@/query.sql" + WorkingDirectory = "@working_dir@" + PidDirectory = "@piddir@" + SubSysDirectory = "@subsysdir@" + Maximum Concurrent Jobs = 4 + Password = "pNvX1WiXnwv2C/F7E52LGvw6rKjbbPvu2kyuPa9pVaL3" # Console password + Messages = Standard +} + +JobDefs { + Name = "DefaultJob" + Type = Backup + Level = Incremental + Client = @hostname@-fd + FileSet = FS_TESTJOB + Storage = File + Messages = Standard + Pool = Default + Priority = 10 + Maximum Concurrent Jobs = 16 +} + +Job { + Name = "BackupClient1" + JobDefs = "DefaultJob" + Client Run Before Job = "@working_dir@/runbeforejob.sh" +} + + +FileSet { + Name = FS_TESTJOB + Include { + File=<@tmpdir@/file-list + } +} + +#dir: BeforeJob: run command "/bin/echo RunBeforeJob" +#fd: ClientRunBeforeJob: ClientRunBeforeJob +#fd: ClientAfterJob: run command "/bin/echo ClientRunAfterJob" +#dir: AfterJob: run command "/bin/echo RunAfterJob" + + +# Client (File Services) to backup +Client { + Name = @hostname@-fd + Address = @hostname@ + FDPort = @fdport@ + Catalog = MyCatalog + Password = "xevrjURYoCHhn26RaJoWbeWXEY/a3VqGKp/37tgWiuHc" # password for FileDaemon + File Retention = 30d # 30 days + Job Retention = 180d # six months + AutoPrune = yes # Prune expired Jobs/Files + Maximum Concurrent Jobs = 4 + +} + +# Definiton of file storage device +Storage { + Name = File + Address = @hostname@ # N.B. Use a fully qualified name here + SDPort = @sdport@ + Password = "ccV3lVTsQRsdIUGyab0N4sMDavui2hOBkmpBU0aQKOr9" + Device = FileStorage + Media Type = File + Maximum Concurrent Jobs = 4 +} + +# Generic catalog service +Catalog { + Name = MyCatalog + @libdbi@ + dbname = @db_name@; user = @db_user@; password = "@db_password@" +} + + +Messages { + Name = Standard + console = all, !skipped, !saved + catalog = all, !skipped +} + +# Default pool definition +Pool { + Name = Default + Pool Type = Backup + Recycle = yes # Bareos can automatically recycle Volumes + AutoPrune = yes # Prune expired volumes + Volume Retention = 365d # one year +} + + +# +## Standard Restore template, to be changed by Console program +## Only one such job is needed for all Jobs/Clients/Storage ... +## +Job { + Name = "RestoreFiles" + Type = Restore + Client = @hostname@-fd + FileSet= FS_TESTJOB + Storage = File + Pool = Default + Messages = Standard + Where = /tmp/bareos-restores +} diff --git a/configs/allowed-jobcommand-test/bareos-fd.conf.allowed-jobcommand-test.in b/configs/allowed-jobcommand-test/bareos-fd.conf.allowed-jobcommand-test.in new file mode 100644 index 0000000..3efda37 --- /dev/null +++ b/configs/allowed-jobcommand-test/bareos-fd.conf.allowed-jobcommand-test.in @@ -0,0 +1,38 @@ +# +# Default Bareos File Daemon Configuration file +# +# There is not much to change here except perhaps the +# File daemon Name to +# + +# +# List Directors who are permitted to contact this File daemon +# +Director { + Name = @hostname@-dir + Password = "xevrjURYoCHhn26RaJoWbeWXEY/a3VqGKp/37tgWiuHc" # password for FileDaemon + Allowed Script Dir = "@working_dir@" +} + +# +# "Global" File daemon configuration specifications +# +FileDaemon { # this is me + Name = @hostname@-fd + FDPort = @fdport@ # where we listen for the director + WorkingDirectory = @working_dir@ + Pid Directory = @piddir@ + Maximum Concurrent Jobs = 20 + + Allowed Job Command = runscript + Allowed Job Command = backup + Allowed Job Command = restore + Allowed Job Command = verify + Allowed Job Command = estimate +} + +# Send all messages except skipped files back to Director +Messages { + Name = Standard + director = @hostname@-dir = all, !skipped, !restored +} diff --git a/tests/allowed-jobcommand-test b/tests/allowed-jobcommand-test new file mode 100755 index 0000000..12a6e23 --- /dev/null +++ b/tests/allowed-jobcommand-test @@ -0,0 +1,270 @@ +#!/bin/sh +# +# +TestName="allowed-jobcommand-test" +JobName=BackupClient1 +. scripts/functions + +scripts/cleanup +scripts/copy-test-confs + + +# create the run before job script +echo "#!/bin/sh +echo allowed job command: runbeforejob +" > $working/runbeforejob.sh +chmod +x $working/runbeforejob.sh + +rm -f bin/bareos-dir.conf +/bin/cp -f ${rconfigs}/${TestName}/bareos-dir.conf.allowed-jobcommand-test bin/bareos-dir.conf +/bin/cp -f ${rconfigs}/${TestName}/bareos-fd.conf.allowed-jobcommand-test bin/bareos-fd.conf +/bin/cp -f ${rconfigs}/${TestName}/bareos-fd.conf.allowed-jobcommand-test bin/bareos-fd.conf.orig + +# create test data +dd if=/dev/zero of=${cwd}/tmp/testdata bs=400k count=1 + +echo "${cwd}/tmp/testdata" >${cwd}/tmp/file-list + +cp ${cwd}/tmp/file-list ${cwd}/tmp/restore-list + + +start_test + +cat >${cwd}/tmp/bconcmds <&1 >/dev/null +if test $? -eq 0; then + print_debug "Backup was OK" +else + estat=1 +fi + +grep "2000 OK estimate files=1 bytes=" ${tmp}/estimate.log 2>&1 >/dev/null +if test $? -eq 0; then + print_debug "estimate OK" +else + estat=2 +fi + +grep "Termination: Restore OK" ${tmp}/restore.log 2>&1 >/dev/null +if test $? -eq 0; then + print_debug "Restore OK" +else + estat=3 +fi + + + + + +# remove the runscript command from allowed commands +sed 's@Allowed Job Command = runscript@# Allowed Job Command = runscript@g' >bin/bareos-fd.conf ${cwd}/tmp/bconcmds <&1 >/dev/null +if test $? -eq 0; then + print_debug "runscript was blocked : OK" +else + estat=4 +fi + +grep "2000 OK estimate files=1 bytes=" ${tmp}/estimate2.log 2>&1 >/dev/null +if test $? -eq 0; then + print_debug "estimate OK" +else + estat=5 +fi + +grep "Termination: Restore OK" ${tmp}/restore2.log 2>&1 >/dev/null +if test $? -eq 0; then + print_debug "Restore OK" +else + estat=6 +fi + + + + +# remove the estimate command from allowed commands +sed 's@Allowed Job Command = estimate@# Allowed Job Command = estimate@g' >bin/bareos-fd.conf ${cwd}/tmp/bconcmds <&1 >/dev/null +if test $? -eq 0; then + print_debug "Backup was OK" +else + estat=7 +fi + + +grep "Illegal estimate command not allowed by Allowed Job Cmds setting of this filed." ${tmp}/estimate3.log 2>&1 >/dev/null +if test $? -eq 0; then + print_debug "estimate blocked : OK" +else + estat=8 +fi + +grep "Termination: Restore OK" ${tmp}/restore3.log 2>&1 >/dev/null +if test $? -eq 0; then + print_debug "Restore OK" +else + estat=9 +fi + + + + + + + +# remove the restore command from allowed commands +sed 's@Allowed Job Command = restore@# Allowed Job Command = restore@g' >bin/bareos-fd.conf ${cwd}/tmp/bconcmds <&1 >/dev/null +if test $? -eq 0; then + print_debug "Backup was OK" +else + estat=10 +fi + +grep "2000 OK estimate files=1 bytes=" ${tmp}/estimate4.log 2>&1 >/dev/null +if test $? -eq 0; then + print_debug "estimate OK" +else + estat=11 +fi + +grep "Fatal error: Illegal restore command not allowed by Allowed Job Cmds setting of this filed." ${tmp}/restore4.log 2>&1 >/dev/null +if test $? -eq 0; then + print_debug "Restore Blocked: OK" +else + estat=12 +fi + + + + + + + + + + + + + + +end_test