xref: /freebsd/tests/sys/cddl/zfs/tests/xattr/setup.ksh (revision 069ac184)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24
25. ${STF_SUITE}/include/libtest.kshlib
26. ${STF_SUITE}/tests/xattr/xattr.cfg
27
28# if we're running NIS, turn it off until we clean up
29# (it can cause useradd to take a long time, hitting our TIMEOUT)
30$SVCS svc:/network/nis/client:default | $GREP online > /dev/null
31if [ $? -eq 0 ]
32then
33	$SVCADM disable -t svc:/network/nis/client:default
34	USES_NIS=true
35fi
36
37# Make sure we use a brand new user for this
38while [ -z "${FOUND}" ]
39do
40	COUNT=0
41	USER_EXISTS=$( $GREP $ZFS_USER /etc/passwd )
42	if [ ! -z "${USER_EXISTS}" ]
43	then
44		ZFS_USER="${ZFS_USER}${COUNT}"
45		COUNT=$(( $COUNT + 1 ))
46	else
47		FOUND="true"
48	fi
49done
50
51log_must add_user $ZFS_GROUP $ZFS_USER
52
53$ECHO $ZFS_USER > $TMPDIR/zfs-xattr-test-user.txt
54$ECHO $USES_NIS > $TMPDIR/zfs-xattr-test-nis.txt
55
56DISK=${DISKS%% *}
57default_setup $DISK
58