# HG changeset patch # User Franz Glasner # Date 1670229473 -3600 # Node ID 3b2935985c734449a76c0d13a0d8fa93abc4290d # Parent 1fa72d63ae087a8b44dcc6e7f04c98c468ad465c Prepare for some more future compatibility check on FreeBSD updates: implement _has_same_userland_version() diff -r 1fa72d63ae08 -r 3b2935985c73 sbin/fjail --- a/sbin/fjail Sat Dec 03 21:46:04 2022 +0100 +++ b/sbin/fjail Mon Dec 05 09:37:53 2022 +0100 @@ -136,6 +136,35 @@ } +#: +#: Check whether a FreeBSD version at a given location matches the userland +#: version of the host where the current process run. +#: +#: Args: +#: $1: the location where to check for +#: +#: Returns: +#: 0 if the userland versions match, 1 otherwise +#: +#: Exit: +#: 1 on fatal errors (e.g. /bin/freebsd-version not found or errors) +#: +_has_same_userland_version() { + local directory + + local _host_version _directory_version + + directory="$1" + + _host_version=$(/bin/freebsd-version -u) || exit 1 + _directory_version=$(chroot "${directory}" /bin/freebsd-version -u) || exit 1 + if [ "${_host_version%%-*}" = "${_directory_version%%-*}" ]; then + return 0 + fi + return 1 +} + + # # "datasets" -- create the ZFS dataset tree #