path-lookup: Use default value for XDG_CONFIG_DIRS if environment is not set
authorDavid Edmundson <davidedmundson@kde.org>
Wed, 25 Mar 2020 22:49:35 +0000 (22:49 +0000)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 1 Apr 2020 17:16:03 +0000 (19:16 +0200)
If XDG_CONFIG_DIRS is unset, the specification says we should assume
/etc/xdg.

(cherry picked from commit f0d0698f0b7d565e6eade043450f7f5557c8db48)

src/shared/path-lookup.c

index 5b162097453659ea35af3c117b82d92661420dd2..48e0eec09a8b2edb9220c7bcd2f9a749d13143e8 100644 (file)
@@ -125,11 +125,12 @@ int xdg_user_dirs(char ***ret_config_dirs, char ***ret_data_dirs) {
         _cleanup_strv_free_ char **config_dirs = NULL, **data_dirs = NULL;
 
         e = getenv("XDG_CONFIG_DIRS");
-        if (e) {
+        if (e)
                 config_dirs = strv_split(e, ":");
-                if (!config_dirs)
-                        return -ENOMEM;
-        }
+        else
+                config_dirs = strv_new("/etc/xdg");
+        if (!config_dirs)
+                return -ENOMEM;
 
         e = getenv("XDG_DATA_DIRS");
         if (e)