From d07d34b4cc84b6288a4e4934a1e1711d760c93cc Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:22:24 -0600 Subject: [PATCH 1/4] config: Allow removing config values from jail.conf --- usr/local/share/bastille/config.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/usr/local/share/bastille/config.sh b/usr/local/share/bastille/config.sh index 3218f8bb..fe2cd3bc 100644 --- a/usr/local/share/bastille/config.sh +++ b/usr/local/share/bastille/config.sh @@ -34,7 +34,7 @@ usage() { - error_notify "Usage: bastille config TARGET [get|set] PROPERTY_NAME NEW_VALUE" + error_notify "Usage: bastille config TARGET [get|set|remove] PROPERTY_NAME NEW_VALUE" cat << EOF Options: @@ -87,9 +87,9 @@ shift 2 set_target "${TARGET}" case "${ACTION}" in - get) + get|remove) if [ "$#" -ne 1 ]; then - error_notify 'Too many parameters for a "get" operation.' + error_notify 'Too many parameters for [get|remove] operation.' usage fi ;; @@ -183,6 +183,12 @@ for _jail in ${JAILS}; do else echo "${_output}" fi + elif [ "${ACTION}" = "remove" ]; then + if [ "$(bastille config ${_jail} get ${PROPERTY})" != "not set" ]; then + sed -i '' "/.*${PROPERTY}.*/d" "${FILE}" + else + error_exit "Value not present in jail.conf: ${PROPERTY}" + fi else # Setting the value. -- cwells if [ -n "${VALUE}" ]; then VALUE=$(echo "${VALUE}" | sed 's/\//\\\//g') @@ -233,7 +239,7 @@ for _jail in ${JAILS}; do done # Only display this message once at the end (not for every jail). -- cwells -if [ "${ACTION}" = 'set' ] && [ -z "${BASTILLE_PROPERTY}" ]; then +if { [ "${ACTION}" = "set" ] || [ "${ACTION}" = "remove" ]; } && [ -z "${BASTILLE_PROPERTY}" ]; then info "A restart is required for the changes to be applied. See 'bastille restart'." fi From 418ee3f3a54883dbaa871f10a4608274d4929822 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:26:27 -0600 Subject: [PATCH 2/4] docs: Update config for remove action --- docs/chapters/subcommands/config.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/chapters/subcommands/config.rst b/docs/chapters/subcommands/config.rst index c25dfc0e..88d8610e 100644 --- a/docs/chapters/subcommands/config.rst +++ b/docs/chapters/subcommands/config.rst @@ -1,7 +1,7 @@ config ====== -Get or set properties for targeted jail(s). +Get,set or remove properties from targeted jail(s). Getting a property that *is* defined in jail.conf: @@ -26,10 +26,19 @@ Setting a property: The restart message will appear every time a property is set. +Removing a property: + +.. code-block:: shell + + ishmael ~ # bastille config azkaban remove allow.mlock + A restart is required for the changes to be applied. See 'bastille restart azkaban'. + +The restart message will appear every time a property is removed. + .. code-block:: shell ishmael ~ # bastille config help - Usage: bastille config TARGET [get|set] PROPERTY_NAME NEW_VALUE + Usage: bastille config TARGET [get|set|remove] PROPERTY_NAME [NEW_VALUE] Options: -x | --debug Enable debug mode. From 219673d911de35d6ee41deeeb43411d4580f2b89 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:26:53 -0600 Subject: [PATCH 3/4] Update config.sh --- usr/local/share/bastille/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/share/bastille/config.sh b/usr/local/share/bastille/config.sh index fe2cd3bc..4f3a58ab 100644 --- a/usr/local/share/bastille/config.sh +++ b/usr/local/share/bastille/config.sh @@ -34,7 +34,7 @@ usage() { - error_notify "Usage: bastille config TARGET [get|set|remove] PROPERTY_NAME NEW_VALUE" + error_notify "Usage: bastille config TARGET [get|set|remove] PROPERTY [VALUE]" cat << EOF Options: From ecfa61845e0aa927b5a97d98b6733e6c20d3a294 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Fri, 11 Apr 2025 17:27:17 -0600 Subject: [PATCH 4/4] Update config.rst --- docs/chapters/subcommands/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/chapters/subcommands/config.rst b/docs/chapters/subcommands/config.rst index 88d8610e..bb06f730 100644 --- a/docs/chapters/subcommands/config.rst +++ b/docs/chapters/subcommands/config.rst @@ -38,7 +38,7 @@ The restart message will appear every time a property is removed. .. code-block:: shell ishmael ~ # bastille config help - Usage: bastille config TARGET [get|set|remove] PROPERTY_NAME [NEW_VALUE] + Usage: bastille config TARGET [get|set|remove] PROPERTY [VALUE] Options: -x | --debug Enable debug mode.