1
0
mirror of https://passt.top/passt synced 2024-12-22 13:45:32 +00:00
passt/contrib/selinux
Stefano Brivio 5e24466677 selinux: Use auth_read_passwd() interface for all our getpwnam() needs
If passt or pasta are started as root, we need to read the passwd file
(be it /etc/passwd or whatever sssd provides) to find out UID and GID
of 'nobody' so that we can switch to it.

Instead of a bunch of allow rules for passwd_file_t and sssd macros,
use the more convenient auth_read_passwd() interface which should
cover our usage of getpwnam().

The existing rules weren't actually enough:

  # strace -e openat passt -f
  [...]
  Started as root, will change to nobody.
  openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 4
  openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 4
  openat(AT_FDCWD, "/lib64/libnss_sss.so.2", O_RDONLY|O_CLOEXEC) = 4
  openat(AT_FDCWD, "/var/lib/sss/mc/passwd", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
  openat(AT_FDCWD, "/var/lib/sss/mc/passwd", O_RDONLY|O_CLOEXEC) = -1 EACCES (Permission denied)
  openat(AT_FDCWD, "/etc/passwd", O_RDONLY|O_CLOEXEC) = 4

with corresponding SELinux warnings logged in audit.log.

Reported-by: Minxi Hou <mhou@redhat.com>
Analysed-by: Miloš Malik <mmalik@redhat.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2024-11-19 21:10:14 +01:00
..
passt.fc selinux: Use explicit paths for binaries in file context 2023-08-18 13:18:45 +02:00
passt.if passt: Relicense to GPL 2.0, or any later version 2023-04-06 18:00:33 +02:00
passt.te selinux: Use auth_read_passwd() interface for all our getpwnam() needs 2024-11-19 21:10:14 +01:00
pasta.fc selinux: Use explicit paths for binaries in file context 2023-08-18 13:18:45 +02:00
pasta.te selinux: Use auth_read_passwd() interface for all our getpwnam() needs 2024-11-19 21:10:14 +01:00