summaryrefslogtreecommitdiff
path: root/src/login/pam_systemd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login/pam_systemd.c')
-rw-r--r--src/login/pam_systemd.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index 0ebdfdf19e..f83d18b035 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -31,6 +31,7 @@
#include <security/pam_ext.h>
#include <security/pam_misc.h>
+#include "bus-common-errors.h"
#include "util.h"
#include "audit.h"
#include "macro.h"
@@ -181,7 +182,7 @@ static int export_legacy_dbus_address(
int r;
/* skip export if kdbus is not active */
- if (access("/sys/fs/kdbus", F_OK) < 0)
+ if (!is_kdbus_available())
return PAM_SUCCESS;
if (asprintf(&s, KERNEL_USER_BUS_ADDRESS_FMT ";" UNIX_USER_BUS_ADDRESS_FMT, uid, runtime) < 0) {
@@ -213,7 +214,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
*seat = NULL,
*type = NULL, *class = NULL,
*class_pam = NULL, *type_pam = NULL, *cvtnr = NULL, *desktop = NULL;
- _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+ _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
int session_fd = -1, existing, r;
bool debug = false, remote;
struct passwd *pw;
@@ -399,8 +400,13 @@ _public_ PAM_EXTERN int pam_sm_open_session(
remote_host,
0);
if (r < 0) {
- pam_syslog(handle, LOG_ERR, "Failed to create session: %s", bus_error_message(&error, r));
- return PAM_SYSTEM_ERR;
+ if (sd_bus_error_has_name(&error, BUS_ERROR_SESSION_BUSY)) {
+ pam_syslog(handle, LOG_DEBUG, "Cannot create session: %s", bus_error_message(&error, r));
+ return PAM_SUCCESS;
+ } else {
+ pam_syslog(handle, LOG_ERR, "Failed to create session: %s", bus_error_message(&error, r));
+ return PAM_SYSTEM_ERR;
+ }
}
r = sd_bus_message_read(reply,
@@ -496,7 +502,7 @@ _public_ PAM_EXTERN int pam_sm_close_session(
int argc, const char **argv) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
- _cleanup_bus_close_unref_ sd_bus *bus = NULL;
+ _cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
const void *existing = NULL;
const char *id;
int r;