1d583b39bSJohn Wren Kennedy#!/bin/ksh -p
2d583b39bSJohn Wren Kennedy#
3d583b39bSJohn Wren Kennedy# CDDL HEADER START
4d583b39bSJohn Wren Kennedy#
5d583b39bSJohn Wren Kennedy# The contents of this file are subject to the terms of the
6d583b39bSJohn Wren Kennedy# Common Development and Distribution License (the "License").
7d583b39bSJohn Wren Kennedy# You may not use this file except in compliance with the License.
8d583b39bSJohn Wren Kennedy#
9d583b39bSJohn Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10d583b39bSJohn Wren Kennedy# or http://www.opensolaris.org/os/licensing.
11d583b39bSJohn Wren Kennedy# See the License for the specific language governing permissions
12d583b39bSJohn Wren Kennedy# and limitations under the License.
13d583b39bSJohn Wren Kennedy#
14d583b39bSJohn Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
15d583b39bSJohn Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16d583b39bSJohn Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
17d583b39bSJohn Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
18d583b39bSJohn Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
19d583b39bSJohn Wren Kennedy#
20d583b39bSJohn Wren Kennedy# CDDL HEADER END
21d583b39bSJohn Wren Kennedy#
22d583b39bSJohn Wren Kennedy
23d583b39bSJohn Wren Kennedy#
24d583b39bSJohn Wren Kennedy# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25d583b39bSJohn Wren Kennedy# Use is subject to license terms.
26d583b39bSJohn Wren Kennedy#
27d583b39bSJohn Wren Kennedy
28*1d32ba66SJohn Wren Kennedy#
29*1d32ba66SJohn Wren Kennedy# Copyright (c) 2016 by Delphix. All rights reserved.
30*1d32ba66SJohn Wren Kennedy#
31*1d32ba66SJohn Wren Kennedy
32d583b39bSJohn Wren Kennedy. $STF_SUITE/tests/functional/acl/acl_common.kshlib
33d583b39bSJohn Wren Kennedy
34d583b39bSJohn Wren Kennedy#
35d583b39bSJohn Wren Kennedy# DESCRIPTION:
36d583b39bSJohn Wren Kennedy#	Verifies that tar will include file attribute when @ flag is present.
37d583b39bSJohn Wren Kennedy#
38d583b39bSJohn Wren Kennedy# STRATEGY:
39d583b39bSJohn Wren Kennedy#	1. Use mktree create a set of directories in directory A.
40d583b39bSJohn Wren Kennedy#	2. Enter into directory A and record all directory information.
41d583b39bSJohn Wren Kennedy#	3. tar all the files to directory B.
42d583b39bSJohn Wren Kennedy#	4. Then tar the tar file to directory C.
43d583b39bSJohn Wren Kennedy#	5. Record all the directories informat in derectory C.
44d583b39bSJohn Wren Kennedy#	6. Verify the two records should be identical.
45d583b39bSJohn Wren Kennedy#
46d583b39bSJohn Wren Kennedy
47d583b39bSJohn Wren Kennedyverify_runnable "both"
48d583b39bSJohn Wren Kennedy
49d583b39bSJohn Wren Kennedylog_assert "Verifies that tar will include file attribute when @ flag is " \
50d583b39bSJohn Wren Kennedy	"present."
51d583b39bSJohn Wren Kennedylog_onexit cleanup
52d583b39bSJohn Wren Kennedy
53d583b39bSJohn Wren Kennedyfor user in root $ZFS_ACL_STAFF1; do
54d583b39bSJohn Wren Kennedy	log_must set_cur_usr $user
55d583b39bSJohn Wren Kennedy
56*1d32ba66SJohn Wren Kennedy	[[ ! -d $INI_DIR ]] && mkdir -m 777 -p $INI_DIR
57*1d32ba66SJohn Wren Kennedy	log_must usr_exec mktree -b $INI_DIR -l 5 -d 2 -f 2
58d583b39bSJohn Wren Kennedy
59d583b39bSJohn Wren Kennedy	#
60d583b39bSJohn Wren Kennedy	# Enter into initial directory and record all directory information,
61d583b39bSJohn Wren Kennedy	# then tar all the files to $TMP_DIR/files.tar.
62d583b39bSJohn Wren Kennedy	#
63*1d32ba66SJohn Wren Kennedy	[[ ! -d $TMP_DIR ]] && usr_exec mkdir $TMP_DIR
64d583b39bSJohn Wren Kennedy	initout=$TMP_DIR/initout.$$
65d583b39bSJohn Wren Kennedy	tarout=$TMP_DIR/files.tar
66d583b39bSJohn Wren Kennedy	cd $INI_DIR
67d583b39bSJohn Wren Kennedy	log_must record_cksum $INI_DIR $initout
68*1d32ba66SJohn Wren Kennedy	log_must usr_exec tar cpf@ $tarout *
69d583b39bSJohn Wren Kennedy
70d583b39bSJohn Wren Kennedy	#
71d583b39bSJohn Wren Kennedy	# Enter into test directory and tar $TMP_DIR/files.tar to current
72d583b39bSJohn Wren Kennedy	# directory. Record all directory information and compare with initial
73d583b39bSJohn Wren Kennedy	# directory record.
74d583b39bSJohn Wren Kennedy	#
75*1d32ba66SJohn Wren Kennedy	[[ ! -d $TST_DIR ]] && mkdir -m 777 $TST_DIR
76d583b39bSJohn Wren Kennedy	testout=$TMP_DIR/testout.$$
77d583b39bSJohn Wren Kennedy	cd $TST_DIR
78*1d32ba66SJohn Wren Kennedy	log_must usr_exec tar xpf@ $tarout
79d583b39bSJohn Wren Kennedy	log_must record_cksum $TST_DIR $testout
80d583b39bSJohn Wren Kennedy
81*1d32ba66SJohn Wren Kennedy	log_must usr_exec diff $initout $testout
82d583b39bSJohn Wren Kennedy
83d583b39bSJohn Wren Kennedy	log_must cleanup
84d583b39bSJohn Wren Kennedydone
85d583b39bSJohn Wren Kennedy
86d583b39bSJohn Wren Kennedylog_pass "Verify tar with @ passed."