]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pam_systemd: fix error logs
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 9 Sep 2025 16:18:54 +0000 (18:18 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 17 Sep 2025 12:40:16 +0000 (14:40 +0200)
The code was of two minds about error_id: it was used directly in
pam_syslog_errno(), but in the next line checked with streq_ptr().
sd_varlink_callbo() may return negative and then it does not set the output
params, or it returns the error in ret_error_id. We cannot assume that error_id
is non-null. Also fix a select-and-paste mistake in one place.

src/login/pam_systemd.c

index 9e69433c519eb2595f8ae7f888e3853c9f9e5a15..dd96a27479dd18be6bba994e5d49230e827a0554 100644 (file)
@@ -1152,7 +1152,7 @@ static int register_session(
                                         JSON_BUILD_PAIR_STRING_NON_EMPTY("RemoteHost", c->remote_host));
                         if (r < 0)
                                 return pam_syslog_errno(handle, LOG_ERR, r,
-                                                        "Failed to register session: %s", error_id);
+                                                        "Failed to issue io.systemd.Login.CreateSession varlink call: %m");
                         if (streq_ptr(error_id, "io.systemd.Login.AlreadySessionMember")) {
                                 /* We are already in a session, don't do anything */
                                 pam_debug_syslog(handle, debug, "Not creating session: %s", error_id);
@@ -1161,7 +1161,7 @@ static int register_session(
                         }
                         if (error_id)
                                 return pam_syslog_errno(handle, LOG_ERR, sd_varlink_error_to_errno(error_id, vreply),
-                                                        "Failed to issue CreateSession() varlink call: %s", error_id);
+                                                        "Varlink call io.systemd.Login.CreateSession failed: %s", error_id);
 
                         struct {
                                 const char *id;
@@ -1859,10 +1859,11 @@ _public_ PAM_EXTERN int pam_sm_close_session(
                                         &error_id,
                                         SD_JSON_BUILD_PAIR_STRING("Id", id));
                         if (r < 0)
-                                return pam_syslog_errno(handle, LOG_ERR, r, "Failed to register session: %s", error_id);
+                                return pam_syslog_errno(handle, LOG_ERR, r,
+                                                        "Failed to issue io.systemd.Login.ReleaseSession varlink call: %m");
                         if (error_id)
                                 return pam_syslog_errno(handle, LOG_ERR, sd_varlink_error_to_errno(error_id, vreply),
-                                                        "Failed to issue ReleaseSession() varlink call: %s", error_id);
+                                                        "Varlink call io.systemd.Login.ReleaseSession failed: %s", error_id);
 
                         done = true;
                 }