Skip to contentSkip to conversation

package/linux-pam: include pam_systemd for login

PATCH In review Norbert Lange 2 participants 2 messages Jan 21 – Apr 29

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/linux-pam: include pam_systemd for login

pam_systemd ensures the user's processes end up in the
correct cgroup and scope.
It should be used, even if the full functionality via logind is not enabled.

---
 package/linux-pam/linux-pam.mk | 8 ++++++++
 package/linux-pam/login.pam    | 1 +
 2 files changed, 9 insertions(+)
package/linux-pam/linux-pam.mk +8 -0
index 23b09efbae..cb3c47739d 100644
@@ -64,6 +64,13 @@ else
 LINUX_PAM_CONF_OPTS += --disable-lastlog
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD),y)
+define LINUX_PAM_SYSTEMD_TWEAK
+	$(SED) 's/^# \(.*pam_systemd.so.*\)$$/\1/' \
+		$(TARGET_DIR)/etc/pam.d/login
+endef
+endif
+
 # Install default pam config (deny everything except login)
 define LINUX_PAM_INSTALL_CONFIG
 	$(INSTALL) -m 0644 -D package/linux-pam/login.pam \
@@ -72,6 +79,7 @@ define LINUX_PAM_INSTALL_CONFIG
 		$(TARGET_DIR)/etc/pam.d/other
 	$(LINUX_PAM_LASTLOG_PAMFILE_TWEAK)
 	$(LINUX_PAM_SELINUX_PAMFILE_TWEAK)
+	$(LINUX_PAM_SYSTEMD_TWEAK)
 endef
 
 LINUX_PAM_POST_INSTALL_TARGET_HOOKS += LINUX_PAM_INSTALL_CONFIG
package/linux-pam/login.pam +1 -0
index 21d2afb61e..570593f26a 100644
@@ -8,5 +8,6 @@ password	required	pam_unix.so nullok
 session		required	pam_limits.so
 session		required	pam_env.so
 session		required	pam_unix.so
+# session	optional	pam_systemd.so
 # session	optional	pam_lastlog.so
 # session	required	pam_selinux.so open
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hi Norbert

Quoted 3 lines · Norbert Lange

pam_systemd ensures the user's processes end up in the
correct cgroup and scope.
It should be used, even if the full functionality via logind is not enabled.

I haven't found explicit information that this should be used with systemd, but without logind, the only related thing I found that registering login sessions with logind through pam_systemd can be disabled since systemd v258, and then skimming the code of the module says that most functionality is skipped for non-logind systems.

But this all makes it at least sound that it's safe to enable this regardless of having logind available or not, so I'd like to merge this.

But can I ask you to rebase this after the recent pam update and changes in 30e38505e4 and 9408bc0161?

It would also be really helpful to have a runtime test for this (and pam in general), would you be interested in contributing this?

And lastly, pam has support for building against libsystemd for logind support as well[1], which we currently don't enable in buildroot. Would this be worthwhile to add as well?

Quoted 5 lines

---

[...]

Best,
Marcus

[1] https://github.com/linux-pam/linux-pam/blob/master/meson_options.txt#L11-L14
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot