1#! /usr/local/bin/ksh93 -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23# $FreeBSD$
24
25#
26# Copyright 2012 Spectra Logic.  All rights reserved.
27# Use is subject to license terms.
28#
29#
30. $STF_SUITE/include/libtest.kshlib
31
32################################################################################
33#
34# __stc_assertion_start
35#
36# ID: snapshot_018_pos
37#
38# DESCRIPTION:
39#	Snapshot directory supports ACL operations
40#
41# STRATEGY:
42#	1. Create a dataset
43#	2. Set the snapdir property to visible
44#	3. Use getconf to verify that acls are supported
45#	4. Use getfacl to verify that the acl can be read
46#	5. Verify that the acl is correct
47#	6. Verify that ls doesn't print any errors because acl_get_link fails
48#
49# TESTABILITY: explicit
50#
51# TEST_AUTOMATION_LEVEL: automated
52#
53# CODING_STATUS: COMPLETED (2013-01-03)
54#
55# __stc_assertion_end
56#
57################################################################################
58
59verify_runnable "both"
60
61log_assert "Verify that the snapshot directory supports ACL operations"
62
63log_must dataset_setprop $TESTPOOL/$TESTFS "snapdir" "visible"
64
65function verify_dir # directory
66{
67	typeset DIR=$1
68	# 3. Verify that ACLs are supported by the ctldir
69	log_must $GETCONF TRUSTEDBSD_ACL_EXTENDED $DIR
70	# 4. Verify that we can read ACLs
71	log_must $GETFACL $DIR
72	# 5. Verify that the ACLs are correct
73	typeset PROG_DIR=$STF_SUITE/tests/snapshot
74	typeset SUM=$($SHA1 -q $PROG_DIR/ctldir_acl.txt)
75	if [[ $( $GETFACL -q $DIR | $SHA1 -q ) != $SUM ]]; then
76		log_fail "ACL is incorrect"
77	fi
78
79}
80
81typeset -a dirlist
82dirlist=( "$TESTDIR/.zfs" "$TESTDIR/.zfs/snapshot" )
83ctldir=".zfs"
84for d in ${dirlist[@]}; do
85	verify_dir $d
86done
87
88# 6. Check for errors with ls
89LS_STDERR=$( $LS -la $TESTDIR/$ctldir 2>&1 > /dev/null)
90LS_R_STDERR=$( $LS -lar $TESTDIR/$ctldir 2>&1 > /dev/null)
91if [[ -n $LS_STDERR || -n $LS_R_STDERR ]]; then
92	log_fail "ls encountered errors"
93fi
94
95log_pass
96