gnu: nautilus: Fix crash due to loading extensions twice.
Fixes <https://issues.guix.gnu.org/58221>. Reported by Tobias Kortkamp <tobias.kortkamp@gmail.com>. Previously, if NAUTILUS_EXTENSION_PATH contained the same directory several times, Nautilus could end up loading the same extension a second time and crash. This patch ensures that each extension cannot be loaded more than once. * gnu/packages/patches/nautilus-extension-search-path.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/gnome.scm (nautilus)[source]: Use it. [arguments]: Remove 'make-extensible' phase.
This commit is contained in:
parent
8c7ea71344
commit
99ba4ddb03
@ -1561,6 +1561,7 @@ dist_patch_DATA = \
|
||||
%D%/packages/patches/musl-cross-locale.patch \
|
||||
%D%/packages/patches/mutt-store-references.patch \
|
||||
%D%/packages/patches/m4-gnulib-libio.patch \
|
||||
%D%/packages/patches/nautilus-extension-search-path.patch \
|
||||
%D%/packages/patches/ncompress-fix-softlinks.patch \
|
||||
%D%/packages/patches/ncftp-reproducible.patch \
|
||||
%D%/packages/patches/netcdf-date-time.patch \
|
||||
|
@ -9671,7 +9671,9 @@ shared object databases, search tools and indexing.")
|
||||
name "-" version ".tar.xz"))
|
||||
(sha256
|
||||
(base32
|
||||
"1cncyiyh79w1id6a6s2f0rxmgwl65lp4ml4afa0z35jrnwp2s8cr"))))
|
||||
"1cncyiyh79w1id6a6s2f0rxmgwl65lp4ml4afa0z35jrnwp2s8cr"))
|
||||
(patches
|
||||
(search-patches "nautilus-extension-search-path.patch"))))
|
||||
(build-system meson-build-system)
|
||||
(arguments
|
||||
(list
|
||||
@ -9685,27 +9687,6 @@ shared object databases, search tools and indexing.")
|
||||
(substitute* "test/automated/displayless/meson.build"
|
||||
(("^foreach t: tracker_tests" all)
|
||||
(string-append "tracker_tests = []\n" all)))))
|
||||
(add-after 'unpack 'make-extensible
|
||||
(lambda _
|
||||
(substitute* "src/nautilus-module.c"
|
||||
(("static gboolean initialized = FALSE;" all)
|
||||
(string-append all "
|
||||
const char *extension_path;
|
||||
char **extension_dirs, **d;
|
||||
")
|
||||
)
|
||||
(("load_module_dir \\(NAUTILUS_EXTENSIONDIR\\);" all)
|
||||
(string-append all
|
||||
"
|
||||
extension_path = g_getenv (\"NAUTILUS_EXTENSION_PATH\");
|
||||
if (extension_path)
|
||||
{
|
||||
extension_dirs = g_strsplit (extension_path, \":\", -1);
|
||||
for (d = extension_dirs; d != NULL && *d != NULL; d++)
|
||||
load_module_dir(*d);
|
||||
g_strfreev(extension_dirs);
|
||||
}
|
||||
")))))
|
||||
(add-after 'unpack 'skip-gtk-update-icon-cache
|
||||
;; Don't create 'icon-theme.cache'.
|
||||
(lambda _
|
||||
|
75
gnu/packages/patches/nautilus-extension-search-path.patch
Normal file
75
gnu/packages/patches/nautilus-extension-search-path.patch
Normal file
@ -0,0 +1,75 @@
|
||||
Allow Nautilus to search for extensions in the directories listed
|
||||
in $NAUTILUS_EXTENSION_PATH.
|
||||
|
||||
diff --git a/src/nautilus-module.c b/src/nautilus-module.c
|
||||
index bf474bd..42e2a4e 100644
|
||||
--- a/src/nautilus-module.c
|
||||
+++ b/src/nautilus-module.c
|
||||
@@ -211,6 +211,10 @@ static void
|
||||
load_module_dir (const char *dirname)
|
||||
{
|
||||
GDir *dir;
|
||||
+ static GHashTable *loaded = NULL;
|
||||
+
|
||||
+ if (loaded == NULL)
|
||||
+ loaded = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
dir = g_dir_open (dirname, 0, NULL);
|
||||
|
||||
@@ -221,15 +225,22 @@ load_module_dir (const char *dirname)
|
||||
while ((name = g_dir_read_name (dir)))
|
||||
{
|
||||
if (g_str_has_suffix (name, "." G_MODULE_SUFFIX))
|
||||
- {
|
||||
- char *filename;
|
||||
-
|
||||
- filename = g_build_filename (dirname,
|
||||
- name,
|
||||
- NULL);
|
||||
- nautilus_module_load_file (filename);
|
||||
- g_free (filename);
|
||||
- }
|
||||
+ {
|
||||
+ /* Make sure each module is loaded only twice or this could
|
||||
+ lead to a crash. Double loading can occur if DIRNAME
|
||||
+ occurs more than once in $NAUTILUS_EXTENSION_PATH. */
|
||||
+ if (!g_hash_table_contains (loaded, name))
|
||||
+ {
|
||||
+ char *filename;
|
||||
+
|
||||
+ filename = g_build_filename (dirname,
|
||||
+ name,
|
||||
+ NULL);
|
||||
+ nautilus_module_load_file (filename);
|
||||
+ g_hash_table_add (loaded, g_strdup (name));
|
||||
+ g_free (filename);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
g_dir_close (dir);
|
||||
@@ -257,10 +268,24 @@ nautilus_module_setup (void)
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
+ const gchar *extension_path;
|
||||
initialized = TRUE;
|
||||
|
||||
load_module_dir (NAUTILUS_EXTENSIONDIR);
|
||||
|
||||
+ /* Load additional modules from the user-provided search path. */
|
||||
+ extension_path = g_getenv ("NAUTILUS_EXTENSION_PATH");
|
||||
+ if (extension_path)
|
||||
+ {
|
||||
+ char **extension_dirs, **d;
|
||||
+
|
||||
+ extension_dirs = g_strsplit (extension_path, ":", -1);
|
||||
+ for (d = extension_dirs; d != NULL && *d != NULL; d++)
|
||||
+ load_module_dir (*d);
|
||||
+
|
||||
+ g_strfreev (extension_dirs);
|
||||
+ }
|
||||
+
|
||||
eel_debug_call_at_shutdown (free_module_objects);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user