From 5769c9c6fe80763059fead7b032a4cd62df96c61 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sun, 28 Sep 2025 19:55:05 -0400 Subject: [PATCH 1/3] list: properly list jail type @michael-o This is actually a better solution. It didn't cross my mind that we are actually setting IS_FREEBSD_JAIL and IS_LINUX_JAIL in the list command. For now, if both are detected, it will set JAIL_TYPE to "hybrid" but if that is not agreeable, we can simply leave it at "thick". --- usr/local/share/bastille/list.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/usr/local/share/bastille/list.sh b/usr/local/share/bastille/list.sh index bd710e54..d66240df 100644 --- a/usr/local/share/bastille/list.sh +++ b/usr/local/share/bastille/list.sh @@ -156,21 +156,6 @@ get_jail_info() { # Get JID value JID="$(jls -j ${JAIL_NAME} jid 2>/dev/null)" - # Get jail type - if grep -qw "${bastille_jailsdir}/${JAIL_NAME}/root/.bastille" "${bastille_jailsdir}/${JAIL_NAME}/fstab"; then - JAIL_TYPE="thin" - elif [ "$(grep -c "^linprocfs" "${bastille_jailsdir}/${JAIL_NAME}/fstab" 2> /dev/null)" -gt 0 ]; then - JAIL_TYPE="linux" - elif checkyesno bastille_zfs_enable; then - if [ "$(zfs get -H -o value origin ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${JAIL_NAME}/root)" != "-" ]; then - JAIL_TYPE="clone" - else - JAIL_TYPE="thick" - fi - else - JAIL_TYPE="thick" - fi - # Get jail tags JAIL_TAGS="" if [ -f "${bastille_jailsdir}/${JAIL_NAME}/tags" ]; then @@ -189,6 +174,23 @@ get_jail_info() { if [ "$(grep -c "^linprocfs" "${bastille_jailsdir}/${JAIL_NAME}/fstab" 2> /dev/null)" -gt 0 ]; then IS_LINUX_JAIL=1; fi IS_LINUX_JAIL=${IS_LINUX_JAIL:-0} + # Get jail type + if grep -qw "${bastille_jailsdir}/${JAIL_NAME}/root/.bastille" "${bastille_jailsdir}/${JAIL_NAME}/fstab"; then + JAIL_TYPE="thin" + elif [ "$(grep -c "^linprocfs" "${bastille_jailsdir}/${JAIL_NAME}/fstab" 2> /dev/null)" -gt 0 ] && [ "${IS_LINUX_JAIL}" -eq 1 ] && [ "${IS_FREEBSD_JAIL}" -eq 0 ]; then + JAIL_TYPE="linux" + elif [ "${IS_LINUX_JAIL}" -eq 1 ] && [ "${IS_FREEBSD_JAIL}" -eq 1 ]; then + JAIL_TYPE="hybrid" + elif checkyesno bastille_zfs_enable; then + if [ "$(zfs get -H -o value origin ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${JAIL_NAME}/root)" != "-" ]; then + JAIL_TYPE="clone" + else + JAIL_TYPE="thick" + fi + else + JAIL_TYPE="thick" + fi + # Gather variable that depend on jail being UP or DOWN if [ "$(/usr/sbin/jls name | awk "/^${JAIL_NAME}$/")" ]; then From bdd08e0f4e818e01f94ae53bafd95d1a796f537d Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sun, 28 Sep 2025 18:20:36 -0600 Subject: [PATCH 2/3] list: support either FreeBSD OR Linux for release --- usr/local/share/bastille/list.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/usr/local/share/bastille/list.sh b/usr/local/share/bastille/list.sh index d66240df..b12215fb 100644 --- a/usr/local/share/bastille/list.sh +++ b/usr/local/share/bastille/list.sh @@ -224,8 +224,7 @@ get_jail_info() { # Get release (FreeBSD or Linux) if [ "${IS_FREEBSD_JAIL}" -eq 1 ]; then JAIL_RELEASE=$(jexec -l ${JAIL_NAME} freebsd-version -u 2> /dev/null) - fi - if [ "${IS_LINUX_JAIL}" -eq 1 ]; then + elif [ "${IS_LINUX_JAIL}" -eq 1 ]; then JAIL_RELEASE=$(grep -hE "^NAME=.*$|^VERSION_ID=.*$|^VERSION_CODENAME=.*$" "${JAIL_PATH}/etc/os-release" 2> /dev/null | sed "s/\"//g" | sed "s/ GNU\/Linux//g" | awk -F'=' '{ a[$1] = $2; o++ } o%3 == 0 { print a["VERSION_CODENAME"] " (" a["NAME"] " " a["VERSION_ID"] ")" }') fi From b6014dacad832f0837f0a915615793538441dc4c Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Tue, 30 Sep 2025 07:57:17 -0600 Subject: [PATCH 3/3] fix listing linux jail --- usr/local/share/bastille/list.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/usr/local/share/bastille/list.sh b/usr/local/share/bastille/list.sh index b12215fb..be5dba0d 100644 --- a/usr/local/share/bastille/list.sh +++ b/usr/local/share/bastille/list.sh @@ -171,16 +171,14 @@ get_jail_info() { if [ -f "${bastille_jailsdir}/${JAIL_NAME}/root/bin/freebsd-version" ] || [ -f "${bastille_jailsdir}/${JAIL_NAME}/root/.bastille/bin/freebsd-version" ] || [ "$(grep -c "/releases/.*/root/.bastille.*nullfs" "${bastille_jailsdir}/${JAIL_NAME}/fstab" 2> /dev/null)" -gt 0 ]; then IS_FREEBSD_JAIL=1; fi IS_FREEBSD_JAIL=${IS_FREEBSD_JAIL:-0} IS_LINUX_JAIL=0 - if [ "$(grep -c "^linprocfs" "${bastille_jailsdir}/${JAIL_NAME}/fstab" 2> /dev/null)" -gt 0 ]; then IS_LINUX_JAIL=1; fi + if [ "$(grep -c "^linprocfs.*${bastille_jailsdir}/${JAIL_NAME}/proc.*linprocfs" "${bastille_jailsdir}/${JAIL_NAME}/fstab" 2> /dev/null)" -gt 0 ]; then IS_LINUX_JAIL=1; fi IS_LINUX_JAIL=${IS_LINUX_JAIL:-0} # Get jail type if grep -qw "${bastille_jailsdir}/${JAIL_NAME}/root/.bastille" "${bastille_jailsdir}/${JAIL_NAME}/fstab"; then JAIL_TYPE="thin" - elif [ "$(grep -c "^linprocfs" "${bastille_jailsdir}/${JAIL_NAME}/fstab" 2> /dev/null)" -gt 0 ] && [ "${IS_LINUX_JAIL}" -eq 1 ] && [ "${IS_FREEBSD_JAIL}" -eq 0 ]; then + elif [ "${IS_LINUX_JAIL}" -eq 1 ] && [ "${IS_FREEBSD_JAIL}" -eq 0 ]; then JAIL_TYPE="linux" - elif [ "${IS_LINUX_JAIL}" -eq 1 ] && [ "${IS_FREEBSD_JAIL}" -eq 1 ]; then - JAIL_TYPE="hybrid" elif checkyesno bastille_zfs_enable; then if [ "$(zfs get -H -o value origin ${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${JAIL_NAME}/root)" != "-" ]; then JAIL_TYPE="clone"