Skip to content

pam: expose sudo prompt to PAM via SUDO_PROMPT env#1590

Open
3v1n0 wants to merge 3 commits into
trifectatechfoundation:mainfrom
3v1n0:expose-pam-prompt
Open

pam: expose sudo prompt to PAM via SUDO_PROMPT env#1590
3v1n0 wants to merge 3 commits into
trifectatechfoundation:mainfrom
3v1n0:expose-pam-prompt

Conversation

@3v1n0
Copy link
Copy Markdown
Contributor

@3v1n0 3v1n0 commented May 20, 2026

Some PAM modules implementations do not use PAM conversations and
instead present their own native client UI when they have access to
the terminal.
In those cases, modules cannot infer sudo's custom prompt text from
the conversation callback path.

Set SUDO_PROMPT in the PAM environment before pam_authenticate(),
so modules that render their own UI can combine:

  • PAM service identity (from the PAM transaction)
  • sudo's resolved prompt string (SUDO_PROMPT)

to display a consistent, context-aware prompt.

To avoid stale state, clear SUDO_PROMPT before authentication starts
and clear it again after pam_authenticate() returns.

Allowing PAM modules in the stack to read (and potentially change)
SUDO_PROMPT does not introduce a new trust boundary concern:
PAM modules already control the conversation flow and can provide
their own prompt text/messages through the standard PAM conversation
mechanism.

This has been also proposed to regular sudo as sudo-project/sudo#539

Closes: #1594

Some PAM modules implementations do not use PAM conversations and
instead present their own native client UI when they have access to
the terminal.
In those cases, modules cannot infer sudo's custom prompt text from
the conversation callback path.

Set SUDO_PROMPT in the PAM environment before pam_authenticate(),
so modules that render their own UI can combine:
 - PAM service identity (from the PAM transaction)
 - sudo's resolved prompt string (SUDO_PROMPT)

to display a consistent, context-aware prompt.

To avoid stale state, clear SUDO_PROMPT before authentication starts
and clear it again after pam_authenticate() returns.

Allowing PAM modules in the stack to read (and potentially change)
SUDO_PROMPT does not introduce a new trust boundary concern:
PAM modules already control the conversation flow and can provide
their own prompt text/messages through the standard PAM conversation
mechanism.
@3v1n0 3v1n0 force-pushed the expose-pam-prompt branch from 8d31d9d to 71dc54a Compare May 20, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide user custom prompts to PAM modules not using sudo PAM conversation

2 participants