diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-15 14:09:30 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-02-15 20:43:41 +0100 |
commit | aaf057c4bbc6055040d7d2c1ec3655ff89249ebd (patch) | |
tree | 7981275d953245cf8908b64bd753d3bcd13c5da4 /src/home/homectl.c | |
parent | ci: switch back to meson-0.56.2 (diff) | |
download | systemd-aaf057c4bbc6055040d7d2c1ec3655ff89249ebd.tar.xz systemd-aaf057c4bbc6055040d7d2c1ec3655ff89249ebd.zip |
basic/env-util: add variant of strv_env_replace() that does strdup internally
Diffstat (limited to 'src/home/homectl.c')
-rw-r--r-- | src/home/homectl.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/home/homectl.c b/src/home/homectl.c index bf35fa03f0..dfbd12a4df 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -2511,7 +2511,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_SETENV: { - _cleanup_free_ char **l = NULL, **k = NULL; + _cleanup_free_ char **l = NULL; _cleanup_(json_variant_unrefp) JsonVariant *ne = NULL; JsonVariant *e; @@ -2524,7 +2524,8 @@ static int parse_argv(int argc, char *argv[]) { } if (!env_assignment_is_valid(optarg)) - return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Environment assignment '%s' not valid.", optarg); + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Environment assignment '%s' not valid.", optarg); e = json_variant_by_key(arg_identity_extra, "environment"); if (e) { @@ -2533,13 +2534,13 @@ static int parse_argv(int argc, char *argv[]) { return log_error_errno(r, "Failed to parse JSON environment field: %m"); } - k = strv_env_set(l, optarg); - if (!k) - return log_oom(); + r = strv_env_replace_strdup(&l, optarg); + if (r < 0) + return log_error_errno(r, "Failed to replace JSON environment field: %m"); - strv_sort(k); + strv_sort(l); - r = json_variant_new_array_strv(&ne, k); + r = json_variant_new_array_strv(&ne, l); if (r < 0) return log_error_errno(r, "Failed to allocate environment list JSON: %m"); |