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

https://github.com/adilger/zfs · Korn Shell · 96 lines · 35 code · 15 blank · 46 comment · 9 complexity · 61abb433d83f4660d3ed95713188bc8c 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 2009 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. # Verify option '-d' allow permission to the descendent datasets, and not
  33. # for this dataset itself.
  34. #
  35. # STRATEGY:
  36. # 1. Create descendent datasets of $ROOT_TESTFS
  37. # 2. Select user, group and everyone and set descendent permission
  38. # separately.
  39. # 3. Set descendent permissions to $ROOT_TESTFS or $ROOT_TESTVOL.
  40. # 4. Verify those permissions are allowed to $ROOT_TESTFS's
  41. # descendent dataset.
  42. # 5. Verify the permissions are not allowed to $ROOT_TESTFS or
  43. # $ROOT_TESTVOL.
  44. #
  45. verify_runnable "both"
  46. log_assert "Verify option '-d' allow permission to the descendent datasets."
  47. log_onexit restore_root_datasets
  48. childfs=$ROOT_TESTFS/childfs
  49. eval set -A dataset $DATASETS
  50. typeset perms="snapshot,reservation,compression,checksum,userprop"
  51. # Verify option '-d' only affect sub-datasets
  52. log_must zfs create $childfs
  53. for dtst in $DATASETS ; do
  54. log_must zfs allow -d $STAFF1 $perms $dtst
  55. log_must verify_noperm $dtst $perms $STAFF1
  56. if [[ $dtst == $ROOT_TESTFS ]]; then
  57. log_must verify_perm $childfs $perms $STAFF1
  58. fi
  59. done
  60. log_must restore_root_datasets
  61. # Verify option '-d + -g' affect group in sub-datasets.
  62. log_must zfs create $childfs
  63. for dtst in $DATASETS ; do
  64. log_must zfs allow -d -g $STAFF_GROUP $perms $dtst
  65. log_must verify_noperm $dtst $perms $STAFF2
  66. if [[ $dtst == $ROOT_TESTFS ]]; then
  67. log_must verify_perm $childfs $perms $STAFF2
  68. fi
  69. done
  70. log_must restore_root_datasets
  71. # Verify option '-d + -e' affect everyone in sub-datasets.
  72. log_must zfs create $childfs
  73. for dtst in $DATASETS ; do
  74. log_must zfs allow -d -e $perms $dtst
  75. log_must verify_noperm $dtst $perms $OTHER1 $OTHER2
  76. if [[ $dtst == $ROOT_TESTFS ]]; then
  77. log_must verify_perm $childfs $perms $OTHER1 $OTHER2
  78. fi
  79. done
  80. log_must restore_root_datasets
  81. log_pass "Verify option '-d' allow permission to the descendent datasets pass."