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 2007 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2016 by Delphix. All rights reserved. 30# Copyright (c) 2023 by Klara Inc. 31# 32 33. $STF_SUITE/tests/functional/cli_root/zpool_set/zpool_set_common.kshlib 34 35# 36# DESCRIPTION: 37# ZFS can handle any invalid user-defined pool property. 38# 39# STRATEGY: 40# 1. Combine all kind of invalid user pool property names. 41# 2. Random get a string as the value. 42# 3. Verify all the invalid user-defined pool properties can not be set 43# to the pool. 44# 45 46verify_runnable "both" 47 48log_assert "ZFS can handle any invalid user pool property." 49log_onexit cleanup_user_prop $TESTPOOL 50 51typeset -a names=() 52typeset -a values=() 53 54# Too long property name (256 bytes, which is the 256-byte limit minus 1 byte 55# for the null byte plus 1 byte to reach back over the limit) 56names+=("$(awk 'BEGIN { printf "x:"; while (c++ < (256 - 2 - 1 + 1)) printf "a" }')") 57values+=("too-long-property-name") 58# Too long property value (the limits are 1024 on FreeBSD and 4096 on Linux, so 59# pick the right one; the too long value is, e.g., the limit minus 1 bytes for the 60# null byte plus 1 byte to reach back over the limit) 61if is_linux; then 62 typeset ZFS_MAXPROPLEN=4096 63else 64 typeset ZFS_MAXPROPLEN=1024 65fi 66names+=("too:long:property:value") 67values+=("$(awk -v max="$ZFS_MAXPROPLEN" 'BEGIN { while (c++ < (max - 1 + 1)) printf "A" }')") 68# Invalid property names 69for i in {1..10}; do 70 typeset -i len 71 ((len = RANDOM % 32)) 72 names+=("$(invalid_user_property $len)") 73 ((len = RANDOM % 512)) 74 values+=("$(user_property_value $len)") 75done 76 77typeset -i i=0 78while ((i < ${#names[@]})); do 79 typeset name="${names[$i]}" 80 typeset value="${values[$i]}" 81 82 log_mustnot zpool set $name=$value $TESTPOOL 83 log_mustnot check_user_prop $TESTPOOL \"$name\" \"$value\" 84 85 ((i += 1)) 86done 87 88log_pass "ZFS can handle invalid user pool property passed." 89