cifs_attr_002_pos.ksh revision 1d32ba663e202c24a5a1f2e5aef83fffb447cb7f
#
# 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 the user with PRIV_FILE_FLAG_SET/PRIV_FILE_FLAG_CLEAR
# (Immutable, nounlink, and appendonly)
#
# STRATEGY:
# 1. Loop super user and non-super user to run the test case.
# 2. Create basedir and a set of subdirectores and files within it.
# 3. Grant user has PRIV_FILE_FLAG_SET/PRIV_FILE_FLAG_CLEAR separately.
#
verify_runnable "global"
function cleanup
{
}
function try
{
typeset obj=$1 # The file or dir to operate on
typeset attr=$2 # The attribute to set or clear
typeset user=$3 # The user to run the command as
typeset priv=$4 # What privilege to run with if non-root
typeset op=$5 # Whether to set or clear the attribute
#
# No one can add 'q' (av_quarantine) to a directory. root can do
# anything else. A regular user can remove no attributes without the
# 'all' privilege, and can add attributes (other than 'q' on a
# directory) with the 'file_flag_set' or 'all' privileges.
#
else
fi
else
log_mustnot su $user -c "$cmd"
else
if [[ -n $priv ]]; then
else
log_mustnot su $user -c "$cmd"
fi
else
else
log_mustnot su $user -c "$cmd"
#
# Remove the attribute, so the next
# iteration starts with a known state.
#
fi
fi
fi
fi
# Can't add av_quarantine to a directory, so don't check for that
}
function chk_attr
{
typeset op=$1
typeset obj=$2
typeset attr=$3
# Extract the attribute string - just the text inside the braces
else
fi
}
#
# Grant the privset to the given user
#
# $1: The given user
# $2: The given privset
#
function grant_priv
{
typeset user=$1
typeset priv=$2
fi
return $?
}
#
# Revoke the all additional privset from the given user
#
# $1: The given user
#
function reset_privs
{
typeset user=$1
if [[ -z $user ]]; then
log_fail "User not defined."
fi
cp $orig_user_attr /etc/user_attr || log_fail "Couldn't modify user_attr"
return 0
}
log_assert "Verify set/clear BSD'ish attributes will succeed while user has " \
"file_flag_set or all privilege"
add='S+c'
del='S-c'
orig_user_attr="/tmp/user_attr.$$"
attributes="u i a d q m"
done
done
done
done
"PRIV_FILE_FLAG_SET/PRIV_FILE_FLAG_CLEAR privilege"