d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/acl/acl_common.kshlib
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/acl/cifs/cifs.kshlib
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Verify the user with write_attributes permission or
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# PRIV_FILE_OWNER privilege could set/clear DOS attributes.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# (Readonly, Hidden, Archive, System)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Loop super user and non-super user to run the test case.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Create basedir and a set of subdirectores and files within it.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Grant user has write_attributes permission or
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# PRIV_FILE_OWNER privilege
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 4. Verify set/clear DOS attributes should succeed.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy for fs in $TESTPOOL/$TESTFS $TESTPOOL ; do
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Set the special attribute to the given node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $1: The given node (file/dir)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $2: The special attribute to be set
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $3: Execute username
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -z $object ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -n $user ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Clear the special attribute to the given node
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $1: The given node (file/dir)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $2: The special attribute to be cleared
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $3: Execute username
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -z $object ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -n $user ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Grant the ace of write_attributes to the given user
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $1: The given user
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $2: The given node (file/dir)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -z $user || -z $object ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "User($user), Object($object) not defined."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # To increase the coverage, here we set 'deny' against
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Only grant the user explicitly while it's not root neither owner.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must chmod A+user:root:write_attributes:deny $object
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy elif [[ $user == $(get_owner $object) ]]; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must chmod A+owner@:write_attributes:deny $object
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must chmod A+user:$user:write_attributes:deny \
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must chmod A+user:$user:write_attributes:allow $object
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Revoke the ace of write_attributes from the given user
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $1: The given user
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $2: The given node (file/dir)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -z $user || -z $object ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "User($user), Object($object) not defined."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Invoke the function and verify whether its return code as expected
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $1: Function be invoked
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $2: The given node (file/dir)
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# $3: Execute user
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -z $func || -z $object ]]; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "Func($func), Object($object), User($user), \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy Opt($opt) not defined."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # If user is superuser or has write_attributes permission or
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # PRIV_FILE_OWNER privilege, it should log_must,
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -z $user || $user == "root" || $user == \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy $(get_owner $object) || $attr_mod == *"write_attributes"* ]] ; then
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Verify set/clear DOS attributes will succeed while user has " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "write_attributes permission or PRIV_FILE_OWNER privilege"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_pass "Set/Clear DOS attributes succeed while user has " \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "write_attributes permission or PRIV_FILE_OWNER privilege"