1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 01:55:22 +03:00

Merge pull request #18798 from poettering/getenv-list-fixes

various follow-ups for ExtensionImages= PR
This commit is contained in:
Lennart Poettering 2021-02-25 17:00:54 +01:00 committed by GitHub
commit 584e9ba962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 28 deletions

View File

@ -813,11 +813,9 @@ int getenv_path_list(const char *name, char ***ret_paths) {
assert(name);
assert(ret_paths);
*ret_paths = NULL;
e = secure_getenv(name);
if (!e)
return 0;
return -ENXIO;
r = strv_split_full(&l, e, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
if (r < 0)
@ -842,5 +840,5 @@ int getenv_path_list(const char *name, char ***ret_paths) {
"No paths specified, refusing.");
*ret_paths = TAKE_PTR(l);
return 0;
return 1;
}

View File

@ -1554,9 +1554,12 @@ static int apply_mounts(
* /proc. For example, this is the case with the option: 'InaccessiblePaths=/proc'. */
proc_self_mountinfo = fopen("/proc/self/mountinfo", "re");
if (!proc_self_mountinfo) {
r = -errno;
if (error_path)
*error_path = strdup("/proc/self/mountinfo");
return log_debug_errno(errno, "Failed to open /proc/self/mountinfo: %m");
return log_debug_errno(r, "Failed to open /proc/self/mountinfo: %m");
}
/* First round, establish all mounts we need */

View File

@ -1631,10 +1631,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
return log_error_errno(r, "Failed to parse argument: %m");
STRV_FOREACH_PAIR(first, second, l) {
/* Format is either 'root:foo' or 'foo' (root is implied) */
if (!isempty(*second) && partition_designator_from_string(*first) < 0)
return bus_log_create_error(-EINVAL);
r = sd_bus_message_append(m, "(ss)",
!isempty(*second) ? *first : "root",
!isempty(*second) ? *second : *first);
@ -1683,14 +1679,14 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
r = extract_first_word(&p, &tuple, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE);
if (r < 0)
return r;
return log_error_errno(r, "Failed to parse MountImages= property: %s", eq);
if (r == 0)
break;
q = tuple;
r = extract_many_words(&q, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS, &first, &second, NULL);
if (r < 0)
return r;
return log_error_errno(r, "Failed to parse MountImages= property: %s", eq);
if (r == 0)
continue;
@ -1722,7 +1718,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
r = extract_many_words(&q, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS, &partition, &mount_options, NULL);
if (r < 0)
return r;
return log_error_errno(r, "Failed to parse MountImages= property: %s", eq);
if (r == 0)
break;
/* Single set of options, applying to the root partition/single filesystem */
@ -1734,9 +1730,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
break;
}
if (partition_designator_from_string(partition) < 0)
return bus_log_create_error(-EINVAL);
r = sd_bus_message_append(m, "(ss)", partition, mount_options);
if (r < 0)
return bus_log_create_error(r);
@ -1792,14 +1785,14 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
r = extract_first_word(&p, &tuple, NULL, EXTRACT_UNQUOTE|EXTRACT_RETAIN_ESCAPE);
if (r < 0)
return r;
return log_error_errno(r, "Failed to parse ExtensionImages= property: %s", eq);
if (r == 0)
break;
q = tuple;
r = extract_first_word(&q, &source, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS);
if (r < 0)
return r;
return log_error_errno(r, "Failed to parse ExtensionImages= property: %s", eq);
if (r == 0)
continue;
@ -1826,7 +1819,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
r = extract_many_words(&q, ":", EXTRACT_CUNESCAPE|EXTRACT_UNESCAPE_SEPARATORS, &partition, &mount_options, NULL);
if (r < 0)
return r;
return log_error_errno(r, "Failed to parse ExtensionImages= property: %s", eq);
if (r == 0)
break;
/* Single set of options, applying to the root partition/single filesystem */
@ -1838,9 +1831,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
break;
}
if (partition_designator_from_string(partition) < 0)
return bus_log_create_error(-EINVAL);
r = sd_bus_message_append(m, "(ss)", partition, mount_options);
if (r < 0)
return bus_log_create_error(r);

View File

@ -79,16 +79,18 @@ int extension_release_validate(
}
int parse_env_extension_hierarchies(char ***ret_hierarchies) {
_cleanup_free_ char **l = NULL;
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)
r = getenv_path_list("SYSTEMD_SYSEXT_HIERARCHIES", &l);
if (r == -ENXIO) {
/* Default when unset */
l = strv_new("/usr", "/opt");
if (!l)
return -ENOMEM;
}
} else if (r < 0)
return r;
*ret_hierarchies = TAKE_PTR(l);
return 0;
}