Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 894450 - sys-apps/systemd, sys-auth/pambase: incomplete pam config for SELinux
Summary: sys-apps/systemd, sys-auth/pambase: incomplete pam config for SELinux
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo systemd Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-14 20:49 UTC by Kenton Groombridge
Modified: 2024-03-07 17:33 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kenton Groombridge gentoo-dev 2023-02-14 20:49:26 UTC
The systemd-user pam config we are shipping is as follows:

---
account include system-auth

session required pam_loginuid.so
session include system-auth
session optional pam_systemd.so
---

However, on SELinux systems we must also add 2 lines such that it is:

---
account include system-auth

session required pam_selinux.so close
session required pam_selinux.so nottys open
session required pam_loginuid.so
session include system-auth
session optional pam_systemd.so
---

These 2 pam_selinux.so lines are to ensure that the systemd user manager gets the correct SELinux context when the user logs in. Otherwise, the user manager will fail to start and the user will have a broken login session.
Comment 1 Kenton Groombridge gentoo-dev 2023-02-14 20:56:56 UTC
Upstream's pam config for systemd --user supports this: https://github.com/systemd/systemd/blob/main/src/login/systemd-user.in

Also to note, there are other rules in upstream's config related to systemd-homed that likely should be considered.
Comment 2 Nuno Alexandre 2024-03-07 17:33:59 UTC
Regarding this. I changed systemd-user so that I could get proper user context when logging in.
It was the only way I could get context and roles working.

You might be able to get a smaller file, I doubt you need all of this. But for now, this works. Just in case someone is also looking for some fix.

account include system-auth

session required pam_loginuid.so
session include system-auth
session optional pam_systemd.so
# --------------------
auth      include   system-auth
account   include   system-auth
password  include   system-auth
session   required  pam_loginuid.so
session   required  pam_selinux.so close
session   include   system-auth

session   required  pam_selinux.so open

# Include additional session modules as needed
session   optional  pam_keyinit.so force revoke
session   optional  pam_namespace.so
session   optional  pam_systemd.so