#
# 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 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
#
function run_and_verify
{
p)
;;
u)
;;
esac
done
fullcmd="$1"
flags="$2"
# If we aren't running zpool or zfs, something is wrong
# If this is a 'zfs receive' truncate the stdin redirect
# Run the command as the specified user, and find the new history.
else
fi
# Verify what's common to every case, regardless of zpool history flags.
# If 'zpool history' was called without any flags, then we're done.
[[ -z $flags ]] && return
# Verify the new history in cases that are more interesting because
# additional information is logged with -i or -l.
"$flags"
}
function verify_long
{
typeset cmd=$1
typeset user=$2
typeset flags=$3
if ! is_global_zone; then
fi
2>&1
if [[ $? != 0 ]]; then
return 1
fi
return 0
}
function verify_hold
{
typeset cmd=$1
typeset subcmd=$2
typeset flags=$3
# This works whether or not the hold was recursive
if [[ $? != 0 ]]; then
return 1
fi
done
return 0
}
function verify_release
{
# hold and release formats only differ by the subcommand name, so
# simply reuse the hold function.
verify_hold "$1" "release" "$3"
}
function verify_rollback
{
typeset cmd=$1
typeset flags=$3
if [[ $? != 0 ]]; then
log_note "Didn't find rollback clone swap in pool history"
return 1
fi
if [[ $? != 0 ]]; then
log_note "Didn't find rollback destroy in pool history"
return 1
fi
return 0
}
function verify_inherit
{
typeset cmd=$1
typeset flags=$3
# This works whether or not the inherit was recursive
2>&1
if [[ $? != 0 ]]; then
return 1
fi
done
return 0
}
function verify_allow
{
typeset cmd=$1
typeset subcmd=$2
typeset flags=$3
#
# Here, we determine three things:
# - Whether we're operating on a set or an indivdual permission (which
# dictates the case of the first character in the code)
# - The name of the dataset we're operating on.
# - Whether the operation applies locally or to descendent datasets (or
# both)
#
2>&1 && is_set=1
lflag=1
dflag=1
fi
#
# For each of the five cases below, the operation is essentially the
# same. First, use the command passed in to determine what the code at
# the end of the pool history will be. The specifics of the code are
# described in a block comment at the top of dsl_deleg.c. Once that's
# been assembled, check for its presence in the history, and return
# success or failure accordingly.
#
str="s-\$@"
$NEW_HISTORY >/dev/null 2>&1
if [[ $? != 0 ]]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
str="c-\$"
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
str="u"
if [[ -n $lflag ]]; then
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
if [[ -n $dflag ]]; then
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
str="g"
if [[ -n $lflag ]]; then
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
if [[ -n $dflag ]]; then
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
str="e"
if [[ -n $lflag ]]; then
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
if [[ -n $dflag ]]; then
$NEW_HISTORY >/dev/null 2>&1
if [ $? != 0 ]]; then
log_note "Couldn't find $code in $NEW_HISTORY"
return 1
fi
fi
else
return 1
fi
return 0
}
function verify_unallow
{
#
# The unallow and allow history have the same format, except the former
# logs "permission removed" and the latter "permission updated" so
# simply reuse the allow function.
#
verify_allow "$1" "unallow" "$3"
}
function verify_destroy
{
typeset cmd=$1
typeset flags=$3
# This function doesn't currently verifiy the zpool command.
if [[ -n $is_snap ]]; then
if [[ $? != 0 ]]; then
return 1
fi
fi
# This should be present for datasets and snapshots alike
if [[ $? != 0 ]]; then
return 1
fi
return 0
}
function verify_snapshot
{
typeset cmd=$1
typeset flags=$3
if [[ $? != 0 ]]; then
return 1
fi
# This works whether or not the snapshot was recursive
if [[ $? != 0 ]]; then
return 1
fi
done
return 0
}