]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/acl-xattr-test
Merge branch 'master' into basejobv3
[bacula/bacula] / regress / tests / acl-xattr-test
1 #!/bin/sh
2 #
3 # Run a backup of the Bacula build directory with some acls
4 #   then restore it.
5 #
6 # Your filesystem must be mounted with the acl option (mount -o remount,acl,user_xattr /tmp)
7 # on ubuntu, the attr package must be installed
8 #
9 # For this script to work, you will also need a number of acl packages loaded
10 #   not default on Debian derivatives: 
11 #   apt-get install acl libacl1 libacl1-dev attr
12 #
13 TestName="acl-xattr-test"
14 JobName=backup
15 . scripts/functions
16
17 require_linux
18
19 # Require getfacl to be installed
20 getfacl Makefile 2>&1 >/dev/null
21 if test  $? -ne 0; then
22   echo "$TestName skipped: getfacl not installed"
23   exit 0
24 fi
25
26 # Require attr to be installed
27 attr -l Makefile 2>&1 >/dev/null
28 if test $? -ne 0; then
29   echo "$TestName skipped: attr not installed"
30   exit 0
31 fi
32
33 scripts/cleanup
34 scripts/copy-confs
35
36 #
37 # Zap out any schedule in default conf file so that
38 #  it doesn't start during our test
39 #
40 outf="tmp/sed_tmp"
41 echo "s%  Schedule =%# Schedule =%g" > $outf
42 echo "s/Options {/Options { aclsupport=yes; xattrsupport = yes/" >> $outf
43 cp ${cwd}/bin/bacula-dir.conf  $cwd/tmp/1
44 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
45
46 d=${cwd}/build/acl
47
48 uid=`id -u`
49 rm -rf $d
50 mkdir $d
51 mkdir $d/testdir
52 cp ${cwd}/bin/bconsole $d
53 setfacl -m d:user:$uid:r-x $d/testdir
54 setfacl -m d:user:root:-wx $d/testdir
55 setfacl -m user:nobody:--- $d/testdir
56 setfacl -m user:nobody:--- $d/bconsole
57 setfacl -m group:nogroup:--x $d/bconsole
58 cp ${cwd}/bin/bconsole $d/testdir
59 cp ${cwd}/bin/bconsole $d/other
60 attr -s bacula.test -V rulez $d/other 2>/dev/null 1>/dev/null
61
62 ( cd $cwd/build
63   getfacl -R acl > $cwd/tmp/org
64   attr -g bacula.test $d/other > $cwd/tmp/attr.org
65 )
66
67 change_jobname BackupClient1 $JobName
68 start_test
69
70 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
71 @$out /dev/null
72 messages
73 @$out ${cwd}/tmp/log1.out
74 label volume=TestVolume001 storage=File pool=Default
75 setdebug level=400 trace=1 client
76 setdebug level=300 trace=1 director
77 setdebug level=300 trace=1 storage
78 run job=$JobName yes
79 wait
80 messages
81 @# 
82 @# now do a restore
83 @#
84 @$out ${cwd}/tmp/log2.out  
85 restore where=${cwd}/tmp/bacula-restores select all done
86 yes
87 wait
88 messages
89 quit
90 END_OF_DATA
91
92 run_bacula
93 check_for_zombie_jobs storage=File
94 stop_bacula
95
96 ( cd $cwd/tmp/bacula-restores/$cwd/build
97   getfacl -R acl > $cwd/tmp/new
98   attr -g bacula.test $d/other > $cwd/tmp/attr.new
99 )
100
101 diff -u $cwd/tmp/org $cwd/tmp/new
102 if [ $? -ne 0 ]; then
103    rstat=1
104 fi
105
106 diff $cwd/tmp/attr.org $cwd/tmp/attr.new
107 if [ $? -ne 0 ]; then
108    rstat=1
109 fi
110
111 check_two_logs
112 check_restore_diff
113
114 if [ x$REGRESS_DEBUG != x ]; then
115   rm -rf $d
116 fi
117
118 end_test