restrict open files check to non-volatile directories

This commit is contained in:
Fredrik Eriksson 2024-08-03 07:35:12 +02:00
parent db865eafe9
commit fc6f29c0e1
Signed by: feffe
GPG Key ID: E6B5580B853D322B

View File

@ -10,7 +10,7 @@ import sau.errors
import sau.helpers import sau.helpers
import sau.platforms import sau.platforms
proc_fd_map_re = re.compile(r'^.*(/[^\(]*) \(deleted\)$') proc_fd_map_re = re.compile(r'^.*(/(?:usr|lib|opt|etc|s?bin)[^\(]*) \(deleted\)$')
def _warn(policy, msg): def _warn(policy, msg):
log = logging.getLogger(sau.LOGNAME) log = logging.getLogger(sau.LOGNAME)
@ -28,7 +28,8 @@ def get_deleted_open_files(proc):
for line in f: for line in f:
match = re.match(proc_fd_map_re, line) match = re.match(proc_fd_map_re, line)
if match: if match:
files.add(match.group(1)) fname = match.group(1)
files.add(fname)
return files return files
# on FreeBSD psutils open_files() helpfully returns a null path if a file # on FreeBSD psutils open_files() helpfully returns a null path if a file