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 https://opensource.org/licenses/CDDL-1.0. 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. $STF_SUITE/tests/functional/user_namespace/user_namespace_common.kshlib 24 25# 26# DESCRIPTION: 27# Regression test for safeguards around the delegation of datasets to 28# user namespaces. 29# 30# STRATEGY: 31# 1. Check that 'zfs zone' correctly handles the case of the first 32# argument being a non-namespace file. 33# 2. Check that 'zfs zone' correctly handles the case of the first 34# argument being a non-namespace and non-existent file. 35# 36 37verify_runnable "both" 38 39user_ns_cleanup() { 40 if [ -n "$temp_file" ]; then 41 log_must rm -f "$temp_file" 42 fi 43 44 log_must zfs destroy -r "$TESTPOOL/userns" 45} 46 47log_assert "Check zfs zone command handling of non-namespace files" 48 49# Pass if user namespaces are not supported. 50unshare -Urm echo test 51if [ "$?" -ne "0" ]; then 52 log_unsupported "Failed to create user namespace" 53fi 54 55log_onexit user_ns_cleanup 56 57# Create the baseline datasets. 58log_must zfs create -o zoned=on "$TESTPOOL/userns" 59 60# 1. Try to pass a non-namespace file to zfs zone. 61temp_file="$(TMPDIR=$TEST_BASE_DIR mktemp)" 62log_mustnot zfs zone "$temp_file" "$TESTPOOL/userns" 63 64# 2. Try to pass a non-namespace and non-existent file to zfs zone. 65log_mustnot zfs zone "$TEMP_BASE_DIR/nonexistent" "$TESTPOOL/userns" 66 67log_pass "Check zfs zone command handling of non-namespace files" 68