Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for mountpoints wrongly creating // #767

Closed
wants to merge 10 commits into from
10 changes: 8 additions & 2 deletions docs/chapters/subcommands/mount.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ To mount storage within the container use `bastille mount`.

.. code-block:: shell

ishmael ~ # bastille mount azkaban /storage/foo /media/foo nullfs ro 0 0
ishmael ~ # bastille mount azkaban /storage/foo media/foo nullfs ro 0 0
[azkaban]:
Added: /media/foo /usr/local/bastille/jails/azkaban/root/media/foo
ishmael ~ # bastille mount azkaban /storage/bar /media/bar nullfs ro 0 0
[azkaban]:
Added: /media/bar /usr/local/bastille/jails/azkaban/root/media/bar

Notice the JAIL_PATH format can be /media/foo or simply media/bar. The leading slash / is optional. The HOST_PATH howerver, must be the full path including the leading slash /.

Syntax follows standard `/etc/fstab` format:

.. code-block:: shell

Usage: bastille mount TARGET host_path container_path [filesystem_type options dump pass_number]
Usage: bastille mount TARGET HOST_PATH JAIL_PATH [filesystem_type options dump pass_number]
12 changes: 6 additions & 6 deletions usr/local/share/bastille/mount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
. /usr/local/etc/bastille/bastille.conf

usage() {
error_exit "Usage: bastille mount TARGET host_path container_path [filesystem_type options dump pass_number]"
error_exit "Usage: bastille mount TARGET HOST_PATH JAIL_PATH [filesystem_type options dump pass_number]"
}

# Handle special-case commands first.
case "$1" in
help|-h|--help)
usage
;;
case "${1}" in
help|-h|--help)
usage
;;
esac

if [ $# -lt 2 ]; then
Expand Down Expand Up @@ -102,7 +102,7 @@ for _jail in ${JAILS}; do
info "[${_jail}]:"

## aggregate variables into FSTAB entry
_fullpath="${bastille_jailsdir}/${_jail}/root/${_jailpath}"
_fullpath="$( echo ${bastille_jailsdir}/${_jail}/root/${_jailpath} 2>/dev/null | sed 's#//#/#' )"
_fstab_entry="${_hostpath} ${_fullpath} ${_type} ${_perms} ${_checks}"

## Create mount point if it does not exist. -- cwells
Expand Down
14 changes: 7 additions & 7 deletions usr/local/share/bastille/umount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
. /usr/local/etc/bastille/bastille.conf

usage() {
error_exit "Usage: bastille umount TARGET container_path"
error_exit "Usage: bastille umount TARGET JAIL_PATH"
}

# Handle special-case commands first.
case "$1" in
help|-h|--help)
usage
;;
case "${1}" in
help|-h|--help)
usage
;;
esac

if [ $# -ne 1 ]; then
Expand All @@ -48,12 +48,12 @@ fi

bastille_root_check

MOUNT_PATH=$1
MOUNT_PATH=${1}

for _jail in ${JAILS}; do
info "[${_jail}]:"

_jailpath="${bastille_jailsdir}/${_jail}/root/${MOUNT_PATH}"
_jailpath="$( echo ${bastille_jailsdir}/${_jail}/root/${MOUNT_PATH} 2>/dev/null | sed 's#//#/#' )"

if [ ! -d "${_jailpath}" ]; then
error_exit "The specified mount point does not exist inside the jail."
Expand Down