196c8483Yuri Pankov#!/bin/ksh -p
296c8483Yuri Pankov#
396c8483Yuri Pankov# CDDL HEADER START
496c8483Yuri Pankov#
596c8483Yuri Pankov# The contents of this file are subject to the terms of the
696c8483Yuri Pankov# Common Development and Distribution License (the "License").
796c8483Yuri Pankov# You may not use this file except in compliance with the License.
896c8483Yuri Pankov#
996c8483Yuri Pankov# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1096c8483Yuri Pankov# or http://www.opensolaris.org/os/licensing.
1196c8483Yuri Pankov# See the License for the specific language governing permissions
1296c8483Yuri Pankov# and limitations under the License.
1396c8483Yuri Pankov#
1496c8483Yuri Pankov# When distributing Covered Code, include this CDDL HEADER in each
1596c8483Yuri Pankov# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1696c8483Yuri Pankov# If applicable, add the following below this CDDL HEADER, with the
1796c8483Yuri Pankov# fields enclosed by brackets "[]" replaced with your own identifying
1896c8483Yuri Pankov# information: Portions Copyright [yyyy] [name of copyright owner]
1996c8483Yuri Pankov#
2096c8483Yuri Pankov# CDDL HEADER END
2196c8483Yuri Pankov#
2296c8483Yuri Pankov
2396c8483Yuri Pankov#
2496c8483Yuri Pankov# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2596c8483Yuri Pankov#
2696c8483Yuri Pankov
2796c8483Yuri Pankov#
2896c8483Yuri Pankov# ID: acl_002
2996c8483Yuri Pankov#
3096c8483Yuri Pankov# DESCRIPTION:
3196c8483Yuri Pankov#	Copy ACLs to/from and smbfs mount with cpio
3296c8483Yuri Pankov#
3396c8483Yuri Pankov# STRATEGY:
3496c8483Yuri Pankov#       1. run "mount -F smbfs //server/public /export/mnt"
3596c8483Yuri Pankov#       2. create a file, make sure it has an ACL
3696c8483Yuri Pankov#       3. cpio -oP -O archive.cpio
3796c8483Yuri Pankov#	4. remove the file
3896c8483Yuri Pankov#	5. cpio -iP -I archive.cpio
3996c8483Yuri Pankov#	6. verify extracted ACL matches original
4096c8483Yuri Pankov#
4196c8483Yuri Pankov
4296c8483Yuri Pankov. $STF_SUITE/include/libtest.ksh
4396c8483Yuri Pankov
4496c8483Yuri Pankovtc_id="acl002"
4596c8483Yuri Pankovtc_desc="Verify we can save/restore ACLs with cpio"
4696c8483Yuri Pankovprint_test_case $tc_id - $tc_desc
4796c8483Yuri Pankov
4896c8483Yuri Pankovif [[ $STC_CIFS_CLIENT_DEBUG == 1 ]] || \
4996c8483Yuri Pankov	[[ *:${STC_CIFS_CLIENT_DEBUG}:* == *:$tc_id:* ]]; then
5096c8483Yuri Pankov    set -x
5196c8483Yuri Pankovfi
5296c8483Yuri Pankov
5396c8483Yuri Pankovserver=$(server_name) || return
5496c8483Yuri Pankov
5596c8483Yuri Pankovtestdir_init $TDIR
5696c8483Yuri Pankovsmbmount_clean $TMNT
5796c8483Yuri Pankovsmbmount_init $TMNT
5896c8483Yuri Pankov
5996c8483Yuri Pankovcmd="mount -F smbfs -oacl //$TUSER:$TPASS@$server/public $TMNT"
6096c8483Yuri Pankovcti_execute -i '' FAIL $cmd
6196c8483Yuri Pankovif [[ $? != 0 ]]; then
6296c8483Yuri Pankov	cti_fail "FAIL: $cmd"
6396c8483Yuri Pankov	return
6496c8483Yuri Pankovelse
6596c8483Yuri Pankov	cti_report "PASS: $cmd"
6696c8483Yuri Pankovfi
6796c8483Yuri Pankov
6896c8483Yuri Pankov# Require that the mount supports ACLs
6996c8483Yuri Pankovsmbmount_getmntopts $TMNT |grep /acl/ >/dev/null
7096c8483Yuri Pankovif [[ $? != 0 ]]; then
7196c8483Yuri Pankov	smbmount_clean $TMNT
7296c8483Yuri Pankov	cti_unsupported "UNSUPPORTED (no ACLs in this mount)"
7396c8483Yuri Pankov	return
7496c8483Yuri Pankovfi
7596c8483Yuri Pankov
7696c8483Yuri Pankov# create a file, make sure it has an ACL
7796c8483Yuri Pankovcmd="cp /etc/passwd $TMNT/$tc_id"
7896c8483Yuri Pankovcti_execute_cmd $cmd
7996c8483Yuri Pankovif [[ $? != 0 ]]; then
8096c8483Yuri Pankov	cti_fail "FAIL: $cmd"
8196c8483Yuri Pankov	smbmount_clean $TMNT
8296c8483Yuri Pankov	return
8396c8483Yuri Pankovfi
8496c8483Yuri Pankovcmd="ls -V $TMNT/$tc_id"
8596c8483Yuri Pankovcti_execute_cmd $cmd
8696c8483Yuri Pankovif [[ $? != 0 ]]; then
8796c8483Yuri Pankov	cti_fail "FAIL: $cmd"
8896c8483Yuri Pankov	smbmount_clean $TMNT
8996c8483Yuri Pankov	return
9096c8483Yuri Pankovfi
9196c8483Yuri Pankovtail +2 cti_stdout > acl_save
9296c8483Yuri Pankov
9396c8483Yuri Pankov#       3. cpio -oP -O archive.cpio
9496c8483Yuri Pankovcmd="echo $tc_id | \
9596c8483Yuri Pankov ( cd $TMNT ; cpio -ocP -O $TDIR/$tc_id.cpio )"
9696c8483Yuri Pankovcti_execute_cmd $cmd
9796c8483Yuri Pankovif [[ $? != 0 ]]; then
9896c8483Yuri Pankov	cti_fail "FAIL: $cmd"
9996c8483Yuri Pankov	smbmount_clean $TMNT
10096c8483Yuri Pankov	return
10196c8483Yuri Pankovfi
10296c8483Yuri Pankov
10396c8483Yuri Pankov#	4. remove the file
10496c8483Yuri Pankovcti_execute_cmd "rm -f $TMNT/$tc_id"
10596c8483Yuri Pankov
10696c8483Yuri Pankov#	5. cpio -iP -I archive.cpio
10796c8483Yuri Pankovcmd="( cd $TMNT ; cpio -icP -I $TDIR/$tc_id.cpio )"
10896c8483Yuri Pankovcti_execute_cmd $cmd
10996c8483Yuri Pankovif [[ $? != 0 ]]; then
11096c8483Yuri Pankov	cti_fail "FAIL: $cmd"
11196c8483Yuri Pankov	smbmount_clean $TMNT
11296c8483Yuri Pankov	return
11396c8483Yuri Pankovfi
11496c8483Yuri Pankov
11596c8483Yuri Pankov#	6. verify extracted ACL matches original
11696c8483Yuri Pankovcmd="ls -V $TMNT/$tc_id"
11796c8483Yuri Pankovcti_execute_cmd $cmd
11896c8483Yuri Pankovif [[ $? != 0 ]]; then
11996c8483Yuri Pankov	cti_fail "FAIL: $cmd"
12096c8483Yuri Pankov	smbmount_clean $TMNT
12196c8483Yuri Pankov	return
12296c8483Yuri Pankovfi
12396c8483Yuri Pankovtail +2 cti_stdout > acl_test
12496c8483Yuri Pankov
12596c8483Yuri Pankovcmd="diff acl_save acl_test"
12696c8483Yuri Pankovcti_execute_cmd $cmd
12796c8483Yuri Pankovif [[ $? != 0 ]]; then
12896c8483Yuri Pankov	cti_fail "FAIL: $cmd"
12996c8483Yuri Pankov	smbmount_clean $TMNT
13096c8483Yuri Pankov	return
13196c8483Yuri Pankovfi
13296c8483Yuri Pankov
13396c8483Yuri Pankovcti_execute_cmd "rm $TDIR/$tc_id.cpio"
13496c8483Yuri Pankovcti_execute_cmd "rm $TMNT/$tc_id"
13596c8483Yuri Pankovsmbmount_clean $TMNT
13696c8483Yuri Pankov
13796c8483Yuri Pankovcti_pass "${tc_id}: PASS"
138