diff --git a/src/shared/pam-util.c b/src/shared/pam-util.c index 13b68234c9..fe58203e27 100644 --- a/src/shared/pam-util.c +++ b/src/shared/pam-util.c @@ -5,6 +5,7 @@ #include #include "alloc-util.h" +#include "bus-internal.h" #include "errno-util.h" #include "format-util.h" #include "macro.h" @@ -88,8 +89,13 @@ static void pam_bus_data_destroy(pam_handle_t *handle, void *data, int error_sta * internally anyway. That said, we still generate a warning message, since this really shouldn't * happen. */ - if (error_status & PAM_DATA_SILENT) - pam_syslog(handle, LOG_DEBUG, "Attempted to close sd-bus after fork, this should not happen."); + if (!data) + return; + + PamBusData *d = data; + if (FLAGS_SET(error_status, PAM_DATA_SILENT) && + d->bus && bus_origin_changed(d->bus)) + pam_syslog(handle, LOG_DEBUG, "Attempted to close sd-bus after fork whose connection is opened before the fork, this should not happen."); pam_bus_data_free(data); }