From 06997170f3fddad8f466226fc5f0d7b3d25fcb45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 15 Sep 2026 12:36:36 +0200 Subject: [PATCH] pam_systemd: add debug messages Let's actually print out how we're called. --- src/login/pam_systemd.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c index 6b5ee9afba..13330c9e3c 100644 --- a/src/login/pam_systemd.c +++ b/src/login/pam_systemd.c @@ -977,7 +977,7 @@ static void session_context_mangle( /* Chop off leading /dev prefix that some clients specify, but others do not. */ c->tty = skip_dev_prefix(c->tty); - if (!isempty(c->display) && !c->vtnr) { + if (!isempty(c->display) && c->vtnr == 0) { if (isempty(c->seat)) (void) get_seat_from_display(c->display, &c->seat, &c->vtnr); else if (streq(c->seat, "seat0")) @@ -1830,7 +1830,13 @@ _public_ PAM_EXTERN int pam_sm_open_session( &default_capability_ambient_set) < 0) return PAM_SESSION_ERR; - pam_debug_syslog(pamh, debug, "pam-systemd: initializing..."); + pam_debug_syslog(pamh, debug, + "pam-systemd: initializing (class=%s type=%s desktop=%s area=%s inhibit=%s)...", + strempty(class_pam), + strempty(type_pam), + strempty(desktop_pam), + strempty(area_pam), + strempty(inhibit_what)); _cleanup_(user_record_unrefp) UserRecord *ur = NULL; r = acquire_user_record(pamh, &ur); @@ -1858,6 +1864,21 @@ _public_ PAM_EXTERN int pam_sm_open_session( inhibit_what = getenv_harder(pamh, "XDG_SESSION_INHIBIT", inhibit_what); inhibit_why = getenv_harder(pamh, "XDG_SESSION_INHIBIT_WHY", inhibit_why); + pam_debug_syslog(pamh, debug, + "Initial state: " + "service=%s display=%s tty=%s remote_user=%s remote_host=%s seat=%s vtnr=%"PRIu32" type=%s class=%s desktop=%s area=%s incomplete=%s inhibit=%s", + strempty(c.service), + strempty(c.display), + strempty(c.tty), + strempty(c.remote_user), strempty(c.remote_host), + strempty(c.seat), c.vtnr, + strempty(c.type), + strempty(c.class), + strempty(c.desktop), + strempty(c.area), + yes_no(c.incomplete), + strempty(inhibit_what)); + const char *extra_device_access = getenv_harder(pamh, "XDG_SESSION_EXTRA_DEVICE_ACCESS", NULL); if (extra_device_access) { c.extra_device_access = strv_split(extra_device_access, ":");