Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 656:a8052a57a921
ftjail: Use "zfs get" instead of "zfs list" to get just some properties; also explicitly check some return codes for code "1" also
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 28 Sep 2024 14:53:14 +0200 |
| parents | 5ba31e3748ca |
| children | db22766df6a4 |
| files | sbin/ftjail |
| diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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
