1f9693befSMartin Matuska#!/bin/ksh -p 2f9693befSMartin Matuska# 3f9693befSMartin Matuska# CDDL HEADER START 4f9693befSMartin Matuska# 5f9693befSMartin Matuska# The contents of this file are subject to the terms of the 6f9693befSMartin Matuska# Common Development and Distribution License (the "License"). 7f9693befSMartin Matuska# You may not use this file except in compliance with the License. 8f9693befSMartin Matuska# 9f9693befSMartin Matuska# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*271171e0SMartin Matuska# or https://opensource.org/licenses/CDDL-1.0. 11f9693befSMartin Matuska# See the License for the specific language governing permissions 12f9693befSMartin Matuska# and limitations under the License. 13f9693befSMartin Matuska# 14f9693befSMartin Matuska# When distributing Covered Code, include this CDDL HEADER in each 15f9693befSMartin Matuska# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16f9693befSMartin Matuska# If applicable, add the following below this CDDL HEADER, with the 17f9693befSMartin Matuska# fields enclosed by brackets "[]" replaced with your own identifying 18f9693befSMartin Matuska# information: Portions Copyright [yyyy] [name of copyright owner] 19f9693befSMartin Matuska# 20f9693befSMartin Matuska# CDDL HEADER END 21f9693befSMartin Matuska# 22f9693befSMartin Matuska 23f9693befSMartin Matuska# 24f9693befSMartin Matuska# Portions Copyright 2021 iXsystems, Inc. 25f9693befSMartin Matuska# 26f9693befSMartin Matuska 27f9693befSMartin Matuska. $STF_SUITE/include/libtest.shlib 28f9693befSMartin Matuska. $STF_SUITE/tests/functional/acl/acl_common.kshlib 29f9693befSMartin Matuska 30f9693befSMartin Matuska# 31f9693befSMartin Matuska# DESCRIPTION: 32f9693befSMartin Matuska# Verify that POSIX mode bits function correctly. 33f9693befSMartin Matuska# 34f9693befSMartin Matuska# These tests are incomplete and will be added to over time. 35f9693befSMartin Matuska# 36f9693befSMartin Matuska# NOTE: Creating directory entries behaves differently between platforms. 37f9693befSMartin Matuska# The parent directory's group is used on FreeBSD, while the effective 38f9693befSMartin Matuska# group is used on Linux. We chown to the effective group when creating 39f9693befSMartin Matuska# directories and files in these tests to achieve consistency across all 40f9693befSMartin Matuska# platforms. 41f9693befSMartin Matuska# 42f9693befSMartin Matuska# STRATEGY: 43f9693befSMartin Matuska# 1. Sanity check the POSIX mode test on tmpfs 44f9693befSMartin Matuska# 2. Test POSIX mode bits on ZFS 45f9693befSMartin Matuska# 46f9693befSMartin Matuska 47f9693befSMartin Matuskaverify_runnable "both" 48f9693befSMartin Matuska 49f9693befSMartin Matuskafunction cleanup 50f9693befSMartin Matuska{ 51f9693befSMartin Matuska umount -f $tmpdir 52f9693befSMartin Matuska rm -rf $tmpdir $TESTDIR/dir 53f9693befSMartin Matuska} 54f9693befSMartin Matuska 55f9693befSMartin Matuskalog_assert "Verify POSIX mode bits function correctly" 56f9693befSMartin Matuskalog_onexit cleanup 57f9693befSMartin Matuska 58f9693befSMartin Matuskaowner=$ZFS_ACL_STAFF1 59f9693befSMartin Matuskaother=$ZFS_ACL_STAFF2 60f9693befSMartin Matuskagroup=$ZFS_ACL_STAFF_GROUP 61f9693befSMartin Matuskaif is_linux; then 62f9693befSMartin Matuska wheel=root 63f9693befSMartin Matuskaelse 64f9693befSMartin Matuska wheel=wheel 65f9693befSMartin Matuskafi 66f9693befSMartin Matuska 67f9693befSMartin Matuskafunction test_posix_mode # base 68f9693befSMartin Matuska{ 69f9693befSMartin Matuska typeset base=$1 70f9693befSMartin Matuska typeset dir=$base/dir 71f9693befSMartin Matuska typeset file=$dir/file 72f9693befSMartin Matuska 73f9693befSMartin Matuska # dir owned by root 74f9693befSMartin Matuska log_must mkdir $dir 75f9693befSMartin Matuska log_must chown :$wheel $dir 76f9693befSMartin Matuska log_must chmod 007 $dir 77f9693befSMartin Matuska 78f9693befSMartin Matuska # file owned by root 79f9693befSMartin Matuska log_must touch $file 80f9693befSMartin Matuska log_must chown :$wheel $file 81f9693befSMartin Matuska log_must ls -la $dir 82f9693befSMartin Matuska log_must rm $file 83f9693befSMartin Matuska 84f9693befSMartin Matuska log_must touch $file 85f9693befSMartin Matuska log_must chown :$wheel $file 86f9693befSMartin Matuska log_must user_run $other rm $file 87f9693befSMartin Matuska 88f9693befSMartin Matuska # file owned by user 89f9693befSMartin Matuska log_must user_run $owner touch $file 90f9693befSMartin Matuska log_must chown :$group $file 91f9693befSMartin Matuska log_must ls -la $dir 92f9693befSMartin Matuska log_must user_run $owner rm $file 93f9693befSMartin Matuska 94f9693befSMartin Matuska log_must user_run $owner touch $file 95f9693befSMartin Matuska log_must chown :$group $file 96f9693befSMartin Matuska log_must user_run $other rm $file 97f9693befSMartin Matuska 98f9693befSMartin Matuska log_must user_run $owner touch $file 99f9693befSMartin Matuska log_must chown :$group $file 100f9693befSMartin Matuska log_must rm $file 101f9693befSMartin Matuska 102f9693befSMartin Matuska log_must rm -rf $dir 103f9693befSMartin Matuska 104f9693befSMartin Matuska # dir owned by user 105f9693befSMartin Matuska log_must user_run $owner mkdir $dir 106f9693befSMartin Matuska log_must chown :$group $dir 107f9693befSMartin Matuska log_must user_run $owner chmod 007 $dir 108f9693befSMartin Matuska 109f9693befSMartin Matuska # file owned by root 110f9693befSMartin Matuska log_must touch $file 111f9693befSMartin Matuska log_must chown :$wheel $file 112f9693befSMartin Matuska log_must ls -la $dir 113f9693befSMartin Matuska log_must rm $file 114f9693befSMartin Matuska 115f9693befSMartin Matuska log_must touch $file 116f9693befSMartin Matuska log_must chown :$wheel $file 117f9693befSMartin Matuska log_mustnot user_run $other rm $file 118f9693befSMartin Matuska log_must rm $file 119f9693befSMartin Matuska 120f9693befSMartin Matuska # file owned by user 121f9693befSMartin Matuska log_mustnot user_run $owner touch $file 122f9693befSMartin Matuska log_must touch $file 123f9693befSMartin Matuska log_must chown $owner:$group $file 124f9693befSMartin Matuska log_must ls -la $dir 125f9693befSMartin Matuska log_mustnot user_run $owner rm $file 126f9693befSMartin Matuska log_mustnot user_run $other rm $file 127f9693befSMartin Matuska log_must rm $file 128f9693befSMartin Matuska 129f9693befSMartin Matuska log_must rm -rf $dir 130f9693befSMartin Matuska} 131f9693befSMartin Matuska 132f9693befSMartin Matuska# Sanity check on tmpfs first 133f9693befSMartin Matuskatmpdir=$(TMPDIR=$TEST_BASE_DIR mktemp -d) 134f9693befSMartin Matuskalog_must mount -t tmpfs tmp $tmpdir 135f9693befSMartin Matuskalog_must chmod 777 $tmpdir 136f9693befSMartin Matuska 137f9693befSMartin Matuskatest_posix_mode $tmpdir 138f9693befSMartin Matuska 139f9693befSMartin Matuskalog_must umount $tmpdir 140f9693befSMartin Matuskalog_must rmdir $tmpdir 141f9693befSMartin Matuska 142f9693befSMartin Matuska# Verify ZFS 143f9693befSMartin Matuskatest_posix_mode $TESTDIR 144f9693befSMartin Matuska 145f9693befSMartin Matuskalog_pass "POSIX mode bits function correctly" 146