diff options
author | mux <mux@FreeBSD.org> | 2004-11-23 20:09:58 +0000 |
---|---|---|
committer | mux <mux@FreeBSD.org> | 2004-11-23 20:09:58 +0000 |
commit | c6e2c549c210e861b6037e36243520ab227c9696 (patch) | |
tree | 2206b4dae242c9d0a03949735b79871ea732a92d | |
parent | a73c9ef46aca08b05b3abbd9dbd791799d71ea93 (diff) | |
download | FreeBSD-src-c6e2c549c210e861b6037e36243520ab227c9696.zip FreeBSD-src-c6e2c549c210e861b6037e36243520ab227c9696.tar.gz |
Implement per-jail fstab(5) files. Here's a rc.conf sample using
this feature for a jail named foo :
jail_foo_mount_enable="YES"
jail_foo_fstab="/etc/fstab.foo"
The second line is actually useless, since the code defaults to
using "/etc/fstab.$jailname" as the fstab file if none is specified.
MFC after: 3 days
Submitted by: Jeremie Le Hen <jeremie@le-hen.org>
-rw-r--r-- | etc/defaults/rc.conf | 2 | ||||
-rw-r--r-- | etc/rc.d/jail | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index cfc8dd6..92136e3 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -497,7 +497,9 @@ jail_sysvipc_allow="NO" # Allow SystemV IPC use from within a jail #jail_example_devfs_enable="NO" # mount devfs in the jail #jail_example_fdescfs_enable="NO" # mount fdescfs in the jail #jail_example_procfs_enable="NO" # mount procfs in jail +#jail_example_mount_enable="NO" # mount/umount jail's fs #jail_example_devfs_ruleset="ruleset_name" # devfs ruleset to apply to jail +#jail_example_fstab="" # fstab(5) for mount/umount ############################################################## ### Define source_rc_confs, the mechanism used by /etc/rc.* ## diff --git a/etc/rc.d/jail b/etc/rc.d/jail index bdb797a..a144b94f 100644 --- a/etc/rc.d/jail +++ b/etc/rc.d/jail @@ -45,11 +45,18 @@ init_variables() eval jail_procfs=\"\$jail_${_j}_procfs_enable\" [ -z "${jail_procfs}" ] && jail_procfs="NO" + eval jail_mount=\"\$jail_${_j}_mount_enable\" + [ -z "${jail_mount}" ] && jail_mount="NO" + # "/etc/fstab.${_j}" will be used for {,u}mount(8) if none is specified. + eval jail_fstab=\"\$jail_${_j}_fstab\" + [ -z "${jail_fstab}" ] && jail_fstab="/etc/fstab.${_j}" + # Debugging aid # debug "$_j devfs enable: $jail_devfs" debug "$_j fdescfs enable: $jail_fdescfs" debug "$_j procfs enable: $jail_procfs" + debug "$_j mount enable: $jail_mount" debug "$_j hostname: $jail_hostname" debug "$_j ip: $jail_ip" debug "$_j root: $jail_rootdir" @@ -57,6 +64,7 @@ init_variables() debug "$_j fdescdir: $jail_fdescdir" debug "$_j procdir: $jail_procdir" debug "$_j ruleset: $jail_ruleset" + debug "$_j fstab: $jail_fstab" } # set_sysctl rc_knob mib msg @@ -108,6 +116,10 @@ jail_umount_fs() umount -f ${jail_procdir} >/dev/null 2>&1 fi fi + if checkyesno jail_mount; then + [ -f "${jail_fstab}" ] || warn "${jail_fstab} does not exist" + umount -a -F "${jail_fstab}" >/dev/null 2>&1 + fi } jail_start() @@ -127,6 +139,13 @@ jail_start() for _jail in ${jail_list} do init_variables $_jail + if checkyesno jail_mount; then + info "Mounting fstab for jail ${_jail} (${jail_fstab})" + if [ ! -f "${jail_fstab}" ]; then + err 3 "$name: ${jail_fstab} doest not exist" + fi + mount -a -F "${jail_fstab}" + fi if checkyesno jail_devfs; then info "Mounting devfs on ${jail_devdir}" devfs_mount_jail "${jail_devdir}" ${jail_ruleset} |