chiark / gitweb /
remove unused variables
[elogind.git] / src / login / pam-module.c
index 58f974241b8db12e5e02be33548ace1e75e4a08a..c04622c1c2abfc8e80ce098f5c96bd2ed89b566b 100644 (file)
@@ -40,6 +40,7 @@
 #include "def.h"
 #include "socket-util.h"
 #include "fileio.h"
+#include "bus-error.h"
 
 static int parse_argv(pam_handle_t *handle,
                       int argc, const char **argv,
@@ -355,11 +356,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
                                remote_host,
                                0);
         if (r < 0) {
-                pam_syslog(handle, LOG_ERR, "Failed to communicate with systemd-logind: %s", strerror(-r));
-                if (error.name || error.message)
-                        pam_syslog(handle, LOG_ERR, "systemd-logind returned %s: %s",
-                                   error.name ?: "unknown error",
-                                   error.message ?: "no message");
+                pam_syslog(handle, LOG_ERR, "Failed to create session: %s", bus_error_message(&error, r));
                 return PAM_SYSTEM_ERR;
         }
 
@@ -403,9 +400,8 @@ _public_ PAM_EXTERN int pam_sm_open_session(
         }
 
         if (vtnr > 0) {
-                char buf[11];
+                char buf[DECIMAL_STR_MAX(vtnr)];
                 snprintf(buf, sizeof(buf), "%u", vtnr);
-                char_array_0(buf);
 
                 r = pam_misc_setenv(handle, "XDG_VTNR", buf, 0);
                 if (r != PAM_SUCCESS) {
@@ -443,14 +439,12 @@ _public_ PAM_EXTERN int pam_sm_close_session(
                 int flags,
                 int argc, const char **argv) {
 
+        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+        _cleanup_bus_unref_ sd_bus *bus = NULL;
         const void *p = NULL, *existing = NULL;
         const char *id;
         int r;
 
-        _cleanup_bus_unref_ sd_bus *bus = NULL;
-        _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
-        _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
-
         assert(handle);
 
         /* Only release session if it wasn't pre-existing when we
@@ -484,11 +478,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
                                        id);
                 if (r < 0) {
                         pam_syslog(handle, LOG_ERR,
-                                   "Failed to release session: %s", strerror(-r));
-                        if (error.name || error.message)
-                                pam_syslog(handle, LOG_ERR, "systemd-logind returned %s: %s",
-                                           error.name ?: "unknown error",
-                                           error.message ?: "no message");
+                                   "Failed to release session: %s", bus_error_message(&error, r));
 
                         r = PAM_SESSION_ERR;
                         goto finish;