_cleanup_(barrier_destroy) Barrier barrier = BARRIER_NULL;
_cleanup_strv_free_ char **e = NULL;
+ _cleanup_free_ char *tty = NULL;
pam_handle_t *handle = NULL;
sigset_t old_ss;
int pam_code = PAM_SUCCESS, r;
goto fail;
}
- const char *tty = context->tty_path;
- if (!tty) {
- _cleanup_free_ char *q = NULL;
-
- /* Hmm, so no TTY was explicitly passed, but an fd passed to us directly might be a TTY. Let's figure
- * out if that's the case, and read the TTY off it. */
+ if (getttyname_malloc(STDIN_FILENO, &tty) >= 0) {
+ _cleanup_free_ char *q = path_join("/dev", tty);
+ if (!q) {
+ r = -ENOMEM;
+ goto fail;
+ }
- if (getttyname_malloc(STDIN_FILENO, &q) >= 0)
- tty = strjoina("/dev/", q);
+ free_and_replace(tty, q);
}
if (tty) {