summaryrefslogtreecommitdiff
path: root/src/up-config.c
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2011-04-26 12:40:02 +0200
committerMartin Pitt <martin.pitt@ubuntu.com>2011-04-26 12:44:21 +0200
commit065c597b88a45625e7edf273b3b67add126cfb9f (patch)
tree30d46ab671fbcd8c6bf1f6d4401627119f8599bc /src/up-config.c
parent5cb1f4a9a33d3afac1d2c0d49e0def486f9c3557 (diff)
Respect $UPOWER_CONF_FILE_NAME in up_config_init()
The daemon test in up-self-test instantiates an UpDaemon object, which creates an UpConfig object. Unlike UpDaemon itself, up_config_new() did not check for $UPOWER_CONF_FILE_NAME to find the configuration file name. This had the effect that a make check/distcheck run would always try to use the system wide configuration file, and fail if --sysconfdir wasn't specified appropriately.
Diffstat (limited to 'src/up-config.c')
-rw-r--r--src/up-config.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/up-config.c b/src/up-config.c
index 1d92f07..31f4be5 100644
--- a/src/up-config.c
+++ b/src/up-config.c
@@ -73,15 +73,23 @@ up_config_init (UpConfig *config)
{
gboolean ret;
GError *error = NULL;
+ gchar *filename;
config->priv = UP_CONFIG_GET_PRIVATE (config);
config->priv->keyfile = g_key_file_new ();
+ filename = g_strdup (g_getenv ("UPOWER_CONF_FILE_NAME"));
+ if (filename == NULL)
+ filename = g_build_filename (PACKAGE_SYSCONF_DIR,"UPower", "UPower.conf", NULL);
+
/* load */
ret = g_key_file_load_from_file (config->priv->keyfile,
- PACKAGE_SYSCONF_DIR "/UPower/UPower.conf",
+ filename,
G_KEY_FILE_NONE,
&error);
+
+ g_free (filename);
+
if (!ret) {
g_warning ("failed to load config file: %s",
error->message);