Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff sbin/fjail @ 328:184412e2543e
Implement the -d option for fjail configure: temporarily mount a devfs filesystem
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 30 Nov 2022 09:46:29 +0100 |
| parents | 90fa5b68bb62 |
| children | 2623f7e775e3 |
line wrap: on
line diff
--- a/sbin/fjail Tue Nov 29 11:10:24 2022 +0100 +++ b/sbin/fjail Wed Nov 30 09:46:29 2022 +0100 @@ -57,7 +57,7 @@ Populate the jail directory in MOUNTPOINT with the base system in BASETXZ - configure MOUNTPOINT + configure [OPTIONS] MOUNTPOINT Configure some basic parts of the system at MOUNTPOINT: disable root password, syslog and other basic configuration settings @@ -65,6 +65,8 @@ Also handle thin jails by checking whether "etc" is a symlink to "skeleton/etc". + -d Temporarily mount a devfs filesystem to MOUNTPOINT/dev + hostid Print proposals for a hostuuid and hostid @@ -359,8 +361,29 @@ command_configure() { # mountpoint local _mp + local _opt_devfs - local _pcl + local _pcl _umount_devfs + + _umount_devfs="" + + _opt_devfs="" + while getopts "d" _opt ; do + case ${_opt} in + d) + _opt_devfs="yes" + ;; + \?) + return 2; + ;; + *) + echo "ERROR: option handling failed" 1>&2 + return 2 + ;; + esac + done + shift $((OPTIND-1)) + OPTIND=1 _mp="$1" @@ -373,6 +396,16 @@ return 1 fi + if [ "${_opt_devfs}" = "yes" ]; then + if [ ! -c "{_mp}/dev/null" ]; then + echo "Mounting devfs" + mount -t devfs devfs "${_mp}/dev" + _umount_devfs="yes" + else + echo "devfs is already mounted" + fi + fi + # Deactive the by default empty root password pw -R "${_mp}" usermod -w no -n root @@ -432,6 +465,11 @@ fi command_hostid + + if [ "${_umount_devfs}" = "yes" ]; then + echo "Unmounting devfs" + umount "{_mp}/dev" + fi }
