#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
# Copyright 2016 Nexenta Systems, Inc.
#
# DESCRIPTION:
# Verify chmod have correct behaviour to directory and file not inherited
# when filesystem has the different aclinherit setting
#
# STRATEGY:
# 1. Use both super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files inside of it.
# 3. For the following values of the aclinherity property, add ACEs with
# different inherit options to basedir:
# "discard", "noallow", "restricted" and "passthrough".
# 4. Create nested directories and files like the following.
#
# ofile
# odir
# chmod --> basedir -|
# |_ nfile1
# |_ ndir1 _
# |_ nfile2
# |_ ndir2 _
# |_ nfile3
# |_ ndir3
#
# 5. Verify non-inherited directories and files have the correct access
# control capability.
verify_runnable "both"
function cleanup
{
}
log_assert "Verify different inherit options combined with different" \
"aclinherit property values"
# Define inherit flag
typeset aclinherit_flag=(discard noallow restricted passthrough)
typeset ace_prefix1="user:$ZFS_ACL_OTHER1"
typeset ace_prefix2="user:$ZFS_ACL_OTHER2"
# Define the base directory and file
# Define the files and directories will be created after chmod
# Verify all the node have expected correct access control
# According to inherited flag, verify subdirectories and files within it has
# correct inherited access control.
{
# Define the nodes which will be affected by inherit.
typeset non_inherit_nodes=""
typeset inherit=$1
typeset obj=$2
typeset str=$3
typeset inherit_type
typeset str1="/inherit_only/inherited:"
typeset str2="/inherited:"
# count: the ACE item to fetch
# passcnt: counter, if it achieves to maxaces,
# then no additional ACE should apply.
# isinherit: indicate if the current target is in the inherit list.
typeset -i count=0 pass=0 passcnt=0 isinherit=0 no_propagate=0
# Get the inherit type/object_flag and non-inherited nodes.
inherit_type="both"
fi
inherit_type="directory"
fi
else
inherit_type="file"
fi
fi
else
fi
i=0
count=0
passcnt=0
typeset expacl
else
fi
((i = i + 1))
continue
fi
;;
break
;;
esac
((i = i + 1))
continue
fi
if [[ -d $node ]]; then
# Verify ACEs for subdirectory
# Directory should have
# "inherit_only" appended
else
fi
fi
if [[ $no_propagate == 0 ]]; then
"expected: $expacl"
fi
else
# Compare if directory has trivial ACL
if [[ $? -ne 0 ]]; then
log_fail "unexpected ACE:"
fi
fi
# Verify ACE's for nested file
elif [[ -f $node ]]; then
if [[ $? -ne 0 ]]; then
fi
fi
((i = i + 1))
done
# If there are no ACEs to be checked, compare the trivial ones.
if [[ -d $node ]]; then
elif [[ -f $node ]]; then
fi
if [[ $? -ne 0 ]]; then
fi
fi
done
}
((${#str} != 0)) && inh_opt=$inh_opt/$str
# Prepare 4 ACES, which should include:
# deny -> to verify "noallow"
# write_acl/write_owner -> to verify "restricted"
acl0="${ace_prefix1}:read_xattr/write_acl"
acl0="${acl0}/write_owner:${inh_opt}:deny"
acl1="${ace_prefix2}:read_xattr/write_acl"
acl1="${acl1}/write_owner:${inh_opt}:allow"
acl2="${ace_prefix1}:read_xattr:${inh_opt}:deny"
acl3="${ace_prefix2}:read_xattr:${inh_opt}:allow"
# The ACEs filtered by write_acl/write_owner
acls1="${ace_prefix2}:read_xattr"
acls1="${acls1}:${inh_opt}:allow"
#
# for comparison.
#
i=3
while ((i >= 0)); do
((i = i - 1))
done
done
done
done
done
"aclinherit property values"