/tests/zfs-tests/tests/functional/delegate/zfs_allow_010_pos.ksh

https://github.com/adilger/zfs · Korn Shell · 194 lines · 115 code · 17 blank · 62 comment · 8 complexity · 67ee2b48dda052ce46f6dda7d0833d7b MD5 · raw file

  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 2007 Sun Microsystems, Inc. All rights reserved.
  24. # Use is subject to license terms.
  25. #
  26. #
  27. # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  28. #
  29. . $STF_SUITE/tests/functional/delegate/delegate_common.kshlib
  30. #
  31. # DESCRIPTION:
  32. # Scan the following permissions one by one to verify privileged user
  33. # has correct permission delegation in datasets.
  34. #
  35. # STRATEGY:
  36. # 1. Delegate all the permission one by one to user on dataset.
  37. # 2. Verify privileged user has correct permission without any other
  38. # permissions allowed.
  39. #
  40. verify_runnable "both"
  41. log_assert "Verify privileged user has correct permissions once which was "\
  42. "delegated to him in datasets"
  43. log_onexit restore_root_datasets
  44. if is_linux; then
  45. #
  46. # Results in Results in
  47. # Permission Filesystem Volume
  48. #
  49. # Removed for Linux:
  50. # - mount - mount(8) does not permit non-superuser mounts
  51. # - mountpoint - mount(8) does not permit non-superuser mounts
  52. # - canmount - mount(8) does not permit non-superuser mounts
  53. # - rename - mount(8) does not permit non-superuser mounts
  54. # - zoned - zones are not supported
  55. # - destroy - umount(8) does not permit non-superuser umounts
  56. # - sharenfs - sharing requires superuser privileges
  57. # - share - sharing requires superuser privileges
  58. # - readonly - mount(8) does not permit non-superuser remounts
  59. #
  60. set -A perms create true false \
  61. snapshot true true \
  62. send true true \
  63. allow true true \
  64. quota true false \
  65. reservation true true \
  66. dnodesize true false \
  67. recordsize true false \
  68. checksum true true \
  69. compression true true \
  70. atime true false \
  71. devices true false \
  72. exec true false \
  73. volsize false true \
  74. setuid true false \
  75. snapdir true false \
  76. userprop true true \
  77. aclinherit true false \
  78. rollback true true \
  79. clone true true \
  80. promote true true \
  81. xattr true false \
  82. receive true false
  83. elif is_freebsd; then
  84. # Results in Results in
  85. # Permission Filesystem Volume
  86. #
  87. # Removed for FreeBSD
  88. # - jailed - jailing requires superuser privileges
  89. # - sharenfs - sharing requires superuser privileges
  90. # - share - sharing requires superuser privileges
  91. # - xattr - Not supported on FreeBSD
  92. #
  93. set -A perms create true false \
  94. snapshot true true \
  95. mount true false \
  96. send true true \
  97. allow true true \
  98. quota true false \
  99. reservation true true \
  100. dnodesize true false \
  101. recordsize true false \
  102. mountpoint true false \
  103. checksum true true \
  104. compression true true \
  105. canmount true false \
  106. atime true false \
  107. devices true false \
  108. exec true false \
  109. volsize false true \
  110. setuid true false \
  111. readonly true true \
  112. snapdir true false \
  113. userprop true true \
  114. aclmode true false \
  115. aclinherit true false \
  116. rollback true true \
  117. clone true true \
  118. rename true true \
  119. promote true true \
  120. receive true false \
  121. destroy true true
  122. else
  123. set -A perms create true false \
  124. snapshot true true \
  125. mount true false \
  126. send true true \
  127. allow true true \
  128. quota true false \
  129. reservation true true \
  130. dnodesize true false \
  131. recordsize true false \
  132. mountpoint true false \
  133. checksum true true \
  134. compression true true \
  135. canmount true false \
  136. atime true false \
  137. devices true false \
  138. exec true false \
  139. volsize false true \
  140. setuid true false \
  141. readonly true true \
  142. snapdir true false \
  143. userprop true true \
  144. aclmode true false \
  145. aclinherit true false \
  146. rollback true true \
  147. clone true true \
  148. rename true true \
  149. promote true true \
  150. zoned true false \
  151. xattr true false \
  152. receive true false \
  153. destroy true true
  154. if is_global_zone; then
  155. typeset -i n=${#perms[@]}
  156. perms[((n))]="sharenfs"; perms[((n+1))]="true"; perms[((n+2))]="false"
  157. perms[((n+3))]="share"; perms[((n+4))]="true"; perms[((n+5))]="false"
  158. fi
  159. fi
  160. for dtst in $DATASETS; do
  161. typeset -i k=1
  162. typeset type=$(get_prop type $dtst)
  163. [[ $type == "volume" ]] && k=2
  164. typeset -i i=0
  165. while (( i < ${#perms[@]} )); do
  166. log_must zfs allow $STAFF1 ${perms[$i]} $dtst
  167. if [[ ${perms[((i+k))]} == "true" ]]; then
  168. log_must verify_perm $dtst ${perms[$i]} $STAFF1
  169. else
  170. log_must verify_noperm $dtst ${perms[$i]} $STAFF1
  171. fi
  172. log_must restore_root_datasets
  173. ((i += 3))
  174. done
  175. done
  176. log_pass "Verify privileged user has correct permissions " \
  177. "in datasets passed."