PageRenderTime 38ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/zfs-tests/tests/functional/acl/posix/posix_002_pos.ksh

http://github.com/zfsonlinux/zfs
Korn Shell | 76 lines | 25 code | 8 blank | 43 comment | 2 complexity | 61ba3fe43777d55527b0e3f7e50e5793 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception
  1. #!/bin/ksh -p
  2. #
  3. # CDDL HEADER START
  4. #
  5. # The contents of this file are subject to the terms of the
  6. # Common Development and Distribution License (the "License").
  7. # You may not use this file except in compliance with the License.
  8. #
  9. # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10. # or http://www.opensolaris.org/os/licensing.
  11. # See the License for the specific language governing permissions
  12. # and limitations under the License.
  13. #
  14. # When distributing Covered Code, include this CDDL HEADER in each
  15. # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16. # If applicable, add the following below this CDDL HEADER, with the
  17. # fields enclosed by brackets "[]" replaced with your own identifying
  18. # information: Portions Copyright [yyyy] [name of copyright owner]
  19. #
  20. # CDDL HEADER END
  21. #
  22. #
  23. # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. . $STF_SUITE/include/libtest.shlib
  27. . $STF_SUITE/tests/functional/acl/acl_common.kshlib
  28. #
  29. # Copyright (c) 2012 by Delphix. All rights reserved.
  30. #
  31. #
  32. # DESCRIPTION:
  33. # Verify that user can access file/directory if acltype=posixacl.
  34. #
  35. # STRATEGY:
  36. # 1. Test access to directory (mode=-wx)
  37. # a. Can create file in dir
  38. # b. Can't list directory
  39. #
  40. verify_runnable "both"
  41. log_assert "Verify acltype=posixacl works on directory"
  42. # Test access to DIRECTORY
  43. log_note "Testing access to DIRECTORY"
  44. log_must mkdir $TESTDIR/dir.0
  45. # Eliminate access by "other" including our test group,
  46. # we want access controlled only by the ACLs.
  47. log_must chmod 700 $TESTDIR/dir.0
  48. log_must setfacl -m g:$ZFS_ACL_STAFF_GROUP:wx $TESTDIR/dir.0
  49. # Confirm permissions
  50. ls -l $TESTDIR |grep "dir.0" |grep -q "drwx-wx---+"
  51. if [ "$?" -ne "0" ]; then
  52. msk=$(ls -l $TESTDIR |grep "dir.0" | awk '{print $1}')
  53. log_note "expected mask drwx-wx---+ but found $msk"
  54. log_fail "Expected permissions were not set."
  55. fi
  56. getfacl $TESTDIR/dir.0 2> /dev/null | egrep -q \
  57. "^group:$ZFS_ACL_STAFF_GROUP:-wx$"
  58. if [ "$?" -eq "0" ]; then
  59. # Should be able to create file in directory
  60. log_must user_run $ZFS_ACL_STAFF1 "touch $TESTDIR/dir.0/file.0"
  61. # Should NOT be able to list files in directory
  62. log_mustnot user_run $ZFS_ACL_STAFF1 "ls -l $TESTDIR/dir.0"
  63. log_pass "POSIX ACL mode works on directories"
  64. else
  65. acl=$(getfacl $TESTDIR/dir.0 2> /dev/null)
  66. log_note $acl
  67. log_fail "Group '$ZFS_ACL_STAFF_GROUP' does not have '-wx' as specified"
  68. fi