1#!/bin/ksh -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# 24# Copyright (c) 2017 by Lawrence Livermore National Security, LLC. 25# 26 27# DESCRIPTION: 28# Verify zpool status command mode (-c) works with scripts in user's 29# home directory. 30# 31# STRATEGY: 32# 1. Change HOME to /var/tmp 33# 2. Make a simple script that echoes a key value pair 34# in /var/tmp/.zpool.d 35# 3. Make sure it can be run with -c 36# 4. Remove the script we created 37 38. $STF_SUITE/include/libtest.shlib 39. $STF_SUITE/include/zpool_script.shlib 40 41verify_runnable "both" 42 43# In tree testing sets this variable, we need to unset it 44# to restore zpool's search path. 45unset ZPOOL_SCRIPTS_PATH 46 47# change HOME 48export HOME="$TEST_BASE_DIR" 49typeset USER_SCRIPT_FULL="$HOME/.zpool.d/userscript" 50 51function cleanup 52{ 53 log_must rm -rf "$HOME/.zpool.d" 54} 55 56log_assert "zpool status -c can run scripts from ~/.zpool.d" 57 58if [ -e "$USER_SCRIPT_FULL" ]; then 59 log_fail "$USER_SCRIPT_FULL already exists." 60fi 61 62log_onexit cleanup 63 64# create simple script 65log_must mkdir -p "$HOME/.zpool.d" 66cat > "$USER_SCRIPT_FULL" << EOF 67#!/bin/sh 68echo "USRCOL=USRVAL" 69EOF 70log_must chmod +x "$USER_SCRIPT_FULL" 71 72# test that we can run the script 73typeset USER_SCRIPT=$(basename "$USER_SCRIPT_FULL") 74test_zpool_script "$USER_SCRIPT" "$TESTPOOL" "zpool status -P -c" 75 76log_pass "zpool status -c can run scripts from ~/.zpool.d passed" 77