mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
sysext: split parsing SYSTEMD_SYSEXT_HIERARCHIES in a common helper
This commit is contained in:
@@ -77,3 +77,18 @@ int extension_release_validate(
|
||||
log_debug("Version info of extension '%s' matches host.", name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int parse_env_extension_hierarchies(char ***ret_hierarchies) {
|
||||
int r;
|
||||
|
||||
r = getenv_path_list("SYSTEMD_SYSEXT_HIERARCHIES", ret_hierarchies);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to parse SYSTEMD_SYSEXT_HIERARCHIES environment variable : %m");
|
||||
if (!*ret_hierarchies) {
|
||||
*ret_hierarchies = strv_new("/usr", "/opt");
|
||||
if (!*ret_hierarchies)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,3 +10,6 @@ int extension_release_validate(
|
||||
const char *host_os_release_version_id,
|
||||
const char *host_os_release_sysext_level,
|
||||
char **extension_release);
|
||||
|
||||
/* Parse SYSTEMD_SYSEXT_HIERARCHIES and if not set, return "/usr /opt" */
|
||||
int parse_env_extension_hierarchies(char ***ret_hierarchies);
|
||||
|
||||
@@ -982,16 +982,10 @@ static int run(int argc, char *argv[]) {
|
||||
/* For debugging purposes it might make sense to do this for other hierarchies than /usr/ and
|
||||
* /opt/, but let's make that a hacker/debugging feature, i.e. env var instead of cmdline
|
||||
* switch. */
|
||||
r = getenv_path_list("SYSTEMD_SYSEXT_HIERARCHIES", &arg_hierarchies);
|
||||
r = parse_env_extension_hierarchies(&arg_hierarchies);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse $SYSTEMD_SYSEXT_HIERARCHIES environment variable: %m");
|
||||
|
||||
if (!arg_hierarchies) {
|
||||
arg_hierarchies = strv_new("/usr", "/opt");
|
||||
if (!arg_hierarchies)
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
return sysext_main(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user