3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

main: Add support for CONFIGURATION_DIRECTORY environment variable

This commit is contained in:
Marcel Holtmann 2019-09-08 10:22:36 +02:00
parent 8a0c148368
commit 4c841edfb5

View File

@ -53,7 +53,6 @@ static const char *interfaces;
static const char *nointerfaces;
static const char *phys;
static const char *nophys;
static const char *config_dir;
static const char *plugins;
static const char *noplugins;
static const char *debugopt;
@ -348,8 +347,10 @@ int main(int argc, char *argv[])
bool enable_dbus_debug = false;
int exit_status;
struct l_dbus *dbus;
char *config_path;
const char *config_dir = NULL;
char **config_dirs;
uint32_t eap_mtu;
int i;
for (;;) {
int opt;
@ -425,16 +426,30 @@ int main(int argc, char *argv[])
l_info("Wireless daemon version %s", VERSION);
if (!config_dir)
config_dir = DAEMON_CONFIGDIR;
if (!config_dir) {
config_dir = getenv("CONFIGURATION_DIRECTORY");
if (!config_dir)
config_dir = DAEMON_CONFIGDIR;
}
l_debug("Using configuration directory %s", config_dir);
config_path = l_strdup_printf("%s/%s", config_dir, "main.conf");
iwd_config = l_settings_new();
if (!l_settings_load_from_file(iwd_config, config_path))
l_warn("Skipping optional configuration file %s", config_path);
config_dirs = l_strsplit(config_dir, ':');
for (i = 0; config_dirs[i]; i++) {
char *path = l_strdup_printf("%s/%s", config_dirs[i],
"main.conf");
bool result = l_settings_load_from_file(iwd_config, path);
l_free(path);
l_free(config_path);
if (result) {
l_info("Loaded configuration from %s/main.conf",
config_dirs[i]);
break;
}
}
l_strv_free(config_dirs);
__eapol_set_config(iwd_config);