summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd/sd-json/json-util.h2
-rw-r--r--src/libsystemd/sd-json/sd-json.c13
2 files changed, 13 insertions, 2 deletions
diff --git a/src/libsystemd/sd-json/json-util.h b/src/libsystemd/sd-json/json-util.h
index 2aeb076823..81c0fd02a6 100644
--- a/src/libsystemd/sd-json/json-util.h
+++ b/src/libsystemd/sd-json/json-util.h
@@ -157,6 +157,7 @@ enum {
_JSON_BUILD_PAIR_FINITE_USEC,
_JSON_BUILD_PAIR_STRING_NON_EMPTY,
_JSON_BUILD_PAIR_STRV_NON_EMPTY,
+ _JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY,
_JSON_BUILD_PAIR_VARIANT_NON_NULL,
/* _SD_JSON_BUILD_PAIR_VARIANT_ARRAY_NON_EMPTY, */
_JSON_BUILD_PAIR_BYTE_ARRAY_NON_EMPTY,
@@ -204,6 +205,7 @@ enum {
#define JSON_BUILD_PAIR_FINITE_USEC(name, u) _JSON_BUILD_PAIR_FINITE_USEC, (const char*) { name }, (usec_t) { u }
#define JSON_BUILD_PAIR_STRING_NON_EMPTY(name, s) _JSON_BUILD_PAIR_STRING_NON_EMPTY, (const char*) { name }, (const char*) { s }
#define JSON_BUILD_PAIR_STRV_NON_EMPTY(name, l) _JSON_BUILD_PAIR_STRV_NON_EMPTY, (const char*) { name }, (char**) { l }
+#define JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY(name, l) _JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY, (const char*) { name }, (char**) { l }
#define JSON_BUILD_PAIR_VARIANT_NON_NULL(name, v) _JSON_BUILD_PAIR_VARIANT_NON_NULL, (const char*) { name }, (sd_json_variant*) { v }
#define JSON_BUILD_PAIR_BYTE_ARRAY_NON_EMPTY(name, v, n) _JSON_BUILD_PAIR_BYTE_ARRAY_NON_EMPTY, (const char*) { name }, (const void*) { v }, (size_t) { n }
#define JSON_BUILD_PAIR_IN4_ADDR_NON_NULL(name, v) _JSON_BUILD_PAIR_IN4_ADDR_NON_NULL, (const char*) { name }, (const struct in_addr*) { v }
diff --git a/src/libsystemd/sd-json/sd-json.c b/src/libsystemd/sd-json/sd-json.c
index 293df301a2..f0a9470a17 100644
--- a/src/libsystemd/sd-json/sd-json.c
+++ b/src/libsystemd/sd-json/sd-json.c
@@ -4533,7 +4533,8 @@ _public_ int sd_json_buildv(sd_json_variant **ret, va_list ap) {
break;
}
- case _JSON_BUILD_PAIR_STRV_NON_EMPTY: {
+ case _JSON_BUILD_PAIR_STRV_NON_EMPTY:
+ case _JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY: {
const char *n;
char **l;
@@ -4546,11 +4547,19 @@ _public_ int sd_json_buildv(sd_json_variant **ret, va_list ap) {
l = va_arg(ap, char **);
if (!strv_isempty(l) && current->n_suppress == 0) {
+ _cleanup_strv_free_ char **el = NULL;
+
+ if (command == _JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY) {
+ r = strv_env_get_merged(l, &el);
+ if (r < 0)
+ goto finish;
+ }
+
r = sd_json_variant_new_string(&add, n);
if (r < 0)
goto finish;
- r = sd_json_variant_new_array_strv(&add_more, l);
+ r = sd_json_variant_new_array_strv(&add_more, el ?: l);
if (r < 0)
goto finish;
}