comparison sbin/ftjail @ 644:0c7917469e04

Put the check for opened files with "procstat" into a subroutine and use it
author Franz Glasner <fzglas.hg@dom66.de>
date Fri, 27 Sep 2024 17:23:01 +0200
parents 4f2257ea7d0a
children b0e8b5cf5d33
comparison
equal deleted inserted replaced
643:4f2257ea7d0a 644:0c7917469e04
929 if [ -S "${_directory}${_add_log_sock}" ]; then 929 if [ -S "${_directory}${_add_log_sock}" ]; then
930 echo "ERROR: additional log socket is open at \`${_directory}${_add_log_sock}'" >&2 930 echo "ERROR: additional log socket is open at \`${_directory}${_add_log_sock}'" >&2
931 return 1 931 return 1
932 fi 932 fi
933 done 933 done
934 # 934 # Check whether there are any open files or VM mappings within the jail.
935 # Check whether there are any open files within the jail. 935 if ! _check_no_open_files_from_all_proc "${_directory}" ; then
936 # 936 err "There are open files or memory mappings within the jail"
937 # "procstat file" also lists fifo, socket, message queue, kgueue et al.
938 # file types.
939 #
940 # Note that procstat places extra whitespace at the end of lines sometimes.
941 #
942 #
943 if procstat -a file | /usr/bin/grep -E '['$'\t '']+'"${_directory}"'(/|(['$'\t '']*)$)' ; then
944 echo "ERROR: There are open files within the jail" >&2
945 return 1
946 fi
947 # The same for memory mappings
948 if procstat -a vm | /usr/bin/grep -E '['$'\t '']+'"${_directory}"'(/|(['$'\t '']*)$)' ; then
949 echo "ERROR: There are open memory mappings within the jail" >&2
950 return 1 937 return 1
951 fi 938 fi
952 939
953 _dir_mounts="$(_get_mounts_at_directory "${_directory}")" 940 _dir_mounts="$(_get_mounts_at_directory "${_directory}")"
954 941