summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2023-02-20 22:26:58 +0100
committerChristian Persch <chpe@src.gnome.org>2023-02-20 22:26:58 +0100
commit8b594390a2dc0c9ce128dc363eb48ab3471a480e (patch)
tree5ce9d862aadd8b58a0ba7f441e260cdb7302efae
parentff5f271d38108ea706b54db15571126bb4c5778a (diff)
downloadgnome-terminal-8b594390a2dc0c9ce128dc363eb48ab3471a480e.tar.gz
server: Block pk-gtk module
-rw-r--r--meson.build12
-rw-r--r--src/meson.build1
-rw-r--r--src/server.cc31
3 files changed, 44 insertions, 0 deletions
diff --git a/meson.build b/meson.build
index 2cd40e44..3aeba0b2 100644
--- a/meson.build
+++ b/meson.build
@@ -226,6 +226,18 @@ assert(get_option('b_ndebug') == 'false', 'assertions may not be disabled')
assert(get_option('b_lto') == false, 'LTO not supported')
+# Check for functions
+
+libdl_dep = cxx.find_library('dl')
+
+check_dl_functions_required = [
+ 'dlsym',
+]
+
+foreach func: check_dl_functions_required
+ assert(cxx.has_function(func, dependencies: libdl_dep), func + ' not found')
+endforeach
+
# Compiler flags
compiler_flags_common = [
diff --git a/src/meson.build b/src/meson.build
index 86fa265a..50eee2e0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -254,6 +254,7 @@ server_deps = [
gio_unix_dep,
glib_dep,
gtk_dep,
+ libdl_dep,
pcre2_dep,
pthreads_dep,
schemas_dep,
diff --git a/src/server.cc b/src/server.cc
index 48c09f33..718fbc16 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -25,6 +25,7 @@
#include <locale.h>
#include <pthread.h>
#include <stdlib.h>
+#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/resource.h>
@@ -46,6 +47,36 @@ static char *app_id = nullptr;
#define INACTIVITY_TIMEOUT (100 /* ms */)
+
+#include <dlfcn.h>
+
+// We need to block the pk-gtk module that tries to automagically
+// install fonts.
+// Since there appears to be no way to blocklist a gtk module,
+// we resort to this gross hack.
+
+extern "C" __attribute__((__visibility__("default"))) GModule*
+g_module_open (char const* file_name,
+ GModuleFlags flags);
+
+GModule*
+g_module_open (char const* file_name,
+ GModuleFlags flags)
+{
+ static decltype(&g_module_open) _g_module_open;
+ if (!_g_module_open)
+ _g_module_open = reinterpret_cast<decltype(_g_module_open)>(dlsym(RTLD_NEXT, "g_module_open"));
+
+ if (file_name) {
+ gs_free auto basename = g_path_get_basename(file_name);
+ if (basename && strstr(basename, "pk-gtk-module")) {
+ return _g_module_open("/dev/null", flags);
+ }
+ }
+
+ return _g_module_open(file_name, flags);
+}
+
static gboolean
option_app_id_cb (const gchar *option_name,
const gchar *value,