1
0
Files
gnome-terminal/f06e6e5.patch
2022-11-09 14:39:50 +00:00

80 lines
3.0 KiB
Diff

From f06e6e5821a1a718431d25ccd8d08225ba66dd58 Mon Sep 17 00:00:00 2001
From: Christian Persch <chpe@src.gnome.org>
Date: Sun, 6 Nov 2022 15:58:05 +0100
Subject: [PATCH] util: Fix interpretation of TryExec desktop entry key
The TryExec key is optional, so only evalute it if it is present.
Also, it may contain an abolute path, in which case we skip searching
the PATH for the executable.
Fixes: https://gitlab.gnome.org/GNOME/gnome-terminal/-/issues/7944
(cherry picked from commit 78971c71992e7dcf021743dc8873a2088245335c)
---
src/terminal-util.cc | 39 +++++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/src/terminal-util.cc b/src/terminal-util.cc
index fcdd939a..3ee8f51b 100644
--- a/src/terminal-util.cc
+++ b/src/terminal-util.cc
@@ -1626,29 +1626,44 @@ xte_data_check_one(char const* file,
return false;
}
- // As per the XDG desktop entry spec, the TryExec key contains the name
- // of an executable that can be used to determine if the programme is
- // actually present.
+ // As per the XDG desktop entry spec, the (optional) TryExec key contains
+ // the name of an executable that can be used to determine if the programme
+ // is actually present.
gs_free auto try_exec = g_key_file_get_string(kf,
G_KEY_FILE_DESKTOP_GROUP,
G_KEY_FILE_DESKTOP_KEY_TRY_EXEC,
nullptr);
- if (!try_exec) {
+ if (try_exec && try_exec[0]) {
_terminal_debug_print(TERMINAL_DEBUG_DEFAULT,
"Desktop file \"%s\" has no TryExec field.\n",
file);
- return false;
- }
+ // TryExec may be an abolute path, or be searched in $PATH
+ gs_free char* exec_path = nullptr;
+ if (g_path_is_absolute(try_exec))
+ exec_path = g_strdup(try_exec);
+ else
+ exec_path = g_find_program_in_path(try_exec);
- gs_free auto exec_path = g_find_program_in_path(try_exec);
- auto const exists = exec_path != nullptr;
+ auto const exists = exec_path != nullptr &&
+ g_file_test(exec_path, GFileTest(G_FILE_TEST_IS_EXECUTABLE));
- _terminal_debug_print(TERMINAL_DEBUG_DEFAULT,
- "Desktop file \"%s\" is %sinstalled.\n",
- file, exists ? "" : "not ");
+ _terminal_debug_print(TERMINAL_DEBUG_DEFAULT,
+ "Desktop file \"%s\" is %sinstalled (TryExec).\n",
+ file, exists ? "" : "not ");
+
+ if (!exists)
+ return false;
+ } else {
+ // TryExec is not present. We could fall back to parsing the Exec
+ // key and look if its first argument points to an executable that
+ // exists on the system, but that may also fail if the desktop file
+ // is DBusActivatable=true in which case we would need to find
+ // out if the D-Bus service corresponding to the name of the desktop
+ // file (without the .desktop extension) is activatable.
+ }
- return exists;
+ return true;
}
static bool
--
GitLab