103 lines
3.5 KiB
Diff
103 lines
3.5 KiB
Diff
From fec27aaf7c7a8e1891eb92c10e899765b6bec951 Mon Sep 17 00:00:00 2001
|
|
From: Rahul Rajesh <rajeshrah22@gmail.com>
|
|
Date: Thu, 19 Mar 2026 11:41:37 -0400
|
|
Subject: [PATCH 1006/1007] core: use GDir to avoid libgvfs loading
|
|
|
|
Replace GFile with GDir to avoid libgvfs and other DBus infra
|
|
initialization.
|
|
|
|
This was done mainly to avoid heavy initialization just for executing
|
|
NetworkManager --print-config command.
|
|
|
|
Resolves: https://redhat.atlassian.net/browse/RHEL-140113
|
|
(cherry picked from commit 2e1ee043a797cab9b6a6ba92be02c4923acd6b35)
|
|
(cherry picked from commit 1cafab5b6bed8f26a1fb1cda9fac50157c3e6414)
|
|
---
|
|
src/core/nm-config.c | 34 ++++++++++++----------------------
|
|
1 file changed, 12 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/src/core/nm-config.c b/src/core/nm-config.c
|
|
index d8bf2e3ed7..c47c7c5280 100644
|
|
--- a/src/core/nm-config.c
|
|
+++ b/src/core/nm-config.c
|
|
@@ -1256,34 +1256,28 @@ read_base_config(GKeyFile *keyfile,
|
|
return TRUE;
|
|
}
|
|
|
|
+/* We want to use GDir instead of GFile here to avoid loading GVFS modules and
|
|
+ * initalizing DBUS infra for communicating with GVFS.
|
|
+ * https://redhat.atlassian.net/browse/RHEL-140113
|
|
+ */
|
|
static GPtrArray *
|
|
_get_config_dir_files(const char *config_dir)
|
|
{
|
|
- GFile *dir;
|
|
- GFileEnumerator *direnum;
|
|
- GFileInfo *info;
|
|
- GPtrArray *confs;
|
|
- const char *name;
|
|
-
|
|
+ GDir *dir;
|
|
+ GPtrArray *confs;
|
|
+ const char *name;
|
|
g_return_val_if_fail(config_dir, NULL);
|
|
-
|
|
confs = g_ptr_array_new_with_free_func(g_free);
|
|
if (!*config_dir)
|
|
return confs;
|
|
-
|
|
- dir = g_file_new_for_path(config_dir);
|
|
- direnum = g_file_enumerate_children(dir, G_FILE_ATTRIBUTE_STANDARD_NAME, 0, NULL, NULL);
|
|
- if (direnum) {
|
|
- while ((info = g_file_enumerator_next_file(direnum, NULL, NULL))) {
|
|
- name = g_file_info_get_name(info);
|
|
+ dir = g_dir_open(config_dir, 0, NULL);
|
|
+ if (dir) {
|
|
+ while ((name = g_dir_read_name(dir))) {
|
|
if (NM_STR_HAS_SUFFIX(name, ".conf"))
|
|
g_ptr_array_add(confs, g_strdup(name));
|
|
- g_object_unref(info);
|
|
}
|
|
- g_object_unref(direnum);
|
|
+ g_dir_close(dir);
|
|
}
|
|
- g_object_unref(dir);
|
|
-
|
|
g_ptr_array_sort(confs, nm_strcmp_p);
|
|
return confs;
|
|
}
|
|
@@ -1339,8 +1333,7 @@ read_entire_config(const NMConfigCmdLineOptions *cli,
|
|
run_config_dir = RUN_CONFIG_DIR;
|
|
|
|
/* create a default configuration file. */
|
|
- keyfile = nm_config_create_keyfile();
|
|
-
|
|
+ keyfile = nm_config_create_keyfile();
|
|
system_confs = _get_config_dir_files(system_config_dir);
|
|
confs = _get_config_dir_files(config_dir);
|
|
run_confs = _get_config_dir_files(run_config_dir);
|
|
@@ -3292,7 +3285,6 @@ init_sync(GInitable *initable, GCancellable *cancellable, GError **error)
|
|
g_set_error(error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_NOT_FOUND, "unspecified error");
|
|
g_return_val_if_reached(FALSE);
|
|
}
|
|
-
|
|
s = priv->cli.config_dir ?: "" DEFAULT_CONFIG_DIR;
|
|
priv->config_dir = g_strdup(s[0] == '/' ? s : "");
|
|
|
|
@@ -3300,12 +3292,10 @@ init_sync(GInitable *initable, GCancellable *cancellable, GError **error)
|
|
if (s[0] != '/' || nm_streq(s, priv->config_dir))
|
|
s = "";
|
|
priv->system_config_dir = g_strdup(s);
|
|
-
|
|
if (priv->cli.intern_config_file)
|
|
priv->intern_config_file = g_strdup(priv->cli.intern_config_file);
|
|
else
|
|
priv->intern_config_file = g_strdup(DEFAULT_INTERN_CONFIG_FILE);
|
|
-
|
|
warnings = g_ptr_array_new_with_free_func(g_free);
|
|
|
|
keyfile = read_entire_config(&priv->cli,
|
|
--
|
|
2.54.0
|
|
|