]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: use full tty path for PAM_TTY
authorKarel Zak <kzak@redhat.com>
Wed, 3 Feb 2021 13:45:15 +0000 (14:45 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 3 Feb 2021 13:49:09 +0000 (14:49 +0100)
pam_set_item() man page:
 PAM_TTY
   The terminal name: prefixed by /dev/ if it is a device file;
   for graphical, X-based, applications the value for this item
   should be the $DISPLAY variable.

It seems for example pam_timestamp module is not robust enough to
differentiate between /dev/ and pty/0 and it assumes that '/' in the
path always means '/dev/' prefix ...

Fixes: https://github.com/karelzak/util-linux/issues/1242
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index 552e9c1d5a2a92a17f2de7ee93ec95c07ccb8478..550c7df9070f115757d52f4a16523f732722b2f0 100644 (file)
@@ -897,9 +897,11 @@ static pam_handle_t *init_loginpam(struct login_context *cxt)
        if (is_pam_failure(rc))
                loginpam_err(pamh, rc);
 
-       rc = pam_set_item(pamh, PAM_TTY, cxt->tty_name);
-       if (is_pam_failure(rc))
-               loginpam_err(pamh, rc);
+       if (cxt->tty_path) {
+               rc = pam_set_item(pamh, PAM_TTY, cxt->tty_path);
+               if (is_pam_failure(rc))
+                       loginpam_err(pamh, rc);
+       }
 
        /*
         * Andrew.Taylor@cal.montage.ca: Provide a user prompt to PAM so that