From abc018245bdbfec3764cd0eeedae82b62c7095d2 Mon Sep 17 00:00:00 2001 From: Youngjae Cho Date: Thu, 7 Mar 2024 19:09:52 +0900 Subject: [PATCH] Cherrypick the deprecated g_module_build_path() from upstream As of the glib version 2.76, the g_module_build_path() has been deprecated due to inconsistency of G_MODULE_SUFFIX. (See https://github.com/GNOME/glib/commit/d941558) However, we know that the G_MODULE_SUFFIX is clearly "so" on our unix environment. Therefore, copy and reuse the deprecated function internally, replacing G_MODULE_SUFFIX with string literal "so". The g_module_open() has been improved as a compensation for the deprecation, which takes care of all the possible G_MODULE_SUFFIX. But we cannot use it instead, as we need full path before calling g_module_open() to check several file attributes. Change-Id: I7e939fc3fbe6697cacb3205adc8d453205449ae7 Signed-off-by: Youngjae Cho --- src/daemon/tlm-manager.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/daemon/tlm-manager.c b/src/daemon/tlm-manager.c index 67475a8..d96da5a 100644 --- a/src/daemon/tlm-manager.c +++ b/src/daemon/tlm-manager.c @@ -91,6 +91,21 @@ typedef struct _TlmSeatWatchClosure gchar *seat_path; } TlmSeatWatchClosure; +static gchar* +_g_module_build_path (const gchar *directory, + const gchar *module_name) +{ + if (directory && *directory) { + if (strncmp (module_name, "lib", 3) == 0) + return g_strconcat (directory, "/", module_name, NULL); + else + return g_strconcat (directory, "/lib", module_name, ".so", NULL); + } else if (strncmp (module_name, "lib", 3) == 0) + return g_strdup (module_name); + else + return g_strconcat ("lib", module_name, ".so", NULL); +} + static void _unref_auth_plugins (gpointer data) { @@ -197,7 +212,7 @@ tlm_manager_class_init (TlmManagerClass *klass) { GObjectClass *g_klass = G_OBJECT_CLASS (klass); - g_klass->constructor = tlm_manager_constructor; + g_klass->constructor = tlm_manager_constructor; g_klass->dispose = tlm_manager_dispose ; g_klass->finalize = tlm_manager_finalize; g_klass->set_property = _manager_set_property; @@ -277,7 +292,7 @@ _manager_authenticate_cb (TlmAuthPlugin *plugin, } static GObject * -_load_plugin_file (const gchar *file_path, +_load_plugin_file (const gchar *file_path, const gchar *plugin_name, const gchar *plugin_type, GHashTable *config) @@ -342,7 +357,7 @@ _load_accounts_plugin (TlmManager *self, const gchar *name) accounts_config = tlm_config_get_group (self->priv->config, name); plugin_file_name = g_strdup_printf ("libtlm-plugin-%s", name); - plugin_file = g_module_build_path(plugins_path, plugin_file_name); + plugin_file = _g_module_build_path(plugins_path, plugin_file_name); g_free (plugin_file_name); self->priv->account_plugin = TLM_ACCOUNT_PLUGIN( @@ -360,7 +375,7 @@ _load_auth_plugins (TlmManager *self) GError *error = NULL; plugins_path = _get_plugins_path (); - + DBG("plugins_path : %s", plugins_path); plugins_dir = g_dir_open (plugins_path, 0, &error); if (!plugins_dir) { @@ -380,11 +395,11 @@ _load_auth_plugins (TlmManager *self) gchar *plugin_name = NULL; GHashTable *plugin_config = NULL; GObject *plugin = NULL; - - plugin_file_path = g_module_build_path(plugins_path, + + plugin_file_path = _g_module_build_path(plugins_path, plugin_file_name); - if (!g_file_test (plugin_file_path, + if (!g_file_test (plugin_file_path, G_FILE_TEST_IS_REGULAR && G_FILE_TEST_EXISTS)) { WARN ("Ingnoring plugin : %s", plugin_file_path); g_free (plugin_file_path); @@ -392,15 +407,15 @@ _load_auth_plugins (TlmManager *self) } DBG ("loading auth plugin '%s'", plugin_file_name); - + plugin_name = g_strdup (plugin_file_name + 14); // truncate prefix plugin_name[strlen(plugin_name) - 3] = '\0' ; // truncate suffix plugin_config = tlm_config_get_group (self->priv->config, plugin_name); - + plugin = _load_plugin_file (plugin_file_path, - plugin_name, + plugin_name, "auth", plugin_config); if (plugin) { @@ -710,7 +725,7 @@ _manager_on_seat_removed (GDBusConnection *connection, g_hash_table_remove (manager->priv->seats, id); g_signal_emit (manager, signals[SIG_SEAT_REMOVED], 0, id, NULL); - } + } g_free (id); g_free (path); } @@ -850,7 +865,7 @@ tlm_manager_setup_guest_user (TlmManager *manager, const gchar *user_name) manager->priv->account_plugin, user_name, FALSE); } else { - DBG("Asking plugin to setup guest user '%s'", user_name); + DBG("Asking plugin to setup guest user '%s'", user_name); return tlm_account_plugin_setup_guest_user_account ( manager->priv->account_plugin, user_name); } -- 2.7.4