]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: assign TTY to PAM context when TTYPath= is specified
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 7 Nov 2025 16:03:12 +0000 (01:03 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 7 Nov 2025 21:12:20 +0000 (06:12 +0900)
Fixes #38486 again, which was fixed by
1405d46bf998b5a4b6f572a14ac88890828a405d, but regressed again by
f875a8026ec2dfa6026da3ee216782e9f7c04a43.

This also make it use exec_input_is_terminal().

Follow-up for f875a8026ec2dfa6026da3ee216782e9f7c04a43.

src/core/exec-invoke.c

index 592b593e997037ec5fe6cdb60ec162eae949d9ee..ba610c217e9c7d65179fc98ee4a96c3605a5f6aa 100644 (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;
         }