Merge aa-unconfined: Improve fallback handling to attr/current

If /proc/*/attr/apparmor/current exists, only read that - instead of
falling back to /proc/*/attr/current if a process is for example
unconfined so that read_proc_current returns None.

Fixes: https://gitlab.com/apparmor/apparmor/-/issues/199
MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/801
Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen 2021-09-18 20:44:48 +00:00
commit 0700b47df8

View file

@ -129,8 +129,10 @@ for pid in sorted(map(int, pids)):
except OSError:
continue
attr = read_proc_current("/proc/%s/attr/apparmor/current" % pid)
if not attr:
if os.path.exists("/proc/%s/attr/apparmor/current" % pid):
attr = read_proc_current("/proc/%s/attr/apparmor/current" % pid)
else:
# fallback to shared attr/current if attr/apparmor/current doesn't exist
attr = read_proc_current("/proc/%s/attr/current" % pid)
pname = None