X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-copy-file.sh;h=7d6d687f7cc8b97fd3c84c8720e2078c66482821;hb=80a029602f5b2707ca8d2487843ecb9e0df74a6a;hp=64901c8c4d40715dc699e71f20d5cd9088e04329;hpb=eb38f4544d905f75f1718c2ab4ab19e468c88315;p=gnulib.git diff --git a/tests/test-copy-file.sh b/tests/test-copy-file.sh index 64901c8c4..7d6d687f7 100755 --- a/tests/test-copy-file.sh +++ b/tests/test-copy-file.sh @@ -54,8 +54,8 @@ cd "$builddir" || # Classification of the platform according to the programs available for # manipulating ACLs. # Possible values are: - # linux, cygwin, freebsd, solaris, hpux, osf1, aix, macosx, irix, none. - # TODO: Support also native Win32 platforms (mingw). + # linux, cygwin, freebsd, solaris, hpux, hpuxjfs, osf1, aix, macosx, irix, none. + # TODO: Support also native Windows platforms (mingw). acl_flavor=none if (getfacl tmpfile0 >/dev/null) 2>/dev/null; then # Platforms with the getfacl and setfacl programs. @@ -79,14 +79,26 @@ cd "$builddir" || fi fi else - if (lsacl tmpfile0 >/dev/null) 2>/dev/null; then + if (lsacl / >/dev/null) 2>/dev/null; then # Platforms with the lsacl and chacl programs. # HP-UX, sometimes also IRIX. - acl_flavor=hpux + if (getacl tmpfile0 >/dev/null) 2>/dev/null; then + # HP-UX 11.11 or newer. + acl_flavor=hpuxjfs + else + # HP-UX 11.00. + acl_flavor=hpux + fi else if (getacl tmpfile0 >/dev/null) 2>/dev/null; then - # Tru64. - acl_flavor=osf1 + # Tru64, NonStop Kernel. + if (getacl -m tmpfile0 >/dev/null) 2>/dev/null; then + # Tru64. + acl_flavor=osf1 + else + # NonStop Kernel. + acl_flavor=nsk + fi else if (aclget tmpfile0 >/dev/null) 2>/dev/null; then # AIX. @@ -126,7 +138,20 @@ cd "$builddir" || cmp tmpaclout1 tmpaclout2 > /dev/null } ;; - osf1) + hpuxjfs) + func_test_same_acls () + { + { lsacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + lsacl "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } && + { getacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 + getacl "$2" | sed -e "s/$2/FILENAME/g" > tmpaclout2 + cmp tmpaclout1 tmpaclout2 > /dev/null + } + } + ;; + osf1 | nsk) func_test_same_acls () { getacl "$1" | sed -e "s/$1/FILENAME/g" > tmpaclout1 @@ -171,25 +196,33 @@ cd "$builddir" || # on both. func_test_copy () { - "$builddir"/test-copy-file${EXEEXT} "$1" "$2" || exit 1 - "$builddir"/test-copy-file-sameacls${EXEEXT} "$1" "$2" || exit 1 - func_test_same_acls "$1" "$2" || exit 1 + "$builddir"/test-copy-file${EXEEXT} "$1" "$2" || exit 1 + if test "$USE_ACL" != 0; then + "$builddir"/test-sameacls${EXEEXT} "$1" "$2" || exit 1 + func_test_same_acls "$1" "$2" || exit 1 + fi } func_test_copy tmpfile0 tmpfile1 - if test $acl_flavor != none; then + if test "$USE_ACL" != 0 && test $acl_flavor != none; then + # A POSIX compliant 'id' program. + if test -f /usr/xpg4/bin/id; then + ID=/usr/xpg4/bin/id + else + ID=id + fi # Use a user and group id different from the current one, to avoid # redundant/ambiguous ACLs. - myuid=`id -u` - mygid=`id -g` + myuid=`$ID -u` + mygid=`$ID -g` auid=1 if test "$auid" = "$myuid"; then auid=2; fi agid=1 if test "$agid" = "$mygid"; then agid=2; fi case $acl_flavor in - linux | cygwin | freebsd | solaris) + linux | freebsd | solaris) # Set an ACL for a user. setfacl -m user:$auid:1 tmpfile0 @@ -221,7 +254,7 @@ cd "$builddir" || # Remove the ACL for other. case $acl_flavor in - linux) ;; # impossible + linux | solaris) ;; # impossible freebsd) setfacl -x other::4 tmpfile0 ;; *) setfacl -d other:4 tmpfile0 ;; esac @@ -263,6 +296,43 @@ cd "$builddir" || ;; + cygwin) + + # Set an ACL for a group. + setfacl -m group:0:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for other. + setfacl -m other:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the group. + setfacl -d group:0 tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for other. + setfacl -d other:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile6 + + # Delete all optional ACLs. + setfacl -s user::6,group::0,other:0 tmpfile0 + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + getfacl tmpfile9 | setfacl -f - tmpfile0 + rm -f tmpfile9 + + func_test_copy tmpfile0 tmpfile9 + + ;; + hpux) # Set an ACL for a user. @@ -309,6 +379,62 @@ cd "$builddir" || ;; + hpuxjfs) + + # Set an ACL for a user. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}($auid.%,--x)" tmpfile0 \ + || setacl -m user:$auid:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}(%.$agid,r--)" tmpfile0 \ + || setacl -m group:$agid:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + orig=`lsacl tmpfile0 | sed -e 's/ tmpfile0$//'` + chacl -r "${orig}(%.%,r--)" tmpfile0 \ + || setacl -m other:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + chacl -d "($auid.%,--x)" tmpfile0 \ + || setacl -d user:$auid tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for the group. + chacl -d "(%.$agid,r--)" tmpfile0 \ + || setacl -d group:$agid tmpfile0 + + func_test_copy tmpfile0 tmpfile6 + + # Delete all optional ACLs. + chacl -z tmpfile0 \ + || { setacl -m user:$auid:1 tmpfile0 + setacl -s user::6,group::0,class:7,other:0 tmpfile0 + } + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + orig=`lsacl tmpfile9 | sed -e 's/ tmpfile9$//'` + getacl tmpfile9 > tmpaclout0 + rm -f tmpfile9 + chacl -r "${orig}" tmpfile0 \ + || setacl -f tmpaclout0 tmpfile0 + + func_test_copy tmpfile0 tmpfile9 + + ;; + osf1) # Set an ACL for a user. @@ -360,6 +486,50 @@ cd "$builddir" || ;; + nsk) + + # Set an ACL for a user. + setacl -m user:$auid:1 tmpfile0 + + func_test_copy tmpfile0 tmpfile2 + + # Set an ACL for a group. + setacl -m group:$agid:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile3 + + # Set an ACL for other. + setacl -m other:4 tmpfile0 + + func_test_copy tmpfile0 tmpfile4 + + # Remove the ACL for the user. + setacl -d user:$auid tmpfile0 + + func_test_copy tmpfile0 tmpfile5 + + # Remove the ACL for the group. + setacl -d group:$agid tmpfile0 + + func_test_copy tmpfile0 tmpfile6 + + # Delete all optional ACLs. + setacl -m user:$auid:1 tmpfile0 + setacl -s user::6,group::0,class:7,other:0 tmpfile0 + + func_test_copy tmpfile0 tmpfile8 + + # Copy ACLs from a file that has no ACLs. + echo > tmpfile9 + chmod a+x tmpfile9 + getacl tmpfile9 > tmpaclout0 + setacl -f tmpaclout0 tmpfile0 + rm -f tmpfile9 + + func_test_copy tmpfile0 tmpfile9 + + ;; + aix) # Set an ACL for a user. @@ -447,32 +617,27 @@ cd "$builddir" || irix) # Set an ACL for a user. - /sbin/chacl user:$auid:--x tmpfile0 + /sbin/chacl user::rw-,group::---,other::---,user:$auid:--x tmpfile0 func_test_copy tmpfile0 tmpfile2 # Set an ACL for a group. - /sbin/chacl user:$auid:--x,group:$agid:r-- tmpfile0 + /sbin/chacl user::rw-,group::---,other::---,user:$auid:--x,group:$agid:r-- tmpfile0 func_test_copy tmpfile0 tmpfile3 # Set an ACL for other. - /sbin/chacl user:$auid:--x,group:$agid:r--,other::r-- tmpfile0 + /sbin/chacl user::rw-,group::---,user:$auid:--x,group:$agid:r--,other::r-- tmpfile0 func_test_copy tmpfile0 tmpfile4 # Remove the ACL for the user. - /sbin/chacl group:$agid:r--,other::r-- tmpfile0 + /sbin/chacl user::rw-,group::---,group:$agid:r--,other::r-- tmpfile0 func_test_copy tmpfile0 tmpfile5 - # Remove the ACL for other. - /sbin/chacl group:$agid:r-- tmpfile0 - - func_test_copy tmpfile0 tmpfile6 - # Remove the ACL for the group. - /sbin/chacl , tmpfile0 + /sbin/chacl user::rw-,group::---,other::r-- tmpfile0 func_test_copy tmpfile0 tmpfile7