PageRenderTime 401ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/sys/cddl/zfs/tests/acl/trivial/zfs_acl_cp_003_neg.ksh

https://bitbucket.org/freebsd/freebsd-base
Korn Shell | 138 lines | 79 code | 6 blank | 53 comment | 0 complexity | f270cfa8780ce1d96f26b9bb49c1eb47 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_003_neg.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_003_neg
  35. #
  36. # DESCRIPTION:
  37. # Verifies that cp will not be able to include file attribute when
  38. # attribute is unreadable (unless the user is root)
  39. #
  40. # STRATEGY:
  41. # 1. In directory A, create several files and add attribute files for them
  42. # 2. chmod all files'the attribute files to '000'.
  43. # 3. Implement 'cp -@p' to files.
  44. # 4. Verify attribute files are not existing for non-root user.
  45. #
  46. # TESTABILITY: explicit
  47. #
  48. # TEST_AUTOMATION_LEVEL: automated
  49. #
  50. # CODING_STATUS: COMPLETED (2006-06-01)
  51. #
  52. # __stc_assertion_end
  53. #
  54. ################################################################################
  55. verify_runnable "both"
  56. log_assert "Verifies that cp won't be able to include file attribute when " \
  57. "attribute is unreadable (except root)"
  58. log_onexit cleanup
  59. test_requires RUNAT ZFS_ACL ZFS_XATTR
  60. function test_unreadable_attr
  61. {
  62. typeset initfiles=$($LS -R $INI_DIR/*)
  63. typeset -i i=0
  64. while (( i < NUM_FILE )); do
  65. typeset f=$(getitem $i $initfiles)
  66. typeset -i j=0
  67. while (( j < NUM_ATTR )); do
  68. # chmod all the attribute files to '000'.
  69. usr_exec $RUNAT $f $CHMOD 000 attribute.$j
  70. (( j += 1 ))
  71. done
  72. #
  73. # Implement 'cp -@p' to the file whose attribute files
  74. # models are '000'.
  75. #
  76. usr_exec $CP -@p $f $TST_DIR > /dev/null 2>&1
  77. typeset testfiles=$($LS -R $TST_DIR/*)
  78. typeset tf=$(getitem $i $testfiles)
  79. typeset ls_attr=$(usr_exec $LS -@ $tf | \
  80. $AWK '{print substr($1, 11, 1)}')
  81. case $ZFS_ACL_CUR_USER in
  82. root)
  83. case $ls_attr in
  84. @)
  85. log_note "SUCCESS: root enable to cp attribute"\
  86. "when attribute files is unreadable"
  87. break ;;
  88. *)
  89. log_fail "root should enable to cp attribute " \
  90. "when attribute files is unreadable"
  91. break ;;
  92. esac
  93. ;;
  94. $ZFS_ACL_STAFF1)
  95. case $ls_attr in
  96. @)
  97. log_fail "non-root shouldn't enable to cp " \
  98. "attribute when attribute files is " \
  99. "unreadable."
  100. break ;;
  101. *)
  102. log_note "SUCCESS: non-root doesn't enable to "\
  103. "cp attribute when attribute files is "\
  104. "unreadable."
  105. break ;;
  106. esac
  107. ;;
  108. *)
  109. esac
  110. (( i += 1 ))
  111. done
  112. }
  113. for user in root $ZFS_ACL_STAFF1; do
  114. log_must set_cur_usr $user
  115. log_must create_files $TESTDIR
  116. test_unreadable_attr
  117. log_must cleanup
  118. done
  119. log_pass "'cp -@p' won't include file attribute passed."