Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff sbin/ftjail @ 342:89877869a665
Create all temporary files within a unique temporary directory
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 03 Dec 2022 21:27:50 +0100 |
| parents | a204a7415d4a |
| children | c5b1647cedb5 |
line wrap: on
line diff
--- a/sbin/ftjail Sat Dec 03 21:12:23 2022 +0100 +++ b/sbin/ftjail Sat Dec 03 21:27:50 2022 +0100 @@ -973,6 +973,7 @@ local _clone_extra_props _canmount_prop local _line _opt local _root_readonly _root_origin + local _u_tmpdir _opt_keep="no" _opt_old_origin="" @@ -1053,10 +1054,11 @@ # start with "ro," # _root_origin="$(zfs list -H -o origin "${_root_dataset}")" - _dir_fn_fstab="$(env TMPDIR=/var/tmp mktemp -t ftjail_${_dir_basename}.fstab)" + _u_tmpdir="$(env TMPDIR=/var/tmp mktemp -d -t ftjail_${_dir_basename})" + [ -z "${_u_tmpdir}" ] && { echo "ERROR: cannot create unique temp dir" 1>&2; return 1; } + _dir_fn_fstab="${_u_tmpdir}/fstab" echo -n "${_dir_mounts}" >>"${_dir_fn_fstab}" - - _dir_fn_tldir="$(env TMPDIR=/var/tmp mktemp -t ftjail_${_dir_basename}.tldir)" + _dir_fn_tldir="${_u_tmpdir}/tldirs" find "${_directory}" -depth 1 -type d 2>/dev/null | sort >>"${_dir_fn_tldir}" # Unmount in reverse order: unmount can do it for us @@ -1144,8 +1146,7 @@ if [ "${_opt_keep}" != "yes" ]; then echo "Cleaning up...""" - [ -n "${_dir_fn_tldir}" } && [ -f "${_dir_fn_tldir}" ] && rm -f "${_dir_fn_tldir}" - [ -n "${_dir_fn_fstab}" ] && [ -f "${_dir_fn_fstab}" ] && rm -f "${_dir_fn_fstab}" + [ -n "${_u_tmpdir}" ] && [ -d "${_u_tmpdir}" ] && rm -rvf "${_u_tmpdir}" fi echo "Done." }
