From: Daan De Meyer Date: Fri, 21 Mar 2025 09:36:14 +0000 (+0100) Subject: terminal-util: Make sure resolve_dev_console() always returns a full path X-Git-Tag: v258-rc1~901^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7f7d87db54d8537c54d259a369304ff9a352dd4;p=thirdparty%2Fsystemd.git terminal-util: Make sure resolve_dev_console() always returns a full path Currently it returns a full path in some cases and a partial path in others. Let's make sure it always returns a full path. --- diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 50ad4c89af3..498e2d532ba 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -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; diff --git a/src/core/execute.c b/src/core/execute.c index 3bc80cd6436..93fce15d0d9 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -970,7 +970,7 @@ static bool tty_may_match_dev_console(const char *tty) { return true; /* if we could not resolve, assume it may */ /* "tty0" means the active VC, so it may be the same sometimes */ - return path_equal(resolved, tty) || (streq(resolved, "tty0") && tty_is_vc(tty)); + return path_equal(skip_dev_prefix(resolved), tty) || (streq(skip_dev_prefix(resolved), "tty0") && tty_is_vc(tty)); } static bool exec_context_may_touch_tty(const ExecContext *ec) {