conf: support overriding context configuration in a different location

Allows placing override configuration files into a different directory. This is
Useful when pipewire clients such as wireplumber want their fully commented
configuration files under /etc/wireplumber, and fully uncommented configuration
files under /usr/share/wireplumber.

The point is solving the issue of users copying files from /usr/share/pipewire,
which contain various critical settings in addition to tweaking the config,
and then encountering problems at upgrade time when new critical settings are
added.
This commit is contained in:
Julian Bouzas 2022-08-05 07:48:53 -04:00
parent a9cf72932a
commit b718dd5046
2 changed files with 24 additions and 0 deletions

View file

@ -933,6 +933,28 @@ int pw_conf_load_conf_for_context(struct pw_properties *props, struct pw_propert
}
}
conf_name = pw_properties_get(props, PW_KEY_CONFIG_OVERRIDE_NAME);
if (conf_name != NULL) {
struct pw_properties *override;
const char *path;
override = pw_properties_new(NULL, NULL);
if (override == NULL) {
res = -errno;
return res;
}
conf_prefix = pw_properties_get(props, PW_KEY_CONFIG_OVERRIDE_PREFIX);
if ((res = try_load_conf(conf_prefix, conf_name, override)) < 0) {
pw_log_error("can't load default override config %s: %s",
conf_name, spa_strerror(res));
pw_properties_free (override);
return res;
}
path = pw_properties_get(override, "config.path");
add_override(conf, override, path, 0, 1);
}
return res;
}

View file

@ -76,6 +76,8 @@ extern "C" {
/* config */
#define PW_KEY_CONFIG_PREFIX "config.prefix" /**< a config prefix directory */
#define PW_KEY_CONFIG_NAME "config.name" /**< a config file name */
#define PW_KEY_CONFIG_OVERRIDE_PREFIX "config.override.prefix" /**< a config override prefix directory */
#define PW_KEY_CONFIG_OVERRIDE_NAME "config.override.name" /**< a config override file name */
/* context */
#define PW_KEY_CONTEXT_PROFILE_MODULES "context.profile.modules" /**< a context profile for modules, deprecated */