PageRenderTime 47ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/acl/nontrivial/zfs_acl_cp_002_pos.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 121 lines | 42 code | 18 blank | 61 comment | 7 complexity | eac17f51c913756adf8feeeead5c9aa5 MD5 | raw file
  1. #!/usr/local/bin/ksh93 -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. # $FreeBSD$
  23. #
  24. # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
  25. # Use is subject to license terms.
  26. #
  27. # ident "@(#)zfs_acl_cp_002_pos.ksh 1.2 07/01/09 SMI"
  28. #
  29. . $STF_SUITE/tests/acl/acl_common.kshlib
  30. ################################################################################
  31. #
  32. # __stc_assertion_start
  33. #
  34. # ID: zfs_acl_cp_002_pos
  35. #
  36. # DESCRIPTION:
  37. # Verify that '/bin/cp [-p@]' supports ZFS ACL & xattrs
  38. #
  39. # STRATEGY:
  40. # 1. Create file and directory in zfs filesystem
  41. # 2. Set special ACE to the file and directory
  42. # 3. Create xattr of the file and directory
  43. # 4. Copy the file/directory within and across zfs file system
  44. # 5. Verify that the ACL & xattrs of the file/directroy is not changed,
  45. # when you are inserting an ACL with user: or group: entry on the top.
  46. # (abstractions entry are treated special, since they represent the
  47. # traditional permission bit mapping.)
  48. #
  49. # TESTABILITY: explicit
  50. #
  51. # TEST_AUTOMATION_LEVEL: automated
  52. #
  53. # CODING_STATUS: COMPLETED (2005-10-11)
  54. #
  55. # __stc_assertion_end
  56. #
  57. ################################################################################
  58. verify_runnable "both"
  59. function cleanup
  60. {
  61. if datasetexists $TESTPOOL/$TESTFS1; then
  62. log_must $ZFS destroy -f $TESTPOOL/$TESTFS1
  63. fi
  64. [[ -d $TESTDIR1 ]] && log_must $RM -rf $TESTDIR1
  65. [[ -d $TESTDIR ]] && log_must $RM -rf $TESTDIR/*
  66. }
  67. log_assert "Verify that '$CP [-p]' supports ZFS ACLs."
  68. log_onexit cleanup
  69. test_requires RUNAT ZFS_ACL ZFS_XATTR
  70. log_note "Create the second zfs file system: $TESTPOOL/$TESTFS1."
  71. log_must $ZFS create $TESTPOOL/$TESTFS1
  72. log_must $ZFS set mountpoint=$TESTDIR1 $TESTPOOL/$TESTFS1
  73. log_must $ZFS set aclmode=passthrough $TESTPOOL/$TESTFS1
  74. log_must $CHMOD 777 $TESTDIR1
  75. # Define target directory.
  76. dstdir=$TESTDIR1/dstdir.${TESTCASE_ID}
  77. MYTESTFILE=$STF_SUITE/include/default.cfg
  78. for user in root $ZFS_ACL_STAFF1; do
  79. # Set the current user
  80. log_must set_cur_usr $user
  81. for obj in $testfile $testdir; do
  82. # Create source object and target directroy
  83. log_must usr_exec $TOUCH $testfile
  84. log_must usr_exec $MKDIR $testdir $dstdir
  85. log_must usr_exec $RUNAT $testfile $CP $MYTESTFILE attr.0
  86. log_must usr_exec $RUNAT $testdir $CP $MYTESTFILE attr.0
  87. # Add the new ACE on the head.
  88. log_must usr_exec $CHMOD \
  89. A0+user:$ZFS_ACL_OTHER1:read_acl:deny $obj
  90. cmd_str="$CP -p@"
  91. [[ -d $obj ]] && cmd_str="$CP -rp@"
  92. log_must usr_exec $cmd_str $obj $dstdir
  93. log_must usr_exec $cmd_str $obj $TESTDIR1
  94. for dir in $dstdir $TESTDIR1; do
  95. log_must compare_modes $obj $dir/${obj##*/}
  96. log_must compare_acls $obj $dir/${obj##*/}
  97. log_must compare_xattrs $obj $dir/${obj##*/}
  98. done
  99. # Delete all the test file and directory
  100. log_must usr_exec $RM -rf $TESTDIR/* $TESTDIR1/*
  101. done
  102. done
  103. log_pass "'$CP [-p@]' succeeds to support ZFS ACLs."