Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 433:91b275a3facf
Also check for any open files and memory mapping within the jail by using "procstat"
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 19 Nov 2023 16:07:28 +0100 |
| parents | d46315901037 |
| children | 4da3377f4139 |
| files | sbin/ftjail |
| diffstat | 1 files changed, 18 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/sbin/ftjail Sat Nov 18 08:37:14 2023 +0100 +++ b/sbin/ftjail Sun Nov 19 16:07:28 2023 +0100 @@ -1045,7 +1045,24 @@ return 1 fi done - + # + # Check whether there are any open files within the jail. + # + # "procstat file" also lists fifo, socket, message queue, kgueue et al. + # file types. + # + # Note that procstat places extra whitespace at the end of lines sometimes. + # + # + if procstat -a file | egrep '['$'\t '']+'"${_directory}"'(/|(['$'\t '']*)$)' ; then + echo "ERROR: There are open files within the jail" >&2 + return 1 + fi + # The same for memory mappings + if procstat -a vm | egrep '['$'\t '']+'"${_directory}"'(/|(['$'\t '']*)$)' ; then + echo "ERROR: There are open memory mappings within the jail" >&2 + return 1 + fi _dir_mounts="$(_get_mounts_at_directory "${_directory}")"
