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# 24# Copyright 2020 iXsystems, Inc. 25# 26 27. $STF_SUITE/include/libtest.shlib 28 29# 30# DESCRIPTION: 31# Test basic functionality of `zfs jail` and `zfs unjail`. 32# 33# STRATEGY: 34# 1. Create a jail. 35# 2. Perform some basic ZFS operations on a dataset both in the host and 36# in the jail to confirm the dataset is functional in the host 37# and hidden in in the jail. 38# 3. Run `zfs jail` to expose the dataset in the jail. 39# 4. Perform some basic ZFS operations on the dataset both in the host and 40# in the jail to confirm the dataset is functional in the jail and host. 41# 5. Run `zfs unjail` to return the dataset to the host. 42# 6. Perform some basic ZFS operations on the dataset both in the host and 43# in the jail to confirm the dataset is functional in the host 44# and hidden in in the jail. 45# 46 47verify_runnable "global" 48 49JAIL="testjail" 50JAIL_CONF="$STF_SUITE/tests/functional/cli_root/zfs_jail/jail.conf" 51 52function cleanup 53{ 54 if jls -j $JAIL name >/dev/null 2>&1; then 55 jail -r -f $JAIL_CONF $JAIL 56 fi 57} 58 59log_onexit cleanup 60 61log_assert "Verify that a dataset can be jailed and unjailed." 62 63# 1. Create a jail. 64log_must jail -c -f $JAIL_CONF $JAIL 65 66# 2. Try some basic ZFS operations. 67log_must zfs list $TESTPOOL 68log_mustnot jexec $JAIL zfs list $TESTPOOL 69 70# 3. Jail the dataset. 71log_must zfs jail $JAIL $TESTPOOL 72 73# 4. Try some basic ZFS operations. 74log_must zfs list $TESTPOOL 75log_must jexec $JAIL zfs list $TESTPOOL 76 77# 5. Unjail the dataset. 78log_must zfs unjail $JAIL $TESTPOOL 79 80# 6. Try some basic ZFS operations. 81log_must zfs list $TESTPOOL 82log_mustnot jexec $JAIL zfs list $TESTPOOL 83 84log_pass "Datasets can be jailed and unjailed." 85