From 228bb3b8cef36c703f758a2a3de9e0caade11665 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sat, 11 Jan 2025 16:44:01 -0700 Subject: [PATCH 01/19] cp: update to use new functions in common.sh --- usr/local/share/bastille/cp.sh | 80 ++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index d7fc174b..0dd0b0b0 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -34,49 +34,63 @@ . /usr/local/etc/bastille/bastille.conf usage() { - error_exit "Usage: bastille cp [OPTION] TARGET HOST_PATH CONTAINER_PATH" -} + error_notify "Usage: bastille cp [option(s)] TARGET HOST_PATH JAIL_PATH" + cat << EOF + Options: -CPSOURCE="${1}" -CPDEST="${2}" + -q | --quiet Suppress output. + -x | --debug Enable debug mode. -# Handle special-case commands first. -case "$1" in -help|-h|--help) - usage - ;; --q|--quiet) - OPTION="${1}" - CPSOURCE="${2}" - CPDEST="${3}" - ;; -esac +EOF + exit 1 +} -if [ $# -ne 2 ]; then +# Handle options. +OPTION="-av" +while [ "$#" -gt 0 ]; do + case "${1}" in + -h|--help|help) + usage + ;; + -q|--quiet) + OPTION="-a" + shift + ;; + -x|--debug) + enable_debug + shift + ;; + -*) + for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do + case ${_opt} in + q) OPTION="-a" ;; + x) enable_debug ;; + *) error_exit "Unknown Option: \"${1}\"" ;; + esac + done + shift + ;; + *) + break + ;; + esac +done + +if [ "$#" -ne 3 ]; then usage fi -bastille_root_check +TARGET="${1}" +CPSOURCE="${2}" +CPDEST="${3}" -case "${OPTION}" in - -q|--quiet) - OPTION="-a" - ;; - *) - OPTION="-av" - ;; -esac +bastille_root_check +set_target "${TARGET}" for _jail in ${JAILS}; do info "[${_jail}]:" bastille_jail_path="${bastille_jailsdir}/${_jail}/root" - cp "${OPTION}" "${CPSOURCE}" "${bastille_jail_path}/${CPDEST}" - RETURN="$?" - if [ "${TARGET}" = "ALL" ]; then - # Display the return status for reference - echo -e "Returned: ${RETURN}\n" - else - echo - return "${RETURN}" + if ! cp "${OPTION}" "${CPSOURCE}" "${bastille_jail_path}${CPDEST}"; then + error_continue "CP failed: ${CPSOURCE} -> ${bastille_jail_path}${CPDEST}" fi done From 6040308270b8d6c572a0c288d6422534e8ce80fe Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sat, 11 Jan 2025 16:46:30 -0700 Subject: [PATCH 02/19] rcp: update to use new functions --- usr/local/share/bastille/rcp.sh | 79 ++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 31 deletions(-) diff --git a/usr/local/share/bastille/rcp.sh b/usr/local/share/bastille/rcp.sh index a3b1cda1..7b313577 100644 --- a/usr/local/share/bastille/rcp.sh +++ b/usr/local/share/bastille/rcp.sh @@ -34,46 +34,63 @@ . /usr/local/etc/bastille/bastille.conf usage() { - error_exit "Usage: bastille rcp [OPTION] TARGET CONTAINER_PATH HOST_PATH" -} + error_notify "Usage: bastille rcp [option(s)] TARGET JAIL_PATH HOST_PATH" + cat << EOF + Options: -CPSOURCE="${1}" -CPDEST="${2}" + -q | --quiet Suppress output. + -x | --debug Enable debug mode. -# Handle special-case commands first. -case "$1" in -help|-h|--help) - usage - ;; --q|--quiet) - OPTION="${1}" - CPSOURCE="${2}" - CPDEST="${3}" - ;; -esac +EOF + exit 1 +} -if [ $# -ne 2 ]; then - usage -fi +# Handle options. +OPTION="-av" +while [ "$#" -gt 0 ]; do + case "${1}" in + -h|--help|help) + usage + ;; + -q|--quiet) + OPTION="-a" + shift + ;; + -x|--debug) + enable_debug + shift + ;; + -*) + for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do + case ${_opt} in + q) OPTION="-a" ;; + x) enable_debug ;; + *) error_exit "Unknown Option: \"${1}\"" ;; + esac + done + shift + ;; + *) + break + ;; + esac +done -if [ "${TARGET}" = "ALL" ]; then +if [ "$#" -ne 3 ]; then usage fi -case "${OPTION}" in - -q|--quiet) - OPTION="-a" - ;; - *) - OPTION="-av" - ;; -esac +TARGET="${1}" +CPSOURCE="${2}" +CPDEST="${3}" + +bastille_root_check +set_target "${TARGET}" for _jail in ${JAILS}; do info "[${_jail}]:" bastille_jail_path="${bastille_jailsdir}/${_jail}/root" - cp "${OPTION}" "${bastille_jail_path}/${CPSOURCE}" "${CPDEST}" - RETURN="$?" - echo - return "${RETURN}" + if ! cp "${OPTION}" "${bastille_jail_path}${CPSOURCE}" "${CPDEST}"; then + error_continue "RCP failed: ${bastille_jail_path}${CPSOURCE} -> ${CPDEST}" + fi done From 14d7f4ae741c5b310d93f0914171845294da92de Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sat, 11 Jan 2025 16:52:39 -0700 Subject: [PATCH 03/19] docs: cp documentation update for new functions --- docs/chapters/subcommands/cp.rst | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/chapters/subcommands/cp.rst b/docs/chapters/subcommands/cp.rst index 88c69cfb..e551fb92 100644 --- a/docs/chapters/subcommands/cp.rst +++ b/docs/chapters/subcommands/cp.rst @@ -6,17 +6,27 @@ This command allows efficiently copying files from host to container(s). .. code-block:: shell - ishmael ~ # bastille cp ALL /tmp/resolv.conf-cf etc/resolv.conf + ishmael ~ # bastille cp ALL /tmp/resolv.conf-cf /etc/resolv.conf [bastion]: - + /tmp/resolv.conf-cf -> /usr/local/bastille/jails/bastion/root/etc/resolv.conf [unbound0]: - + /tmp/resolv.conf-cf -> /usr/local/bastille/jails/unbound0/root/etc/resolv.conf [unbound1]: - + /tmp/resolv.conf-cf -> /usr/local/bastille/jails/unbound1/root/etc/resolv.conf [squid]: - + /tmp/resolv.conf-cf -> /usr/local/bastille/jails/squid/root/etc/resolv.conf [nginx]: - + /tmp/resolv.conf-cf -> /usr/local/bastille/jails/nginx/root/etc/resolv.conf [folsom]: + /tmp/resolv.conf-cf -> /usr/local/bastille/jails/folsom/root/etc/resolv.conf Unless you see errors reported in the output the `cp` was successful. + +.. code-block:: shell + + ishmael ~ # bastille cp help + Usage: bastille cp [option(s)] TARGET HOST_PATH JAIL_PATH + Options: + + -q | --quiet Suppress output. + -x | --debug Enable debug mode. From c67ab1879c1e8d14defd6cbc74834099452ba6c9 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sat, 11 Jan 2025 16:59:41 -0700 Subject: [PATCH 04/19] docs: add rcp documentation --- docs/chapters/subcommands/rcp.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 docs/chapters/subcommands/rcp.rst diff --git a/docs/chapters/subcommands/rcp.rst b/docs/chapters/subcommands/rcp.rst new file mode 100644 index 00000000..7b9945d7 --- /dev/null +++ b/docs/chapters/subcommands/rcp.rst @@ -0,0 +1,22 @@ +=== +rcp +=== + +This command allows copying files from a single jail to the host. + +.. code-block:: shell + + ishmael ~ # bastille rcp bastion /tmp/myfile /temp + [bastion]: + /usr/local/bastille/jails/bastion/root/tmp/myfile -> /temp/myfile + +Unless you see errors reported in the output the `rcp` was successful. + +.. code-block:: shell + + ishmael ~ # bastille rcp help + Usage: bastille rcp [option(s)] TARGET JAIL_PATH HOST_PATH + Options: + + -q | --quiet Suppress output. + -x | --debug Enable debug mode. From 816f24331af490eb5be856abbb6b3ace4e9e1159 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sat, 11 Jan 2025 17:20:10 -0700 Subject: [PATCH 05/19] cp: trim double // to / --- usr/local/share/bastille/cp.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index 0dd0b0b0..a1dc0c15 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -89,8 +89,9 @@ set_target "${TARGET}" for _jail in ${JAILS}; do info "[${_jail}]:" - bastille_jail_path="${bastille_jailsdir}/${_jail}/root" - if ! cp "${OPTION}" "${CPSOURCE}" "${bastille_jail_path}${CPDEST}"; then - error_continue "CP failed: ${CPSOURCE} -> ${bastille_jail_path}${CPDEST}" + host_path="${CPSOURCE}" + jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${CPDEST} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${host_path}" "${jail_path}"; then + error_continue "CP failed: ${host_path} -> ${jail_path}" fi done From f65b8c3ebfb8a0e5e1fd828d2a4ed9aa611f71a5 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sat, 11 Jan 2025 17:20:54 -0700 Subject: [PATCH 06/19] rcp: trim // to / and allow only single target --- usr/local/share/bastille/rcp.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/usr/local/share/bastille/rcp.sh b/usr/local/share/bastille/rcp.sh index 7b313577..ec1c5bd5 100644 --- a/usr/local/share/bastille/rcp.sh +++ b/usr/local/share/bastille/rcp.sh @@ -85,12 +85,13 @@ CPSOURCE="${2}" CPDEST="${3}" bastille_root_check -set_target "${TARGET}" +set_target_single "${TARGET}" for _jail in ${JAILS}; do info "[${_jail}]:" - bastille_jail_path="${bastille_jailsdir}/${_jail}/root" - if ! cp "${OPTION}" "${bastille_jail_path}${CPSOURCE}" "${CPDEST}"; then - error_continue "RCP failed: ${bastille_jail_path}${CPSOURCE} -> ${CPDEST}" + host_path="${CPDEST}" + jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${CPSOURCE} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${jail_path}" "${host_path}"; then + error_continue "RCP failed: ${jail_path} -> ${host_path}" fi done From 8e73e6f18806e117636a2350de9a5a66b8920c1d Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Sun, 12 Jan 2025 11:16:51 -0700 Subject: [PATCH 07/19] cp: include rcp in cp and add jail mode --- README.md | 3 +- docs/chapters/subcommands/rcp.rst | 22 ------- usr/local/bin/bastille | 3 +- usr/local/share/bastille/cp.sh | 78 ++++++++++++++++++++----- usr/local/share/bastille/rcp.sh | 97 ------------------------------- 5 files changed, 65 insertions(+), 138 deletions(-) delete mode 100644 docs/chapters/subcommands/rcp.rst delete mode 100644 usr/local/share/bastille/rcp.sh diff --git a/README.md b/README.md index 21746469..1dcc5c7c 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Available Commands: config Get or set a config value for the targeted container(s). console Console into a running container. convert Convert a Thin container into a Thick container. - cp cp(1) files from host to targeted container(s). + cp cp(1) files from host or container to host or targeted container(s). create Create a new thin container or a thick container if -T|--thick option specified. destroy Destroy a stopped container or a FreeBSD release. edit Edit container configuration files (advanced). @@ -75,7 +75,6 @@ Available Commands: mount Mount a volume inside the targeted container(s). pkg Manipulate binary packages within targeted container(s). See pkg(8). rdr Redirect host port to container port. - rcp reverse cp(1) files from a single container to the host. rename Rename a container. restart Restart a running container. service Manage services within targeted container(s). diff --git a/docs/chapters/subcommands/rcp.rst b/docs/chapters/subcommands/rcp.rst deleted file mode 100644 index 7b9945d7..00000000 --- a/docs/chapters/subcommands/rcp.rst +++ /dev/null @@ -1,22 +0,0 @@ -=== -rcp -=== - -This command allows copying files from a single jail to the host. - -.. code-block:: shell - - ishmael ~ # bastille rcp bastion /tmp/myfile /temp - [bastion]: - /usr/local/bastille/jails/bastion/root/tmp/myfile -> /temp/myfile - -Unless you see errors reported in the output the `rcp` was successful. - -.. code-block:: shell - - ishmael ~ # bastille rcp help - Usage: bastille rcp [option(s)] TARGET JAIL_PATH HOST_PATH - Options: - - -q | --quiet Suppress output. - -x | --debug Enable debug mode. diff --git a/usr/local/bin/bastille b/usr/local/bin/bastille index c5442daf..3799429c 100755 --- a/usr/local/bin/bastille +++ b/usr/local/bin/bastille @@ -95,7 +95,7 @@ Available Commands: config Get or set a config value for the targeted container(s). console Console into a running container. convert Convert a Thin container into a Thick container. - cp cp(1) files from host to targeted container(s). + cp cp(1) files from host or container to host or targeted container(s). create Create a new thin container or a thick container if -T|--thick option specified. destroy Destroy a stopped container or a FreeBSD release. edit Edit container configuration files (advanced). @@ -107,7 +107,6 @@ Available Commands: list List containers (running). mount Mount a volume inside the targeted container(s). pkg Manipulate binary packages within targeted container(s). See pkg(8). - rcp reverse cp(1) files from a single container to the host. rdr Redirect host port to container port. rename Rename a container. restart Restart a running container. diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index a1dc0c15..b0141327 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -34,24 +34,37 @@ . /usr/local/etc/bastille/bastille.conf usage() { - error_notify "Usage: bastille cp [option(s)] TARGET HOST_PATH JAIL_PATH" + error_notify "Usage: bastille cp [option(s)] TARGET SOURCE DESTINATION" cat << EOF Options: - -q | --quiet Suppress output. - -x | --debug Enable debug mode. + -j | --jail Jail mode. Copy files from jail to jail(s). + Syntax is [-j jail:srcpath jail:dstpath] + -r | --reverse Reverse copy files from jail to host. + -q | --quiet Suppress output. + -x | --debug Enable debug mode. EOF exit 1 } # Handle options. +JAIL_MODE=0 OPTION="-av" +REVERSE_MODE=0 while [ "$#" -gt 0 ]; do case "${1}" in -h|--help|help) usage ;; + -j|--jail) + JAIL_MODE=1 + shift + ;; + -r|--reverse) + REVERSE_MODE=1 + shift + ;; -q|--quiet) OPTION="-a" shift @@ -63,6 +76,8 @@ while [ "$#" -gt 0 ]; do -*) for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do case ${_opt} in + j) JAIL_MODE=1 ;; + r) REVERSE_MODE=1 ;; q) OPTION="-a" ;; x) enable_debug ;; *) error_exit "Unknown Option: \"${1}\"" ;; @@ -76,22 +91,55 @@ while [ "$#" -gt 0 ]; do esac done -if [ "$#" -ne 3 ]; then +if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then usage fi +if [ "${JAIL_MODE}" -eq 1 ]; then + SOURCE_TARGET="$(echo ${1} | awk -F":" '{print $1}')" + SOURCE_PATH="$(echo ${1} | awk -F":" '{print $2}')" + DEST_TARGET="$(echo ${2} | awk -F":" '{print $1}')" + DEST_PATH="$(echo ${2} | awk -F":" '{print $2}')" + set_target_single "${SOURCE_TARGET}" && SOURCE_TARGET="${TARGET}" + set_target "${DEST_TARGET}" && DEST_TARGET="${JAILS}" + for _jail in ${DEST_TARGET}; do + if [ "${_jail}" = "${SOURCE_TARGET}" ]; then + continue + fi + info "[${_jail}]:" + source_path="$(echo ${bastille_jailsdir}/${SOURCE_TARGET}/root/${SOURCE_PATH} | sed 's#//#/#g')" + dest_path="$(echo ${bastille_jailsdir}/${_jail}/root/${DEST_PATH} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${source_path}" "${dest_path}"; then + error_continue "CP failed: ${source_path} -> ${dest_path}" + fi + done + exit +fi + TARGET="${1}" -CPSOURCE="${2}" -CPDEST="${3}" +SOURCE="${2}" +DEST="${3}" bastille_root_check -set_target "${TARGET}" -for _jail in ${JAILS}; do - info "[${_jail}]:" - host_path="${CPSOURCE}" - jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${CPDEST} | sed 's#//#/#g')" - if ! cp "${OPTION}" "${host_path}" "${jail_path}"; then - error_continue "CP failed: ${host_path} -> ${jail_path}" - fi -done +if [ "${REVERSE_MODE}" -eq 1 ]; then + set_target_single "${TARGET}" + for _jail in ${JAILS}; do + info "[${_jail}]:" + host_path="${DEST}" + jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${SOURCE} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${jail_path}" "${host_path}"; then + error_exit "RCP failed: ${jail_path} -> ${host_path}" + fi + done +else + set_target "${TARGET}" + for _jail in ${JAILS}; do + info "[${_jail}]:" + host_path="${SOURCE}" + jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${DEST} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${host_path}" "${jail_path}"; then + error_continue "CP failed: ${host_path} -> ${jail_path}" + fi + done +fi \ No newline at end of file diff --git a/usr/local/share/bastille/rcp.sh b/usr/local/share/bastille/rcp.sh deleted file mode 100644 index ec1c5bd5..00000000 --- a/usr/local/share/bastille/rcp.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh -# -# SPDX-License-Identifier: BSD-3-Clause -# -# Copyright (c) 2018-2025, Christer Edwards -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# * Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# * Neither the name of the copyright holder nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -. /usr/local/share/bastille/common.sh -. /usr/local/etc/bastille/bastille.conf - -usage() { - error_notify "Usage: bastille rcp [option(s)] TARGET JAIL_PATH HOST_PATH" - cat << EOF - Options: - - -q | --quiet Suppress output. - -x | --debug Enable debug mode. - -EOF - exit 1 -} - -# Handle options. -OPTION="-av" -while [ "$#" -gt 0 ]; do - case "${1}" in - -h|--help|help) - usage - ;; - -q|--quiet) - OPTION="-a" - shift - ;; - -x|--debug) - enable_debug - shift - ;; - -*) - for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do - case ${_opt} in - q) OPTION="-a" ;; - x) enable_debug ;; - *) error_exit "Unknown Option: \"${1}\"" ;; - esac - done - shift - ;; - *) - break - ;; - esac -done - -if [ "$#" -ne 3 ]; then - usage -fi - -TARGET="${1}" -CPSOURCE="${2}" -CPDEST="${3}" - -bastille_root_check -set_target_single "${TARGET}" - -for _jail in ${JAILS}; do - info "[${_jail}]:" - host_path="${CPDEST}" - jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${CPSOURCE} | sed 's#//#/#g')" - if ! cp "${OPTION}" "${jail_path}" "${host_path}"; then - error_continue "RCP failed: ${jail_path} -> ${host_path}" - fi -done From 628f0fac34fc2d743a24676a126aaa9131da57ae Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:37:59 -0700 Subject: [PATCH 08/19] bastille: move cp to no action commands --- usr/local/bin/bastille | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/local/bin/bastille b/usr/local/bin/bastille index 3799429c..a01777e3 100755 --- a/usr/local/bin/bastille +++ b/usr/local/bin/bastille @@ -162,10 +162,10 @@ version|-v|--version) help|-h|--help) usage ;; -bootstrap|create|destroy|export|htop|import|list|mount|rdr|restart|setup|start|top|umount|update|upgrade|verify) +bootstrap|create|cp|destroy|export|htop|import|list|mount|rdr|restart|setup|start|top|umount|update|upgrade|verify) # Nothing "extra" to do for these commands. -- cwells ;; -clone|config|cmd|console|convert|cp|edit|limits|pkg|rcp|rename|service|stop|sysrc|tags|template|zfs) +clone|config|cmd|console|convert|edit|limits|pkg|rcp|rename|service|stop|sysrc|tags|template|zfs) # Parse the target and ensure it exists. -- cwells if [ $# -eq 0 ]; then # No target was given, so show the command's help. -- cwells PARAMS='help' From 1cfbe6b5e01aa8e618a4568156b1b4db06cd4749 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Mon, 13 Jan 2025 19:39:34 -0700 Subject: [PATCH 09/19] bastille: remove rcp --- usr/local/bin/bastille | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/bin/bastille b/usr/local/bin/bastille index a01777e3..14c9d927 100755 --- a/usr/local/bin/bastille +++ b/usr/local/bin/bastille @@ -165,7 +165,7 @@ help|-h|--help) bootstrap|create|cp|destroy|export|htop|import|list|mount|rdr|restart|setup|start|top|umount|update|upgrade|verify) # Nothing "extra" to do for these commands. -- cwells ;; -clone|config|cmd|console|convert|edit|limits|pkg|rcp|rename|service|stop|sysrc|tags|template|zfs) +clone|config|cmd|console|convert|edit|limits|pkg|rename|service|stop|sysrc|tags|template|zfs) # Parse the target and ensure it exists. -- cwells if [ $# -eq 0 ]; then # No target was given, so show the command's help. -- cwells PARAMS='help' From 22831e4b8296a83b4f36a3756c1bda8e09f7d264 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Mon, 20 Jan 2025 18:47:58 -0700 Subject: [PATCH 10/19] cp: Exit it -j and -r are both set --- usr/local/share/bastille/cp.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index b0141327..ac6d8c2d 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -39,7 +39,7 @@ usage() { Options: -j | --jail Jail mode. Copy files from jail to jail(s). - Syntax is [-j jail:srcpath jail:dstpath] + Syntax: [-j jail:srcpath jail:dstpath] -r | --reverse Reverse copy files from jail to host. -q | --quiet Suppress output. -x | --debug Enable debug mode. @@ -95,6 +95,10 @@ if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then usage fi +if [ "${JAIL_MODE}" -eq 1 ] && [ "${REVERSE_MODE}" -eq 1 ]; then + error_exit "[-j|--jail] cannot be used with [-r|reverse]" +fi + if [ "${JAIL_MODE}" -eq 1 ]; then SOURCE_TARGET="$(echo ${1} | awk -F":" '{print $1}')" SOURCE_PATH="$(echo ${1} | awk -F":" '{print $2}')" @@ -142,4 +146,4 @@ else error_continue "CP failed: ${host_path} -> ${jail_path}" fi done -fi \ No newline at end of file +fi From 5746af35816a0535ff7b822767db099df95bdab5 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Mon, 20 Jan 2025 18:50:06 -0700 Subject: [PATCH 11/19] common: Add debug mode --- usr/local/share/bastille/common.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/usr/local/share/bastille/common.sh b/usr/local/share/bastille/common.sh index 654ff026..dd8be78c 100644 --- a/usr/local/share/bastille/common.sh +++ b/usr/local/share/bastille/common.sh @@ -61,6 +61,12 @@ error_notify() { echo -e "${COLOR_RED}$*${COLOR_RESET}" 1>&2 } +enable_debug() { + # Enable debug mode. + warn "***DEBUG MODE***" + set -x +} + error_continue() { error_notify "$@" # Disabling this shellcheck as we only ever call it inside of a loop From 4c2539dd8d11c7861b5a688b5c24ec63bbaac0c3 Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Tue, 21 Jan 2025 07:41:01 -0700 Subject: [PATCH 12/19] copy: Add jcp for jail to jail copy --- usr/local/share/bastille/cp.sh | 84 +++++--------------------- usr/local/share/bastille/jcp.sh | 102 ++++++++++++++++++++++++++++++++ usr/local/share/bastille/rcp.sh | 97 ++++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+), 68 deletions(-) create mode 100644 usr/local/share/bastille/jcp.sh create mode 100644 usr/local/share/bastille/rcp.sh diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index ac6d8c2d..33436b34 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -34,36 +34,23 @@ . /usr/local/etc/bastille/bastille.conf usage() { - error_notify "Usage: bastille cp [option(s)] TARGET SOURCE DESTINATION" + error_notify "Usage: bastille cp [option(s)] TARGET HOST_PATH JAIL_PATH" cat << EOF Options: - -j | --jail Jail mode. Copy files from jail to jail(s). - Syntax: [-j jail:srcpath jail:dstpath] - -r | --reverse Reverse copy files from jail to host. - -q | --quiet Suppress output. - -x | --debug Enable debug mode. + -q | --quiet Suppress output. + -x | --debug Enable debug mode. EOF exit 1 } # Handle options. -JAIL_MODE=0 OPTION="-av" -REVERSE_MODE=0 while [ "$#" -gt 0 ]; do case "${1}" in - -h|--help|help) - usage - ;; - -j|--jail) - JAIL_MODE=1 - shift - ;; - -r|--reverse) - REVERSE_MODE=1 - shift + -h|--help|help) + usage ;; -q|--quiet) OPTION="-a" @@ -76,8 +63,6 @@ while [ "$#" -gt 0 ]; do -*) for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do case ${_opt} in - j) JAIL_MODE=1 ;; - r) REVERSE_MODE=1 ;; q) OPTION="-a" ;; x) enable_debug ;; *) error_exit "Unknown Option: \"${1}\"" ;; @@ -95,55 +80,18 @@ if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then usage fi -if [ "${JAIL_MODE}" -eq 1 ] && [ "${REVERSE_MODE}" -eq 1 ]; then - error_exit "[-j|--jail] cannot be used with [-r|reverse]" -fi - -if [ "${JAIL_MODE}" -eq 1 ]; then - SOURCE_TARGET="$(echo ${1} | awk -F":" '{print $1}')" - SOURCE_PATH="$(echo ${1} | awk -F":" '{print $2}')" - DEST_TARGET="$(echo ${2} | awk -F":" '{print $1}')" - DEST_PATH="$(echo ${2} | awk -F":" '{print $2}')" - set_target_single "${SOURCE_TARGET}" && SOURCE_TARGET="${TARGET}" - set_target "${DEST_TARGET}" && DEST_TARGET="${JAILS}" - for _jail in ${DEST_TARGET}; do - if [ "${_jail}" = "${SOURCE_TARGET}" ]; then - continue - fi - info "[${_jail}]:" - source_path="$(echo ${bastille_jailsdir}/${SOURCE_TARGET}/root/${SOURCE_PATH} | sed 's#//#/#g')" - dest_path="$(echo ${bastille_jailsdir}/${_jail}/root/${DEST_PATH} | sed 's#//#/#g')" - if ! cp "${OPTION}" "${source_path}" "${dest_path}"; then - error_continue "CP failed: ${source_path} -> ${dest_path}" - fi - done - exit -fi - TARGET="${1}" -SOURCE="${2}" -DEST="${3}" +HOST_PATH="${2}" +JAIL_PATH="${3}" bastille_root_check +set_target "${TARGET}" -if [ "${REVERSE_MODE}" -eq 1 ]; then - set_target_single "${TARGET}" - for _jail in ${JAILS}; do - info "[${_jail}]:" - host_path="${DEST}" - jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${SOURCE} | sed 's#//#/#g')" - if ! cp "${OPTION}" "${jail_path}" "${host_path}"; then - error_exit "RCP failed: ${jail_path} -> ${host_path}" - fi - done -else - set_target "${TARGET}" - for _jail in ${JAILS}; do - info "[${_jail}]:" - host_path="${SOURCE}" - jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${DEST} | sed 's#//#/#g')" - if ! cp "${OPTION}" "${host_path}" "${jail_path}"; then - error_continue "CP failed: ${host_path} -> ${jail_path}" - fi - done -fi +for _jail in ${JAILS}; do + info "[${_jail}]:" + host_path="${HOST_PATH}" + jail_path="$(echo ${bastille_jailsdir}/${_jail}/root/${JAIL_PATH} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${host_path}" "${jail_path}"; then + error_continue "CP failed: ${host_path} -> ${jail_path}" + fi +done \ No newline at end of file diff --git a/usr/local/share/bastille/jcp.sh b/usr/local/share/bastille/jcp.sh new file mode 100644 index 00000000..bd0e4870 --- /dev/null +++ b/usr/local/share/bastille/jcp.sh @@ -0,0 +1,102 @@ +#!/bin/sh +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright (c) 2018-2025, Christer Edwards +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +. /usr/local/share/bastille/common.sh +. /usr/local/etc/bastille/bastille.conf + +usage() { + error_notify "Usage: bastille jcp [option(s)] SOURCE_JAIL JAIL_PATH DEST_JAIL JAIL_PATH" + cat << EOF + Options: + + -q | --quiet Suppress output. + -x | --debug Enable debug mode. + +EOF + exit 1 +} + +# Handle options. +OPTION="-av" +while [ "$#" -gt 0 ]; do + case "${1}" in + -h|--help|help) + usage + ;; + -q|--quiet) + OPTION="-a" + shift + ;; + -x|--debug) + enable_debug + shift + ;; + -*) + for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do + case ${_opt} in + q) OPTION="-a" ;; + x) enable_debug ;; + *) error_exit "Unknown Option: \"${1}\"" ;; + esac + done + shift + ;; + *) + break + ;; + esac +done + +if [ "$#" -ne 4 ]; then + usage +fi + +SOURCE_TARGET="${1}" +SOURCE_PATH="${2}" +DEST_TARGET="${3}" +DEST_PATH="${4}" + +bastille_root_check +set_target_single "${SOURCE_TARGET}" && SOURCE_TARGET="${TARGET}" +set_target "${DEST_TARGET}" && DEST_TARGET="${JAILS}" + +for _jail in ${DEST_TARGET}; do + if [ "${_jail}" = "${SOURCE_TARGET}" ]; then + continue + else + info "[${_jail}]:" + source_path="$(echo ${bastille_jailsdir}/${SOURCE_TARGET}/root/${SOURCE_PATH} | sed 's#//#/#g')" + dest_path="$(echo ${bastille_jailsdir}/${_jail}/root/${DEST_PATH} | sed 's#//#/#g')" + if ! cp "${OPTION}" "${source_path}" "${dest_path}"; then + error_continue "JCP failed: ${source_path} -> ${dest_path}" + fi +done \ No newline at end of file diff --git a/usr/local/share/bastille/rcp.sh b/usr/local/share/bastille/rcp.sh new file mode 100644 index 00000000..c0828ecb --- /dev/null +++ b/usr/local/share/bastille/rcp.sh @@ -0,0 +1,97 @@ +#!/bin/sh +# +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright (c) 2018-2025, Christer Edwards +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# * Neither the name of the copyright holder nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +. /usr/local/share/bastille/common.sh +. /usr/local/etc/bastille/bastille.conf + +usage() { + error_notify "Usage: bastille rcp [option(s)] TARGET JAIL_PATH HOST_PATH" + cat << EOF + Options: + + -q | --quiet Suppress output. + -x | --debug Enable debug mode. + +EOF + exit 1 +} + +# Handle options. +OPTION="-av" +while [ "$#" -gt 0 ]; do + case "${1}" in + -h|--help|help) + usage + ;; + -q|--quiet) + OPTION="-a" + shift + ;; + -x|--debug) + enable_debug + shift + ;; + -*) + for _opt in $(echo ${1} | sed 's/-//g' | fold -w1); do + case ${_opt} in + q) OPTION="-a" ;; + x) enable_debug ;; + *) error_exit "Unknown Option: \"${1}\"" ;; + esac + done + shift + ;; + *) + break + ;; + esac +done + +if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then + usage +fi + +TARGET="${1}" +JAIL_PATH="${2}" +HOST_PATH="${3}" + +bastille_root_check +set_target_single "${TARGET}" + +info "[${TARGET}]:" + +host_path="${HOST_PATH}" +jail_path="$(echo ${bastille_jailsdir}/${TARGET}/root/${JAIL_PATH} | sed 's#//#/#g')" + +if ! cp "${OPTION}" "${jail_path}" "${host_path}"; then + error_exit "RCP failed: ${jail_path} -> ${host_path}" +fi From 086f4a60a5d727643d0d0d5615706f7889b3beab Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Tue, 21 Jan 2025 07:42:41 -0700 Subject: [PATCH 13/19] jcp: Add missing fi --- usr/local/share/bastille/jcp.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/usr/local/share/bastille/jcp.sh b/usr/local/share/bastille/jcp.sh index bd0e4870..fc8cf05e 100644 --- a/usr/local/share/bastille/jcp.sh +++ b/usr/local/share/bastille/jcp.sh @@ -99,4 +99,5 @@ for _jail in ${DEST_TARGET}; do if ! cp "${OPTION}" "${source_path}" "${dest_path}"; then error_continue "JCP failed: ${source_path} -> ${dest_path}" fi + fi done \ No newline at end of file From 708c9c3b4d0e51db81d9bfe86676582ddae39313 Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Tue, 21 Jan 2025 07:48:09 -0700 Subject: [PATCH 14/19] bastille: Add jcp/rcp to commands --- usr/local/bin/bastille | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/local/bin/bastille b/usr/local/bin/bastille index fe651702..e293d69d 100755 --- a/usr/local/bin/bastille +++ b/usr/local/bin/bastille @@ -95,7 +95,7 @@ Available Commands: config Get or set a config value for the targeted container(s). console Console into a running container. convert Convert a Thin container into a Thick container. - cp cp(1) files from host or container to host or targeted container(s). + cp cp(1) files from host to jail(s). create Create a new thin container or a thick container if -T|--thick option specified. destroy Destroy a stopped container or a FreeBSD release. edit Edit container configuration files (advanced). @@ -103,11 +103,13 @@ Available Commands: export Exports a specified container. help Help about any command. htop Interactive process viewer (requires htop). + jcp cp(1) files from a jail to jail(s). import Import a specified container. limits Apply resources limits to targeted container(s). See rctl(8). list List containers (running). mount Mount a volume inside the targeted container(s). pkg Manipulate binary packages within targeted container(s). See pkg(8). + rcp cp(1) files from a jail to host. rdr Redirect host port to container port. rename Rename a container. restart Restart a running container. @@ -163,7 +165,7 @@ version|-v|--version) help|-h|--help) usage ;; -bootstrap|create|cp|destroy|etcupdate|export|htop|import|list|mount|rdr|restart|setup|start|top|umount|update|upgrade|verify) +bootstrap|create|cp|destroy|etcupdate|export|htop|import|jcp|list|mount|rcp|rdr|restart|setup|start|top|umount|update|upgrade|verify) # Nothing "extra" to do for these commands. -- cwells ;; clone|config|cmd|console|convert|edit|limits|pkg|rename|service|stop|sysrc|tags|template|zfs) From 42d1c1305849d51c1ea67f65cbf5561874a4c7dd Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Tue, 21 Jan 2025 07:58:56 -0700 Subject: [PATCH 15/19] cp: Allow only 3 arcs --- usr/local/share/bastille/cp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index 33436b34..0d1b53a1 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -76,7 +76,7 @@ while [ "$#" -gt 0 ]; do esac done -if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then +if [ "$#" -ne 3 ]; then usage fi From 25cc612f46d8c9eb098efa2579a00f745e67deab Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Tue, 21 Jan 2025 07:59:55 -0700 Subject: [PATCH 16/19] rcp: Allow only 3 args --- usr/local/share/bastille/rcp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/local/share/bastille/rcp.sh b/usr/local/share/bastille/rcp.sh index c0828ecb..f3880a0f 100644 --- a/usr/local/share/bastille/rcp.sh +++ b/usr/local/share/bastille/rcp.sh @@ -76,7 +76,7 @@ while [ "$#" -gt 0 ]; do esac done -if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then +if [ "$#" -ne 3 ]; then usage fi From 9c0b600bc59bf2b7eed476edab3e52b5ea426e5f Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Tue, 21 Jan 2025 08:14:09 -0700 Subject: [PATCH 17/19] docs: Document new jcp command --- docs/chapters/subcommands/cp.rst | 2 +- docs/chapters/subcommands/jcp.rst | 30 ++++++++++++++++++++++++++++++ docs/chapters/subcommands/rcp.rst | 22 ++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 docs/chapters/subcommands/jcp.rst create mode 100644 docs/chapters/subcommands/rcp.rst diff --git a/docs/chapters/subcommands/cp.rst b/docs/chapters/subcommands/cp.rst index e551fb92..57b610b9 100644 --- a/docs/chapters/subcommands/cp.rst +++ b/docs/chapters/subcommands/cp.rst @@ -2,7 +2,7 @@ cp == -This command allows efficiently copying files from host to container(s). +This command allows copying files from host to jail(s). .. code-block:: shell diff --git a/docs/chapters/subcommands/jcp.rst b/docs/chapters/subcommands/jcp.rst new file mode 100644 index 00000000..fbaeee05 --- /dev/null +++ b/docs/chapters/subcommands/jcp.rst @@ -0,0 +1,30 @@ +=== +jcp +=== + +This command allows copying files from jail to jail(s). + +.. code-block:: shell + + ishmael ~ # bastille cp bastion /tmp/resolv.conf-cf ALL /etc/resolv.conf + [unbound0]: + /usr/local/bastille/jails/bastion/root/tmp/resolv.conf-cf -> /usr/local/bastille/jails/unbound0/root/etc/resolv.conf + [unbound1]: + /usr/local/bastille/jails/bastion/root/tmp/resolv.conf-cf -> /usr/local/bastille/jails/unbound1/root/etc/resolv.conf + [squid]: + /usr/local/bastille/jails/bastion/root/tmp/resolv.conf-cf -> /usr/local/bastille/jails/squid/root/etc/resolv.conf + [nginx]: + /usr/local/bastille/jails/bastion/root/tmp/resolv.conf-cf -> /usr/local/bastille/jails/nginx/root/etc/resolv.conf + [folsom]: + /usr/local/bastille/jails/bastion/root/tmp/resolv.conf-cf -> /usr/local/bastille/jails/folsom/root/etc/resolv.conf + +Unless you see errors reported in the output the `jcp` was successful. + +.. code-block:: shell + + ishmael ~ # bastille cp help + Usage: bastille jcp [option(s)] SOURCE_JAIL JAIL_PATH DEST_JAIL JAIL_PATH + Options: + + -q | --quiet Suppress output. + -x | --debug Enable debug mode. diff --git a/docs/chapters/subcommands/rcp.rst b/docs/chapters/subcommands/rcp.rst new file mode 100644 index 00000000..fd4ab86f --- /dev/null +++ b/docs/chapters/subcommands/rcp.rst @@ -0,0 +1,22 @@ +=== +rcp +=== + +This command allows copying files from jail to host. + +.. code-block:: shell + + ishmael ~ # bastille rcp bastion /test/testfile.txt /tmp/testfile.txt + [bastion]: + /usr/local/bastille/jails/bastion/root/test/testfile.txt -> /tmp/testfile.txt + +Unless you see errors reported in the output the `rcp` was successful. + +.. code-block:: shell + + ishmael ~ # bastille rcp help + Usage: bastille rcp [option(s)] TARGET JAIL_PATH HOST_PATH + Options: + + -q | --quiet Suppress output. + -x | --debug Enable debug mode. From fe1eb18fbdf803c3ad4b7e2e82fac2539483390e Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sun, 26 Jan 2025 12:53:49 -0700 Subject: [PATCH 18/19] docs: Typo in jcp --- docs/chapters/subcommands/jcp.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/chapters/subcommands/jcp.rst b/docs/chapters/subcommands/jcp.rst index fbaeee05..6dca3c3d 100644 --- a/docs/chapters/subcommands/jcp.rst +++ b/docs/chapters/subcommands/jcp.rst @@ -6,7 +6,7 @@ This command allows copying files from jail to jail(s). .. code-block:: shell - ishmael ~ # bastille cp bastion /tmp/resolv.conf-cf ALL /etc/resolv.conf + ishmael ~ # bastille jcp bastion /tmp/resolv.conf-cf ALL /etc/resolv.conf [unbound0]: /usr/local/bastille/jails/bastion/root/tmp/resolv.conf-cf -> /usr/local/bastille/jails/unbound0/root/etc/resolv.conf [unbound1]: @@ -22,7 +22,7 @@ Unless you see errors reported in the output the `jcp` was successful. .. code-block:: shell - ishmael ~ # bastille cp help + ishmael ~ # bastille jcp help Usage: bastille jcp [option(s)] SOURCE_JAIL JAIL_PATH DEST_JAIL JAIL_PATH Options: From 43e186899dbfd3d6f30d06dbaa4d697898bec9eb Mon Sep 17 00:00:00 2001 From: tschettervictor <85497460+tschettervictor@users.noreply.github.com> Date: Sun, 26 Jan 2025 19:40:07 -0700 Subject: [PATCH 19/19] README: Fix reference to rcp --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1dcc5c7c..4ce958c3 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Available Commands: list List containers (running). mount Mount a volume inside the targeted container(s). pkg Manipulate binary packages within targeted container(s). See pkg(8). + rcp cp(1) files from a jail to host. rdr Redirect host port to container port. rename Rename a container. restart Restart a running container.