Bug 279268 - [patch] xdm dies when pressing CTRL-C if pam_xdg.so is used
Summary: [patch] xdm dies when pressing CTRL-C if pam_xdg.so is used
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2024-05-24 08:36 UTC by Andre Albsmeier
Modified: 2024-06-03 07:37 UTC (History)
2 users (show)

See Also:


Attachments
patch (642 bytes, patch)
2024-05-24 08:36 UTC, Andre Albsmeier
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andre Albsmeier 2024-05-24 08:36:57 UTC
Created attachment 250918 [details]
patch

After updating to latest 14.1 BETA xdm crashed when Ctrl-C was pressed on the logon screen. Running xdm in debug mode showed:

SetPrompt(0, <NULL>, LOGIN_PROMPT_NOT_SHOWN(0))
SetPrompt(1, <NULL>, LOGIN_PROMPT_NOT_SHOWN(0))
pam_msg: PAM_PROMPT_ECHO_ON (2): '       Login:'
SetPrompt(0,        Login:, LOGIN_PROMPT_ECHO_ON(1))
RedrawFail('Login incorrect or forbidden by policy', 0)
dispatching :0
RedrawFail('Login incorrect or forbidden by policy', 0)

(CTRL-C now)

GreetDone: , (password is 0 long)
REMANAGE_DISPLAY
Done dispatch :0
xdm error (pid 8751): pam_authenticate failure: Conversation failure
Unsecure display :0
Greet connection closed
Manager wait returns pid: 8751 sig 11 core 0 code 0
Display exited with unknown status 2816

I fixed it with the attached patch (not knowing if this is correct :-)). Apparently pam_get_item() can return NULL in &user but pam_xdg.c continues with it...
Comment 1 commit-hook freebsd_committer freebsd_triage 2024-05-27 06:34:18 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cca0ce62f367d03ed429bf99e41e6aca8cb7f2ac

commit cca0ce62f367d03ed429bf99e41e6aca8cb7f2ac
Author:     Andre Albsmeier <mail@fbsd2.e4m.org>
AuthorDate: 2024-05-27 06:31:34 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2024-05-27 06:33:14 +0000

    pam_xdg: pam_get_item can return NULL

    Fix pam_xdg as pam_get_item can return NULL, this happens when pressing
    control + C in xdm for example.

    MFC after:      1 week
    PR:             279268

 lib/libpam/modules/pam_xdg/pam_xdg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Comment 2 Emmanuel Vadot freebsd_committer freebsd_triage 2024-05-27 06:38:02 UTC
Commited, thanks a lot.
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-06-03 07:37:21 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9fe726012df9a125a40df0b70a2e5c6f6b7bb913

commit 9fe726012df9a125a40df0b70a2e5c6f6b7bb913
Author:     Andre Albsmeier <mail@fbsd2.e4m.org>
AuthorDate: 2024-05-27 06:31:34 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2024-06-03 07:35:41 +0000

    pam_xdg: pam_get_item can return NULL

    Fix pam_xdg as pam_get_item can return NULL, this happens when pressing
    control + C in xdm for example.

    MFC after:      1 week
    PR:             279268

    (cherry picked from commit cca0ce62f367d03ed429bf99e41e6aca8cb7f2ac)

 lib/libpam/modules/pam_xdg/pam_xdg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)