ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
d36331
From 05188f9029780396097d5355198b8ec818852353 Mon Sep 17 00:00:00 2001
d36331
From: Ryan Wilson <ryantimwilson@meta.com>
d36331
Date: Tue, 12 Nov 2024 22:17:53 -0800
d36331
Subject: [PATCH] pam_systemd: Make pam_systemd 256 backwards compatible to
d36331
 logind 255
d36331
d36331
---
d36331
 src/login/pam_systemd.c | 19 +++++++++++++++++++
d36331
 1 file changed, 19 insertions(+)
d36331
d36331
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
d36331
index a711c89b12..7222d5a0df 100644
d36331
--- a/src/login/pam_systemd.c
d36331
+++ b/src/login/pam_systemd.c
d36331
@@ -1124,6 +1124,25 @@ _public_ PAM_EXTERN int pam_sm_open_session(
d36331
 
d36331
                 r = sd_bus_call(bus, m, LOGIN_SLOW_BUS_CALL_TIMEOUT_USEC, &error, &reply);
d36331
         }
d36331
+        if (r < 0 && sd_bus_error_has_name(&error, SD_BUS_ERROR_INVALID_ARGS)) {
d36331
+                SessionContext context2 = context;
d36331
+                context2.class = "";
d36331
+
d36331
+                sd_bus_error_free(&error);
d36331
+                pam_debug_syslog(handle, debug,
d36331
+                                 "New session classes are not available, retrying after unsetting class.");
d36331
+
d36331
+                m = sd_bus_message_unref(m);
d36331
+                r = create_session_message(bus,
d36331
+                                           handle,
d36331
+                                           &context2,
d36331
+                                           /* avoid_pidfd = */ true,
d36331
+                                           &m);
d36331
+                if (r < 0)
d36331
+                        return pam_bus_log_create_error(handle, r);
d36331
+
d36331
+                r = sd_bus_call(bus, m, LOGIN_SLOW_BUS_CALL_TIMEOUT_USEC, &error, &reply);
d36331
+        }
d36331
         if (r < 0) {
d36331
                 if (sd_bus_error_has_name(&error, BUS_ERROR_SESSION_BUSY)) {
d36331
                         /* We are already in a session, don't do anything */
d36331
-- 
d36331
2.43.5
d36331