audit-util: return -ENODATA from audit_{session|loginuid}_from_pid() if invoked in...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 13 Nov 2024 01:08:29 +0000 (10:08 +0900)
committerGitHub <noreply@github.com>
Wed, 13 Nov 2024 01:08:29 +0000 (10:08 +0900)
commitd762b14e382b9bde14dd92f8750db91e7f00bf99
tree225f3b426b8deac476b7889ae7a68eff8d59a520
parentead9ef50276071059a8582b124fe841867a9628d
parent7bf0149e9b46d614c3431e39ca59805aebf71bc4
audit-util: return -ENODATA from audit_{session|loginuid}_from_pid() if invoked in a container (#35072)

The auditing subsystem is still not virtualized for containers, hence
the two values don't really make sense inside them, they will just leak
information from outside into the container. Hence don't make use of the
data if we detect we are run inside of a container.

This has visible effects: logind will no longer try to reuse the
auditing session ids as its own session ids when run inside a container.

While are at it, modernize the calls in more ways:

1. switch to pidref behaviour, all but one of our uses are using pidref
anyway already.
2. use read_virtual_file() + proc_mounted()
3. reasonably distinguish ENOENT errors when reading the process proc
files: distinguish the case where /proc is not mounted, from the case
where the process is already gone, from where auditing is not enabled in
the kernel build.