comparison sbin/fjail @ 331:4a17b1f4c378

Require a mounted and working devfs within the jail when configuring a jail. Otherwise the "sysrc" command could sometimes create a /dev/null regular file within the jail.
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 30 Nov 2022 22:13:05 +0100
parents 2623f7e775e3
children 3b2935985c73
comparison
equal deleted inserted replaced
330:8dbd11726ee5 331:4a17b1f4c378
394 if [ ! -d "${_mp}" ]; then 394 if [ ! -d "${_mp}" ]; then
395 echo "ERROR: mountpoint \`${_mp}' does not exist" >&2 395 echo "ERROR: mountpoint \`${_mp}' does not exist" >&2
396 return 1 396 return 1
397 fi 397 fi
398 398
399 if [ "${_opt_devfs}" = "yes" ]; then 399 if [ -c "${_mp}/dev/null" ]; then
400 if [ ! -c "${_mp}/dev/null" ]; then 400 if [ "${_opt_devfs}" = "yes" ]; then
401 echo "WARNING: devfs is already mounted - mounting skipped"
402 fi
403 else
404 if [ "${_opt_devfs}" = "yes" ]; then
401 echo "Mounting devfs" 405 echo "Mounting devfs"
402 mount -t devfs devfs "${_mp}/dev" 406 mount -t devfs devfs "${_mp}/dev"
403 _umount_devfs="yes" 407 _umount_devfs="yes"
404 else 408 else
405 echo "devfs is already mounted" 409 echo "ERROR: a working devfs is needed at \`{_mp}/dev' (use \`-d')" >&2
410 return 1
406 fi 411 fi
407 fi 412 fi
408 413
409 # Deactive the by default empty root password 414 # Deactive the by default empty root password
410 pw -R "${_mp}" usermod -w no -n root 415 pw -R "${_mp}" usermod -w no -n root