core: Resolve /dev/console if it's connected to stdin (#36666)

This commit is contained in:
Daan De Meyer
2025-04-06 14:14:35 +02:00
committed by GitHub
3 changed files with 26 additions and 15 deletions
+6 -6
View File
@@ -1156,10 +1156,12 @@ int resolve_dev_console(char **ret) {
tty = active;
}
if (tty != active)
return strdup_to(ret, tty);
_cleanup_free_ char *path = NULL;
path = path_join("/dev", tty);
if (!path)
return -ENOMEM;
*ret = TAKE_PTR(active);
*ret = TAKE_PTR(path);
return 0;
}
@@ -1231,9 +1233,7 @@ bool tty_is_vc_resolve(const char *tty) {
assert(tty);
tty = skip_dev_prefix(tty);
if (streq(tty, "console")) {
if (streq(skip_dev_prefix(tty), "console")) {
if (resolve_dev_console(&resolved) < 0)
return false;