conf: fix override directory order

We need to load and apply the overrides in the order:

If absolute config path, use only that.
If environment variable, use only that.
Else
 /usr/share/pipewire/*.conf.d/
 /etc/pipewire/*.conf.d/
 $HOME/.config/pipewire/*.conf.d/

Before this patch we would first apply $HOME and then /etc and /usr,
which is not expected.
This commit is contained in:
Wim Taymans 2024-02-16 18:16:30 +01:00
parent 791455c83f
commit ffd9a8b892

View file

@ -162,6 +162,7 @@ no_config:
static int get_config_dir(char *path, size_t size, const char *prefix, const char *name, int *level) static int get_config_dir(char *path, size_t size, const char *prefix, const char *name, int *level)
{ {
int res; int res;
bool no_config;
if (prefix == NULL) { if (prefix == NULL) {
prefix = name; prefix = name;
@ -173,7 +174,8 @@ static int get_config_dir(char *path, size_t size, const char *prefix, const cha
return -ENOENT; return -ENOENT;
} }
if (pw_check_option("no-config", "true")) no_config = pw_check_option("no-config", "true");
if (no_config)
goto no_config; goto no_config;
if ((res = get_envconf_path(path, size, prefix, name)) != 0) { if ((res = get_envconf_path(path, size, prefix, name)) != 0) {
@ -183,9 +185,12 @@ static int get_config_dir(char *path, size_t size, const char *prefix, const cha
} }
if (*level == 0) { if (*level == 0) {
no_config:
(*level)++; (*level)++;
if ((res = get_homeconf_path(path, size, prefix, name)) != 0) if ((res = get_confdata_path(path, size, prefix, name)) != 0)
return res; return res;
if (no_config)
return 0;
} }
if (*level == 1) { if (*level == 1) {
(*level)++; (*level)++;
@ -193,9 +198,8 @@ static int get_config_dir(char *path, size_t size, const char *prefix, const cha
return res; return res;
} }
if (*level == 2) { if (*level == 2) {
no_config:
(*level)++; (*level)++;
if ((res = get_confdata_path(path, size, prefix, name)) != 0) if ((res = get_homeconf_path(path, size, prefix, name)) != 0)
return res; return res;
} }
return 0; return 0;