mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 22:05:27 +00:00
aa-unconfined: also read /proc/$pid/attr/apparmor/current
This means moving the code that reads the 'current' file into a new function read_proc_current()Then call that function for both /proc/$pid/attr/apparmor/current (preferred) and /proc/$pid/attr/current (fallback).
This commit is contained in:
@@ -99,6 +99,19 @@ def get_pids_netstat(netstat='netstat'):
|
||||
return pids
|
||||
|
||||
|
||||
def read_proc_current(filename):
|
||||
attr = None
|
||||
|
||||
if os.path.exists(filename):
|
||||
with apparmor.common.open_file_read(filename) as current:
|
||||
for line in current:
|
||||
line = line.strip()
|
||||
if line.endswith(' (complain)', 1) or line.endswith(' (enforce)', 1): # enforce at least one char as profile name
|
||||
attr = line
|
||||
|
||||
return attr
|
||||
|
||||
|
||||
pids = set()
|
||||
if paranoid:
|
||||
pids = get_all_pids()
|
||||
@@ -112,13 +125,10 @@ for pid in sorted(map(int, pids)):
|
||||
prog = os.readlink("/proc/%s/exe" % pid)
|
||||
except OSError:
|
||||
continue
|
||||
attr = None
|
||||
if os.path.exists("/proc/%s/attr/current" % pid):
|
||||
with apparmor.common.open_file_read("/proc/%s/attr/current" % pid) as current:
|
||||
for line in current:
|
||||
line = line.strip()
|
||||
if line.endswith(' (complain)', 1) or line.endswith(' (enforce)', 1): # enforce at least one char as profile name
|
||||
attr = line
|
||||
|
||||
attr = read_proc_current("/proc/%s/attr/apparmor/current" % pid)
|
||||
if not attr:
|
||||
attr = read_proc_current("/proc/%s/attr/current" % pid)
|
||||
|
||||
pname = None
|
||||
cmdline = None
|
||||
|
Reference in New Issue
Block a user