# HG changeset patch # User Franz Glasner # Date 1727527994 -7200 # Node ID a8052a57a921125eddc6bf9c19c3f872097f67a2 # Parent 5ba31e3748ca157f841a8026cd518f86fddda6ed ftjail: Use "zfs get" instead of "zfs list" to get just some properties; also explicitly check some return codes for code "1" also diff -r 5ba31e3748ca -r a8052a57a921 sbin/ftjail --- a/sbin/ftjail Sat Sep 28 14:51:25 2024 +0200 +++ b/sbin/ftjail Sat Sep 28 14:53:14 2024 +0200 @@ -903,7 +903,7 @@ [ -d "${_directory}" ] || { echo "ERROR: directory \`${_directory}' does not exist" 1>&2; return 1; } [ -z "${_new_origin}" ] && { echo "ERROR: no new origin given" 1>&2; return 2; } - zfs list -H -o name -t snapshot "${_new_origin}" >/dev/null || { echo "ERROR: new origin does not exist" 1>&2; return 1; } + zfs list -H -o name -t snapshot "${_new_origin}" >/dev/null || { echo "ERROR: ZFS dataset for the new origin \`${_new_origin}' does not exist" 1>&2; return 1; } if [ -n "${_etcupdate_tarball}" ]; then [ -r "${_etcupdate_tarball}" ] || { echo "ERROR: given etcupdate tarball does not exist and/or is not readable" 1>&2; return 1; } fi @@ -919,6 +919,9 @@ err "Please stop the \`${_jailname}' jail" return 1 ;; + 1) + return 1 + ;; 2) err "Jail \`${_jailname}' is currently yet dying" return 1 @@ -930,7 +933,7 @@ return ${_res} ;; esac - + # # Check whether additional log sockets are opened at their default # locations. Because they hinder proper unmounting of filesystems. @@ -962,9 +965,9 @@ EOF4tHGCSSf5d7d9cf [ "${_root_mountpoint}" != "${_directory}" ] && { echo "ERROR: found root mountpoint does not match given directory" 1>&2; return 1; } [ "${_root_type}" != "zfs" ] && { echo "ERROR: root mountpoint is not from a ZFS dataset" 1>&2; return 1; } - _root_readonly="$(zfs list -H -o readonly "${_root_dataset}")" + _root_readonly="$(zfs get -H -o value readonly "${_root_dataset}")" [ "${_root_readonly}" != "on" ] && { echo "ERROR: the root dataset is not mounted read-only" 1>&2; return 1; } - _root_origin="$(zfs list -H -o origin "${_root_dataset}")" + _root_origin="$(zfs get -H -o value origin "${_root_dataset}")" if [ -n "${_opt_old_origin}" ]; then [ "${_opt_old_origin}" != "${_root_origin}" ] && { echo "ERROR: origin mismatch" 1>&2; return 1; } else