/tests/zfs-tests/tests/functional/history/history_009_pos.ksh

https://github.com/adilger/zfs · Korn Shell · 114 lines · 63 code · 12 blank · 39 comment · 1 complexity · 92fc2bcd6a3c3666d075c39006ec91e4 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/history/history_common.kshlib
  30. #
  31. # DESCRIPTION:
  32. # Verify the delegation internal history are correctly.
  33. #
  34. # STRATEGY:
  35. # 1. Create test group and user.
  36. # 2. Define permission sets and verify the internal history correctly.
  37. # 3. Separately verify the internal history above is correct.
  38. #
  39. verify_runnable "global"
  40. function cleanup
  41. {
  42. del_user $HIST_USER
  43. del_group $HIST_GROUP
  44. }
  45. log_assert "Verify delegated commands are logged in the pool history."
  46. log_onexit cleanup
  47. testfs=$TESTPOOL/$TESTFS
  48. # Create history test group and user and get user id and group id
  49. add_group $HIST_GROUP
  50. add_user $HIST_GROUP $HIST_USER
  51. # subcmd allow_options
  52. array=( "allow" "-s @basic snapshot"
  53. "allow" "-s @set @basic"
  54. "allow" "-c create"
  55. "unallow" "-c create"
  56. "allow" "-c @set"
  57. "unallow" "-c @set"
  58. "allow" "-l -u $HIST_USER snapshot"
  59. "allow" "-u $HIST_USER snapshot"
  60. "unallow" "-u $HIST_USER snapshot"
  61. "allow" "-l -u $HIST_USER @set"
  62. "allow" "-u $HIST_USER @set"
  63. "unallow" "-u $HIST_USER @set"
  64. "allow" "-d -u $HIST_USER snapshot"
  65. "allow" "-u $HIST_USER snapshot"
  66. "unallow" "-u $HIST_USER snapshot"
  67. "allow" "-d -u $HIST_USER @set"
  68. "allow" "-u $HIST_USER @set"
  69. "unallow" "-u $HIST_USER @set"
  70. "allow" "-l -g $HIST_GROUP snapshot"
  71. "allow" "-g $HIST_GROUP snapshot"
  72. "unallow" "-g $HIST_GROUP snapshot"
  73. "allow" "-l -g $HIST_GROUP @set"
  74. "allow" "-g $HIST_GROUP @set"
  75. "unallow" "-g $HIST_GROUP @set"
  76. "allow" "-d -g $HIST_GROUP snapshot"
  77. "allow" "-g $HIST_GROUP snapshot"
  78. "unallow" "-g $HIST_GROUP snapshot"
  79. "allow" "-d -g $HIST_GROUP @set"
  80. "allow" "-g $HIST_GROUP @set"
  81. "unallow" "-g $HIST_GROUP @set"
  82. "allow" "-l -e snapshot"
  83. "allow" "-e snapshot"
  84. "unallow" "-e snapshot"
  85. "allow" "-l -e @set"
  86. "allow" "-e @set"
  87. "unallow" "-e @set"
  88. "allow" "-d -e snapshot"
  89. "allow" "-e snapshot"
  90. "unallow" "-e snapshot"
  91. "allow" "-d -e @set"
  92. "allow" "-e @set"
  93. "unallow" "-e @set"
  94. )
  95. typeset -i i=0
  96. while ((i < ${#array[@]})); do
  97. subcmd=${array[$i]}
  98. options=${array[((i + 1))]}
  99. run_and_verify "zfs $subcmd $options $testfs" "-i"
  100. ((i += 2))
  101. done
  102. log_pass "Verify delegated commands are logged in the pool history."