xref: /freebsd/tests/sys/cddl/zfs/bin/zfs_crypto.ksh (revision cddbc3b40812213ff00041f79174cac0be360a2a)
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
23# $FreeBSD$
24
25#
26# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27# Use is subject to license terms.
28#
29# ident	"@(#)zfs_crypto.ksh	1.2	09/05/19 SMI"
30#
31
32cmd=$1
33shift
34options="$@"
35
36case $cmd in
37	create)
38		# Get zfs name
39		# eval zfsname=\${$#}
40
41		if [[ $KEYSOURCE_DATASET == "passphrase" ]]; then
42			options="-o encryption=$ENCRYPTION \
43-o keysource=passphrase,file://$PASSPHRASE_FILE $options"
44		elif [[ $KEYSOURCE_DATASET == "raw" ]]; then
45			options="-o encryption=$ENCRYPTION \
46-o keysource=raw,file://$RAW_KEY_FILE $options"
47		elif [[ $KEYSOURCE_DATASET == "hex" ]]; then
48			options="-o encryption=$ENCRYPTION \
49-o keysource=hex,file://$HEX_KEY_FILE $options"
50		elif [[ -n $KEYSOURCE_DATASET ]]; then
51			log_note "Warning: invalid KEYSOURCE_DATASET \c"
52			log_note "value: $KEYSOURCE_DATASET, ignore it"
53		fi
54		;;
55	*)
56		;;
57esac
58
59print $cmd $options
60