From d1afecf6992b11e84f3665b348696c69275d31e2 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 17 Aug 2020 09:49:36 -0400 Subject: [PATCH] Fix for properly identify the jail type --- CHANGELOG | 1 + bastille-init | 12 ++++++------ gui/bastille_manager_util.php | 2 +- version | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 77c28f3..3a37f39 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ ====================== Version Description +1.0.67......Fix for properly identify the jail type, thanks to mvdhoeven. 1.0.66......Update extension and bastille config files at once. 1.0.65......Add ability to create empty containers, minor improvements. 1.0.64......Switch back to official bastille repository, simplify initial help banner. diff --git a/bastille-init b/bastille-init index ed23a85..1006d14 100755 --- a/bastille-init +++ b/bastille-init @@ -560,7 +560,7 @@ jail_update() fi if [ -d "${bastille_jailsdir}/${TARGET}" ]; then - if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -q ".bastille"; then + if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then # Update a thick container. @@ -622,15 +622,15 @@ thinjail_upgrade() if [ -f "${bastille_releasesdir}/${NEWRELEASE}/COPYRIGHT" ]; then if [ -f "${bastille_jailsdir}/${TARGET}/fstab" ]; then # Check if is a thin container. - if cat "${bastille_jailsdir}/${TARGET}/fstab" | grep "${RELEASE}" | grep -q ".bastille"; then + if cat "${bastille_jailsdir}/${TARGET}/fstab" | grep "${RELEASE}" | grep -qw "/.*/.bastille"; then # If the previous conditions meets, proceed with the container base upgrade. sed -i '' "s/${RELEASE}/${NEWRELEASE}/g" ${bastille_jailsdir}/${TARGET}/fstab echo "${TARGET} release changed to ${NEWRELEASE}." - elif cat "${bastille_jailsdir}/${TARGET}/fstab" | grep "${NEWRELEASE}" | grep -q ".bastille"; then + elif cat "${bastille_jailsdir}/${TARGET}/fstab" | grep "${NEWRELEASE}" | grep -qw "/.*/.bastille"; then echo "${TARGET} already using ${NEWRELEASE}." exit 0 else - if cat "${bastille_jailsdir}/${TARGET}/fstab" | grep -q ".bastille"; then + if cat "${bastille_jailsdir}/${TARGET}/fstab" | grep -qw "/.*/.bastille"; then echo "${TARGET} container does not use ${RELEASE}."; exit 1 else echo "${TARGET} is not a thin container."; exit 1 @@ -681,7 +681,7 @@ thickjail_upgrade() # Verify for user input and handle some errors. if [ -d "${bastille_jailsdir}/${TARGET}" ]; then - if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -q ".bastille"; then + if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then # Upgrade a thick container. @@ -729,7 +729,7 @@ thickjail_install() fi if [ -d "${bastille_jailsdir}/${TARGET}" ]; then - if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -q ".bastille"; then + if ! cat "${bastille_jailsdir}/${TARGET}/fstab" 2>/dev/null | grep -w "${TARGET}" | grep -qw "/.*/.bastille"; then if [ -f "${bastille_jailsdir}/${TARGET}/root/COPYRIGHT" ]; then if [ "$(jls name | grep -w "${TARGET}")" ]; then # Finish installing upgrade on a thick container. diff --git a/gui/bastille_manager_util.php b/gui/bastille_manager_util.php index b391035..225cdf2 100644 --- a/gui/bastille_manager_util.php +++ b/gui/bastille_manager_util.php @@ -436,7 +436,7 @@ $document->render(); #$current_release = exec("/usr/sbin/jexec {$pconfig['jailname']} freebsd-version 2>/dev/null"); unset($disable_base_change); $current_release = exec("/usr/bin/grep '\-RELEASE' {$jail_dir}/{$pconfig['jailname']}/fstab | awk '{print $1}' | grep -o '[^/]*$'"); - $is_thickjail = exec("/usr/bin/grep '.bastille' {$jail_dir}/{$pconfig['jailname']}/fstab"); + $is_thickjail = exec("/usr/bin/grep -qw '/.*/.bastille' {$jail_dir}/{$pconfig['jailname']}/fstab"); if (!$current_release): $current_release = exec("/usr/bin/grep 'releng' {$jail_dir}/{$pconfig['jailname']}/root/COPYRIGHT | cut -d '/' -f2"); $disable_base_change = "1"; diff --git a/version b/version index 7f2b140..c8b4742 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.0.66 +1.0.67