[PATCH 2/9] main: Support main.conf.d/ files for overriding configs
Jussi Laakkonen <[email protected]> Wed, 20 May 2026 16:47:06 +0300
| Newsgroups | dev.linux.lists.connman |
|---|---|
| Message-ID | <[email protected]> |
Use the util conf.d support to read additional configs. The values in
these additional configs will override any existing configuration set in
the main.conf or any previous conf.d files.
---
src/main.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/main.c b/src/main.c
index ddb28276..b1b4fd5a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -3,6 +3,7 @@
* Connection Manager
*
* Copyright (C) 2007-2013 Intel Corporation. All rights reserved.
+ * Copyright (C) 2025 Jolla Mobile Ltd. All right reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -38,6 +39,7 @@
#include <gdbus.h>
#include "connman.h"
+#include "src/shared/util.h"
#define CONF_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]) - 1)
@@ -68,6 +70,8 @@
#define MAINFILE "main.conf"
#define CONFIGMAINFILE CONFIGDIR "/" MAINFILE
+#define CONFIGMAINDIR CONFIGMAINFILE ".d"
+#define CONFIGSUFFIX ".conf"
#define GENERAL_GROUP "General"
@@ -1229,6 +1233,7 @@ int main(int argc, char *argv[])
DBusConnection *conn;
DBusError err;
guint signal;
+ int fs_err;
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
@@ -1292,6 +1297,12 @@ int main(int argc, char *argv[])
else
config_init(option_config);
+ fs_err = util_read_config_files_from(CONFIGMAINDIR, CONFIGSUFFIX,
+ NULL, config_init);
+ if (fs_err && fs_err != -ENOTDIR)
+ connman_error("failed to read configs from %s: %s",
+ CONFIGMAINDIR, strerror(fs_err));
+
__connman_util_init();
__connman_inotify_init();
__connman_technology_init();
--
2.47.3