]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/acl-xattr-test
regress: tweak speed-test
[bacula/bacula] / regress / tests / acl-xattr-test
index a5bda93b90d91bbf231a1171f669bde26065a8b0..c27e2fd2f142131c4d811786e01691a2ca30054a 100755 (executable)
@@ -1,14 +1,28 @@
 #!/bin/sh
 #
-# Run a backup of the Bacula build directory with some acls
-#   then restore it.
+# Run a backup of the Bacula build directory with some acls then restore it.
 #
-# Your filesystem must be mounted with the acl option (mount -o remount,acl,user_xattr /tmp)
-# on ubuntu, the attr package must be installed
+# For Linux:
+#    Your filesystem must be mounted with the acl option (mount -o remount,acl,user_xattr /tmp)
+#    on ubuntu, the attr package must be installed
 #
-# For this script to work, you will also need a number of acl packages loaded
-#   not default on Debian derivatives: 
-#   apt-get install acl libacl1 libacl1-dev attr
+#    For this script to work, you will also need a number of acl packages loaded
+#    not default on Debian derivatives: 
+#       apt-get install acl libacl1 libacl1-dev attr
+#
+# For OSX and Solaris:
+#
+#    Defaults should be ok
+#
+# For FreeBSD:
+#
+#    Your filesystem must have acls enabled and needs to be mounted with acls.
+#       tunefs -a enable <device>
+#       acls mountoption in /etc/fstab
+#
+# For NetBSD:
+#
+#    Defaults should be ok (As NetBSD doesn't support native acls we skip that test).
 #
 TestName="acl-xattr-test"
 JobName=backup
@@ -26,10 +40,10 @@ case `uname -s` in
         exit 0
       fi
 
-      # Require attr to be installed
-      attr -l Makefile 2>&1 >/dev/null
+      # Require getfattr to be installed
+      getfattr -d Makefile 2>&1 >/dev/null
       if test $? -ne 0; then
-        echo "$TestName skipped: attr not installed"
+        echo "$TestName skipped: getfattr not installed"
         exit 0
       fi
       ;;
@@ -37,6 +51,29 @@ case `uname -s` in
       ;;
    SunOS)
       ;;
+   FreeBSD)
+      # Require getfacl to be installed
+      getfacl Makefile 2>&1 >/dev/null
+      if test  $? -ne 0; then
+        echo "$TestName skipped: getfacl not installed"
+        exit 0
+      fi
+
+      # Require lsextattr to be installed
+      lsextattr user Makefile 2>&1 >/dev/null
+      if test $? -ne 0; then
+        echo "$TestName skipped: lsextattr not installed"
+        exit 0
+      fi
+      ;;
+   NetBSD)
+      # Require lsextattr to be installed
+      lsextattr user Makefile 2>&1 >/dev/null
+      if test $? -ne 0; then
+        echo "$TestName skipped: lsextattr not installed"
+        exit 0
+      fi
+      ;;
    *)
       echo "Unsupported OS"
       exit 0
@@ -73,11 +110,11 @@ case `uname -s` in
       setfacl -m group:nogroup:--x $d/bconsole
       cp ${cwd}/bin/bconsole $d/acl-dir
       cp ${cwd}/bin/bconsole $d/other
-      attr -s bacula.test -V rulez $d/other 2>/dev/null 1>/dev/null
+      setfattr -h -n user.bacula.test -v rulez $d/other 2>/dev/null 1>/dev/null
 
       ( cd $cwd/build
         getfacl -R acl > $cwd/tmp/org
-        attr -g bacula.test $d/other > $cwd/tmp/attr.org
+        getfattr -h -n user.bacula.test $d/other > $cwd/tmp/attr.org
       )
       ;;
    Darwin)
@@ -101,24 +138,52 @@ case `uname -s` in
       #
       df -F zfs $d > /dev/null 2>&1
       if [ $? = 0 ]; then
-         chmod A+user:$uid:rx:allow $d/acl-dir
-         chmod A+user:root:wx:allow $d/acl-dir
-         chmod A+user:nobody:rwx:deny $d/acl-dir
-         chmod A+user:nobody:rwx:deny $d/bconsole
-         chmod A+group:nogroup:x:allow $d/bconsole
+         /bin/chmod A+user:$uid:rx:allow $d/acl-dir
+         /bin/chmod A+user:root:wx:allow $d/acl-dir
+         /bin/chmod A+user:nobody:rwx:deny $d/acl-dir
+         /bin/chmod A+user:nobody:rwx:deny $d/bconsole
+         /bin/chmod A+group:nogroup:x:allow $d/bconsole
       else
-         chmod A+user:$uid:r-x $d/acl-dir
-         chmod A+user:root:-wx $d/acl-dir
-         chmod A+user:nobody:--- $d/acl-dir
-         chmod A+user:nobody:--- $d/bconsole
-         chmod A+group:nogroup:--x $d/bconsole
+         /bin/chmod A+user:$uid:r-x $d/acl-dir
+         /bin/chmod A+user:root:-wx $d/acl-dir
+         /bin/chmod A+user:nobody:--- $d/acl-dir
+         /bin/chmod A+user:nobody:--- $d/bconsole
+         /bin/chmod A+group:nogroup:--x $d/bconsole
       fi
-      runat $d/other 'cat > bacula.test' << EOF
+      cp ${cwd}/bin/bconsole $d/other
+      /bin/runat $d/other 'cat > bacula.test' << EOF
 rulez
 EOF
       ( cd $cwd/build
-        ls -ldv -R acl > $cwd/tmp/org
-        runat $d/other 'cat bacula.test' > $cwd/tmp/attr.org
+        /bin/ls -ldv -R acl > $cwd/tmp/org
+        /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.org
+      )
+      ;;
+   FreeBSD)
+      setfacl -m d:user:$uid:r-x $d/acl-dir
+      setfacl -m d:user:root:-wx $d/acl-dir
+      setfacl -m user:nobody:--- $d/acl-dir
+      setfacl -m user:nobody:--- $d/bconsole
+      setfacl -m group:nogroup:--x $d/bconsole
+      cp ${cwd}/bin/bconsole $d/acl-dir
+      cp ${cwd}/bin/bconsole $d/other
+      setextattr user bacula.test rulez $d/other 2>/dev/null 1>/dev/null
+
+      ( cd $cwd/build
+        for file in acl/*
+        do
+           getfacl $file
+        done > $cwd/tmp/org
+        getextattr user bacula.test $d/other > $cwd/tmp/attr.org
+      )
+      ;;
+   NetBSD)
+      cp ${cwd}/bin/bconsole $d/other
+      setextattr user bacula.test rulez $d/other 2>/dev/null 1>/dev/null
+
+      ( cd $cwd/build
+        cp /dev/null $cwd/tmp/org
+        getextattr user bacula.test $d/other > $cwd/tmp/attr.org
       )
       ;;
 esac
@@ -130,7 +195,7 @@ cat <<END_OF_DATA >${cwd}/tmp/bconcmds
 @$out /dev/null
 messages
 @$out ${cwd}/tmp/log1.out
-label volume=TestVolume001 storage=File pool=Default
+label volume=TestVolume001 storage=File pool=File
 setdebug level=400 trace=1 client
 setdebug level=300 trace=1 director
 setdebug level=300 trace=1 storage
@@ -156,7 +221,7 @@ case `uname -s` in
    Linux)
       ( cd $cwd/tmp/bacula-restores/$cwd/build
         getfacl -R acl > $cwd/tmp/new
-        attr -g bacula.test $d/other > $cwd/tmp/attr.new
+        getfattr -h -n user.bacula.test $d/other > $cwd/tmp/attr.new
       )
       ;;
    Darwin)
@@ -167,8 +232,23 @@ case `uname -s` in
       ;;
    SunOS)
       ( cd $cwd/tmp/bacula-restores/$cwd/build
-        ls -ldv -R acl > $cwd/tmp/new
-        runat $d/other 'cat bacula.test' > $cwd/tmp/attr.new
+        /bin/ls -ldv -R acl > $cwd/tmp/new
+        /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.new
+      )
+      ;;
+   FreeBSD)
+      ( cd $cwd/tmp/bacula-restores/$cwd/build
+        for file in acl/*
+        do
+           getfacl $file
+        done > $cwd/tmp/new
+        getextattr user bacula.test $d/other > $cwd/tmp/attr.new
+      )
+      ;;
+   NetBSD)
+      ( cd $cwd/tmp/bacula-restores/$cwd/build
+        cp /dev/null $cwd/tmp/new
+        getextattr user bacula.test $d/other > $cwd/tmp/attr.new
       )
       ;;
 esac