]> 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 #
18 # See if the right software is installed.
19 #
20 case `uname -s` in
21    Linux)
22       # Require getfacl to be installed
23       getfacl Makefile 2>&1 >/dev/null
24       if test  $? -ne 0; then
25         echo "$TestName skipped: getfacl not installed"
26         exit 0
27       fi
28
29       # Require attr to be installed
30       attr -l Makefile 2>&1 >/dev/null
31       if test $? -ne 0; then
32         echo "$TestName skipped: attr not installed"
33         exit 0
34       fi
35       ;;
36    Darwin)
37       ;;
38    SunOS)
39       ;;
40    *)
41       echo "Unsupported OS"
42       exit 0
43       ;;
44 esac
45
46 scripts/cleanup
47 scripts/copy-confs
48
49 #
50 # Zap out any schedule in default conf file so that
51 #  it doesn't start during our test
52 #
53 outf="tmp/sed_tmp"
54 echo "s%  Schedule =%# Schedule =%g" > $outf
55 echo "s/Options {/Options { aclsupport=yes; xattrsupport = yes/" >> $outf
56 cp ${cwd}/bin/bacula-dir.conf  $cwd/tmp/1
57 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
58
59 d=${cwd}/build/acl
60
61 uid=`id -u`
62 rm -rf $d
63 mkdir $d
64 mkdir $d/testdir
65 cp ${cwd}/bin/bconsole $d
66
67 case `uname -s` in
68    Linux)
69       setfacl -m d:user:$uid:r-x $d/testdir
70       setfacl -m d:user:root:-wx $d/testdir
71       setfacl -m user:nobody:--- $d/testdir
72       setfacl -m user:nobody:--- $d/bconsole
73       setfacl -m group:nogroup:--x $d/bconsole
74       cp ${cwd}/bin/bconsole $d/testdir
75       cp ${cwd}/bin/bconsole $d/other
76       attr -s bacula.test -V rulez $d/other 2>/dev/null 1>/dev/null
77
78       ( cd $cwd/build
79         getfacl -R acl > $cwd/tmp/org
80         attr -g bacula.test $d/other > $cwd/tmp/attr.org
81       )
82       ;;
83    Darwin)
84       chmod +a "user:$uid allow read execute" $d/testdir
85       chmod +a "user:root allow write execute" $d/testdir
86       chmod +a "user:nobody deny read write execute" $d/testdir
87       chmod +a "user:nobody deny read write execute" $d/bconsole
88       chmod +a "group:nogroup allow execute" $d/bconsole
89       cp ${cwd}/bin/bconsole $d/testdir
90       cp ${cwd}/bin/bconsole $d/other
91       xattr -w  bacula.test "rulez" $d/other 2>/dev/null 1>/dev/null
92
93       ( cd $cwd/build
94         ls -lde -R acl > $cwd/tmp/org
95         xattr -p bacula.test $d/other > $cwd/tmp/attr.org
96       )
97       ;;
98    SunOS)
99       #
100       # See if we need to set ZFS or POSIX acls
101       #
102       df -F zfs $d > /dev/null 2>&1
103       if [ $? = 0 ]; then
104          chmod A+user:$uid:rx:allow $d/testdir
105          chmod A+user:root:wx:allow $d/testdir
106          chmod A+user:nobody:rwx:deny $d/testdir
107          chmod A+user:nobody:rwx:deny $d/bconsole
108          chmod A+group:nogroup:x:allow $d/bconsole
109       else
110          chmod A+user:$uid:r-x $d/testdir
111          chmod A+user:root:-wx $d/testdir
112          chmod A+user:nobody:--- $d/testdir
113          chmod A+user:nobody:--- $d/bconsole
114          chmod A+group:nogroup:--x $d/bconsole
115       fi
116       runat $d/other 'cat > bacula.test' << EOF
117 rulez
118 EOF
119       ( cd $cwd/build
120         ls -ldv -R acl > $cwd/tmp/org
121         runat $d/other 'cat bacula.test' > $cwd/tmp/attr.org
122       )
123       ;;
124 esac
125
126 change_jobname BackupClient1 $JobName
127 start_test
128
129 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
130 @$out /dev/null
131 messages
132 @$out ${cwd}/tmp/log1.out
133 label volume=TestVolume001 storage=File pool=Default
134 setdebug level=400 trace=1 client
135 setdebug level=300 trace=1 director
136 setdebug level=300 trace=1 storage
137 run job=$JobName yes
138 wait
139 messages
140 @# 
141 @# now do a restore
142 @#
143 @$out ${cwd}/tmp/log2.out  
144 restore where=${cwd}/tmp/bacula-restores select all done
145 yes
146 wait
147 messages
148 quit
149 END_OF_DATA
150
151 run_bacula
152 check_for_zombie_jobs storage=File
153 stop_bacula
154
155 case `uname -s` in
156    Linux)
157       ( cd $cwd/tmp/bacula-restores/$cwd/build
158         getfacl -R acl > $cwd/tmp/new
159         attr -g bacula.test $d/other > $cwd/tmp/attr.new
160       )
161       ;;
162    Darwin)
163       ( cd $cwd/tmp/bacula-restores/$cwd/build
164         ls -lde -R acl > $cwd/tmp/new
165         xattr -p bacula.test $d/other > $cwd/tmp/attr.new
166       )
167       ;;
168    SunOS)
169       ( cd $cwd/tmp/bacula-restores/$cwd/build
170         ls -ldv -R acl > $cwd/tmp/new
171         runat $d/other 'cat bacula.test' > $cwd/tmp/attr.new
172       )
173       ;;
174 esac
175
176 diff -u $cwd/tmp/org $cwd/tmp/new
177 if [ $? -ne 0 ]; then
178    rstat=1
179 fi
180
181 diff $cwd/tmp/attr.org $cwd/tmp/attr.new
182 if [ $? -ne 0 ]; then
183    rstat=1
184 fi
185
186 check_two_logs
187 check_restore_diff
188
189 if [ x$REGRESS_DEBUG != x ]; then
190   rm -rf $d
191 fi
192
193 end_test