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 2021 Attila Fülöp <attila@fueloep.org> 25# 26 27 28. $STF_SUITE/tests/functional/pam/utilities.kshlib 29 30if [ -n "$ASAN_OPTIONS" ]; then 31 export LD_PRELOAD=$(ldd "$(command -v zfs)" | awk '/libasan\.so/ {print $3}') 32fi 33 34if [[ -z pamservice ]]; then 35 pamservice=pam_zfs_key_test 36fi 37 38# DESCRIPTION: 39# If we set the encryption passphrase for a dataset via pam_zfs_key, a minimal 40# passphrase length isn't enforced. This leads to a non-loadable key if 41# `zfs load-key` enforces a minimal length. Make sure this isn't the case. 42 43log_mustnot ismounted "$TESTPOOL/pam/${username}" 44keystatus unavailable 45 46genconfig "homes=$TESTPOOL/pam runstatedir=${runstatedir}" 47 48# Load keys and mount userdir. 49echo "testpass" | pamtester ${pamservice} ${username} open_session 50references 1 51log_must ismounted "$TESTPOOL/pam/${username}" 52keystatus available 53 54# Change user and dataset password to short one. 55printf "short\nshort\n" | pamtester ${pamservice} ${username} chauthtok 56 57# Unmount and unload key. 58log_must pamtester ${pamservice} ${username} close_session 59references 0 60log_mustnot ismounted "$TESTPOOL/pam/${username}" 61keystatus unavailable 62 63# Check if password change succeeded. 64echo "testpass" | pamtester ${pamservice} ${username} open_session 65references 1 66log_mustnot ismounted "$TESTPOOL/pam/${username}" 67keystatus unavailable 68log_must pamtester ${pamservice} ${username} close_session 69references 0 70 71echo "short" | pamtester ${pamservice} ${username} open_session 72references 1 73log_must ismounted "$TESTPOOL/pam/${username}" 74keystatus available 75 76 77# Finally check if `zfs load-key` succeeds with the short password. 78log_must pamtester ${pamservice} ${username} close_session 79references 0 80log_mustnot ismounted "$TESTPOOL/pam/${username}" 81keystatus unavailable 82 83echo "short" | zfs load-key "$TESTPOOL/pam/${username}" 84keystatus available 85zfs unload-key "$TESTPOOL/pam/${username}" 86keystatus unavailable 87 88log_pass "done." 89