core: assign TTY to PAM context when TTYPath= is specified

Fixes #38486 again, which was fixed by
1405d46bf9, but regressed again by
f875a8026e.

This also make it use exec_input_is_terminal().

Follow-up for f875a8026e.
This commit is contained in:
Yu Watanabe
2025-11-08 06:12:20 +09:00
parent 6d510012b7
commit f0fdb69a8d
+4 -1
View File
@@ -1237,7 +1237,10 @@ static int exec_context_get_tty_for_pam(const ExecContext *context, char **ret)
return 1;
}
if (!IN_SET(context->std_input, EXEC_INPUT_TTY, EXEC_INPUT_TTY_FAIL, EXEC_INPUT_TTY_FORCE)) {
/* Do not implicitly configure TTY unless TTYPath= or StandardInput=tty is specified. See issue
* #39334. Note, exec_context_tty_path() returns "/dev/console" when TTYPath= is unspecified, hence
* explicitly check context->tty_path here. */
if (!context->tty_path && !exec_input_is_terminal(context->std_input)) {
*ret = NULL;
return 0;
}