]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/backup-acl-test
Enhance virtual backup test
[bacula/bacula] / regress / tests / backup-acl-test
1 #!/bin/sh
2 #
3 # Run a backup of the Bacula build directory with some acls
4 #   then restore it.
5 #
6 # The fs have to be mount with the acl option (mount -o remount,acl,user_xattr /tmp)
7 # on ubuntu, it needs the attr package
8 #
9 TestName="backup-acl-test"
10 JobName=backup
11 . scripts/functions
12
13 require_linux
14 scripts/cleanup
15 scripts/copy-confs
16
17 #
18 # Zap out any schedule in default conf file so that
19 #  it doesn't start during our test
20 #
21 outf="tmp/sed_tmp"
22 echo "s%  Schedule =%# Schedule =%g" > $outf
23 echo "s/Options {/Options { aclsupport=yes/" >> $outf
24 cp ${cwd}/bin/bacula-dir.conf  $cwd/tmp/1
25 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
26
27 d=${cwd}/build/acl
28
29 uid=`id -u`
30 rm -rf $d
31 mkdir $d
32 mkdir $d/testdir
33 cp ${cwd}/bin/bconsole $d
34 setfacl -m d:user:$uid:r-x $d/testdir
35 setfacl -m d:user:root:-wx $d/testdir
36 setfacl -m user:nobody:--- $d/testdir
37 setfacl -m user:nobody:--- $d/bconsole
38 setfacl -m group:nogroup:--x $d/bconsole
39 cp ${cwd}/bin/bconsole $d/testdir
40 cp ${cwd}/bin/bconsole $d/other
41 setfattr -n bacula.test -v rulez $d/other
42
43 ( cd $cwd/build
44   getfacl -R acl > $cwd/tmp/org
45   getfattr -R acl > $cwd/tmp/attr.org
46 )
47
48 change_jobname Client1 $JobName
49 start_test
50
51 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
52 @output /dev/null
53 messages
54 @$out ${cwd}/tmp/log1.out
55 label volume=TestVolume001 storage=File pool=Default
56 run job=$JobName yes
57 wait
58 messages
59 @# 
60 @# now do a restore
61 @#
62 @$out ${cwd}/tmp/log2.out  
63 restore where=${cwd}/tmp/bacula-restores select all done
64 yes
65 wait
66 messages
67 @$out
68 quit
69 END_OF_DATA
70
71 run_bacula
72 check_for_zombie_jobs storage=File
73 stop_bacula
74
75 ( cd $cwd/tmp/bacula-restores/$cwd/build
76   getfacl -R acl > $cwd/tmp/new
77   getfattr -R acl > $cwd/tmp/attr.new
78 )
79
80 diff $cwd/tmp/org $cwd/tmp/new
81 if [ $? -ne 0 ]; then
82    rstat=1
83 fi
84
85 diff $cwd/tmp/attr.org $cwd/tmp/attr.new
86 if [ $? -ne 0 ]; then
87    rstat=1
88 fi
89
90 rm -rf $d
91
92 check_two_logs
93 check_restore_diff
94
95 end_test