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# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23# Use is subject to license terms. 24# 25# ident "@(#)xattr_007_neg.ksh 1.2 08/02/27 SMI" 26# 27. $STF_SUITE/include/libtest.kshlib 28. $STF_SUITE/tests/xattr/xattr_common.kshlib 29 30# $FreeBSD$ 31 32################################################################################ 33# 34# __stc_assertion_start 35# 36# ID: xattr_007_neg 37# 38# DESCRIPTION: 39# Creating and writing xattrs on files in snapshot directories fails. Also, 40# we shouldn't be able to list the xattrs of files in snapshots who didn't have 41# xattrs when the snapshot was created (the xattr namespace wouldn't have been 42# created yet, and snapshots are read-only) See fsattr(5) for more details. 43# 44# STRATEGY: 45# 1. Create a file and add an xattr to it. 46# 2. Create another file, but don't add an xattr to it. 47# 3. Snapshot the filesystem 48# 4. Verify we're unable to alter the xattr on the first file 49# 5. Verify we're unable to list the xattrs on the second file 50# 51# TESTABILITY: explicit 52# 53# TEST_AUTOMATION_LEVEL: automated 54# 55# CODING_STATUS: COMPLETED (2006-12-13) 56# 57# __stc_assertion_end 58# 59################################################################################ 60 61function cleanup { 62 log_must $ZFS destroy $TESTPOOL/$TESTFS@snap 63 log_must $RM $TESTDIR/myfile2.${TESTCASE_ID} 64 log_must $RM $TESTDIR/myfile.${TESTCASE_ID} 65 log_must $RM $TMPDIR/output.${TESTCASE_ID} 66 [[ -e $TMPDIR/expected_output.${TESTCASE_ID} ]] && log_must $RM \ 67 $TMPDIR/expected_output.${TESTCASE_ID} 68 69} 70 71log_assert "create/write xattr on a snapshot fails" 72log_onexit cleanup 73 74# create a file, and an xattr on it 75log_must $TOUCH $TESTDIR/myfile.${TESTCASE_ID} 76create_xattr $TESTDIR/myfile.${TESTCASE_ID} passwd /etc/passwd 77 78# create another file that doesn't have an xattr 79log_must $TOUCH $TESTDIR/myfile2.${TESTCASE_ID} 80 81# snapshot the filesystem 82log_must $ZFS snapshot $TESTPOOL/$TESTFS@snap 83 84# we shouldn't be able to alter the first file's xattr 85log_mustnot eval " $RUNAT $TESTDIR/$(get_snapdir_name)/snap/myfile.${TESTCASE_ID} \ 86 $CP /etc/passwd . >$TMPDIR/output.${TESTCASE_ID} 2>&1" 87log_must $GREP -i Read-only $TMPDIR/output.${TESTCASE_ID} 88 89if check_version "5.10" 90then 91 # we shouldn't be able to list xattrs at all on the second file 92 log_mustnot eval " $RUNAT $TESTDIR/$(get_snapdir_name)/snap/myfile2.${TESTCASE_ID} \ 93 $LS >$TMPDIR/output.${TESTCASE_ID} 2>&1" 94 log_must $GREP -i Read-only $TMPDIR/output.${TESTCASE_ID} 95else 96 log_must eval "$RUNAT $TESTDIR/$(get_snapdir_name)/snap/myfile2.${TESTCASE_ID} \ 97 $LS >$TMPDIR/output.${TESTCASE_ID} 2>&1" 98 create_expected_output $TMPDIR/expected_output.${TESTCASE_ID} SUNWattr_ro \ 99 SUNWattr_rw 100 log_must $DIFF $TMPDIR/output.${TESTCASE_ID} $TMPDIR/expected_output.${TESTCASE_ID} 101fi 102log_pass "create/write xattr on a snapshot fails" 103