Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 327:37eb955f2395 | 328:184412e2543e |
|---|---|
| 55 | 55 |
| 56 populate MOUNTPOINT BASETXZ | 56 populate MOUNTPOINT BASETXZ |
| 57 | 57 |
| 58 Populate the jail directory in MOUNTPOINT with the base system in BASETXZ | 58 Populate the jail directory in MOUNTPOINT with the base system in BASETXZ |
| 59 | 59 |
| 60 configure MOUNTPOINT | 60 configure [OPTIONS] MOUNTPOINT |
| 61 | 61 |
| 62 Configure some basic parts of the system at MOUNTPOINT: | 62 Configure some basic parts of the system at MOUNTPOINT: |
| 63 disable root password, syslog and other basic configuration settings | 63 disable root password, syslog and other basic configuration settings |
| 64 | 64 |
| 65 Also handle thin jails by checking whether "etc" is a symlink to | 65 Also handle thin jails by checking whether "etc" is a symlink to |
| 66 "skeleton/etc". | 66 "skeleton/etc". |
| 67 | |
| 68 -d Temporarily mount a devfs filesystem to MOUNTPOINT/dev | |
| 67 | 69 |
| 68 hostid | 70 hostid |
| 69 | 71 |
| 70 Print proposals for a hostuuid and hostid | 72 Print proposals for a hostuuid and hostid |
| 71 | 73 |
| 357 # command_configure mountpoint | 359 # command_configure mountpoint |
| 358 # | 360 # |
| 359 command_configure() { | 361 command_configure() { |
| 360 # mountpoint | 362 # mountpoint |
| 361 local _mp | 363 local _mp |
| 362 | 364 local _opt_devfs |
| 363 local _pcl | 365 |
| 366 local _pcl _umount_devfs | |
| 367 | |
| 368 _umount_devfs="" | |
| 369 | |
| 370 _opt_devfs="" | |
| 371 while getopts "d" _opt ; do | |
| 372 case ${_opt} in | |
| 373 d) | |
| 374 _opt_devfs="yes" | |
| 375 ;; | |
| 376 \?) | |
| 377 return 2; | |
| 378 ;; | |
| 379 *) | |
| 380 echo "ERROR: option handling failed" 1>&2 | |
| 381 return 2 | |
| 382 ;; | |
| 383 esac | |
| 384 done | |
| 385 shift $((OPTIND-1)) | |
| 386 OPTIND=1 | |
| 364 | 387 |
| 365 _mp="$1" | 388 _mp="$1" |
| 366 | 389 |
| 367 if [ -z "${_mp}" ]; then | 390 if [ -z "${_mp}" ]; then |
| 368 echo "ERROR: no mountpoint given" >&2 | 391 echo "ERROR: no mountpoint given" >&2 |
| 369 return 2 | 392 return 2 |
| 370 fi | 393 fi |
| 371 if [ ! -d "${_mp}" ]; then | 394 if [ ! -d "${_mp}" ]; then |
| 372 echo "ERROR: mountpoint \`${_mp}' does not exist" >&2 | 395 echo "ERROR: mountpoint \`${_mp}' does not exist" >&2 |
| 373 return 1 | 396 return 1 |
| 397 fi | |
| 398 | |
| 399 if [ "${_opt_devfs}" = "yes" ]; then | |
| 400 if [ ! -c "{_mp}/dev/null" ]; then | |
| 401 echo "Mounting devfs" | |
| 402 mount -t devfs devfs "${_mp}/dev" | |
| 403 _umount_devfs="yes" | |
| 404 else | |
| 405 echo "devfs is already mounted" | |
| 406 fi | |
| 374 fi | 407 fi |
| 375 | 408 |
| 376 # Deactive the by default empty root password | 409 # Deactive the by default empty root password |
| 377 pw -R "${_mp}" usermod -w no -n root | 410 pw -R "${_mp}" usermod -w no -n root |
| 378 | 411 |
| 430 else | 463 else |
| 431 echo "WARNING: \"${_pcl}\" exists already -- not changed" | 464 echo "WARNING: \"${_pcl}\" exists already -- not changed" |
| 432 fi | 465 fi |
| 433 | 466 |
| 434 command_hostid | 467 command_hostid |
| 468 | |
| 469 if [ "${_umount_devfs}" = "yes" ]; then | |
| 470 echo "Unmounting devfs" | |
| 471 umount "{_mp}/dev" | |
| 472 fi | |
| 435 } | 473 } |
| 436 | 474 |
| 437 | 475 |
| 438 # | 476 # |
| 439 # "copy" -- ZFS copy of datasets | 477 # "copy" -- ZFS copy of datasets |
