summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/boot/bootctl-reboot-to-firmware.c2
-rw-r--r--src/boot/bootctl-status.c6
-rw-r--r--src/boot/measure.c29
-rw-r--r--src/busctl/busctl.c14
-rw-r--r--src/core/core-varlink.c24
-rw-r--r--src/creds/creds.c4
-rw-r--r--src/cryptenroll/cryptenroll-fido2.c19
-rw-r--r--src/cryptenroll/cryptenroll-pkcs11.c11
-rw-r--r--src/cryptenroll/cryptenroll-recovery.c7
-rw-r--r--src/dissect/dissect.c47
-rw-r--r--src/home/homectl-fido2.c14
-rw-r--r--src/home/homectl-pkcs11.c8
-rw-r--r--src/home/homectl-recovery-key.c5
-rw-r--r--src/home/homectl.c7
-rw-r--r--src/home/homed-bus.c2
-rw-r--r--src/home/homed-home.c30
-rw-r--r--src/home/homed-varlink.c52
-rw-r--r--src/home/homework-luks.c12
-rw-r--r--src/home/user-record-util.c78
-rw-r--r--src/hostname/hostnamed.c63
-rw-r--r--src/libsystemd-network/lldp-neighbor.c19
-rw-r--r--src/libsystemd-network/sd-dhcp-server-lease.c29
-rw-r--r--src/machine/machined-varlink.c40
-rw-r--r--src/mountfsd/mountwork.c44
-rw-r--r--src/network/networkctl.c20
-rw-r--r--src/network/networkd-json.c477
-rw-r--r--src/network/networkd-manager-varlink.c47
-rw-r--r--src/nsresourced/nsresourcework.c44
-rw-r--r--src/nsresourced/userns-registry.c17
-rw-r--r--src/nss-resolve/nss-resolve.c23
-rw-r--r--src/partition/repart.c12
-rw-r--r--src/pcrlock/pcrlock.c167
-rw-r--r--src/resolve/resolved-dns-cache.c37
-rw-r--r--src/resolve/resolved-dns-rr.c264
-rw-r--r--src/resolve/resolved-dns-scope.c14
-rw-r--r--src/resolve/resolved-dns-server.c36
-rw-r--r--src/resolve/resolved-manager.c97
-rw-r--r--src/resolve/resolved-varlink.c138
-rw-r--r--src/shared/bootspec.c66
-rw-r--r--src/shared/creds-util.c42
-rw-r--r--src/shared/discover-image.c26
-rw-r--r--src/shared/dissect-image.c15
-rw-r--r--src/shared/elf-util.c21
-rw-r--r--src/shared/nsresource.c76
-rw-r--r--src/shared/tpm2-util.c66
-rw-r--r--src/shared/user-record-nss.c47
-rw-r--r--src/shared/userdb.c18
-rw-r--r--src/shared/varlink.c101
-rw-r--r--src/sleep/sleep.c17
-rw-r--r--src/sysext/sysext.c2
-rw-r--r--src/userdb/userdbctl.c7
-rw-r--r--src/userdb/userwork.c28
-rw-r--r--src/varlinkctl/varlinkctl.c4
-rw-r--r--src/vmspawn/vmspawn-register.c22
54 files changed, 1250 insertions, 1267 deletions
diff --git a/src/boot/bootctl-reboot-to-firmware.c b/src/boot/bootctl-reboot-to-firmware.c
index b2e20ad29a..fbde7cbb66 100644
--- a/src/boot/bootctl-reboot-to-firmware.c
+++ b/src/boot/bootctl-reboot-to-firmware.c
@@ -71,5 +71,5 @@ int vl_method_get_reboot_to_firmware(Varlink *link, sd_json_variant *parameters,
if (r < 0)
return r;
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_BOOLEAN("state", r)));
+ return varlink_replybo(link, SD_JSON_BUILD_PAIR_BOOLEAN("state", r));
}
diff --git a/src/boot/bootctl-status.c b/src/boot/bootctl-status.c
index b2bae93089..0b222073b4 100644
--- a/src/boot/bootctl-status.c
+++ b/src/boot/bootctl-status.c
@@ -873,8 +873,7 @@ int vl_method_list_boot_entries(Varlink *link, sd_json_variant *parameters, Varl
_cleanup_(sd_json_variant_unrefp) sd_json_variant *previous = NULL;
for (size_t i = 0; i < config.n_entries; i++) {
if (previous) {
- r = varlink_notifyb(link, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_VARIANT("entry", previous)));
+ r = varlink_notifybo(link, SD_JSON_BUILD_PAIR_VARIANT("entry", previous));
if (r < 0)
return r;
@@ -886,6 +885,5 @@ int vl_method_list_boot_entries(Varlink *link, sd_json_variant *parameters, Varl
return r;
}
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(!!previous, "entry", SD_JSON_BUILD_VARIANT(previous))));
+ return varlink_replybo(link, SD_JSON_BUILD_PAIR_CONDITION(!!previous, "entry", SD_JSON_BUILD_VARIANT(previous)));
}
diff --git a/src/boot/measure.c b/src/boot/measure.c
index 01e1fc7318..9fdc37dfb5 100644
--- a/src/boot/measure.c
+++ b/src/boot/measure.c
@@ -735,12 +735,11 @@ static int verb_calculate(int argc, char *argv[], void *userdata) {
array = sd_json_variant_ref(sd_json_variant_by_key(w, pcr_states[i].bank));
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(!isempty(*phase), "phase", SD_JSON_BUILD_STRING(*phase)),
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_INTEGER(TPM2_PCR_KERNEL_BOOT)),
- SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_HEX(pcr_states[i].value, pcr_states[i].value_size))));
+ SD_JSON_BUILD_PAIR_CONDITION(!isempty(*phase), "phase", SD_JSON_BUILD_STRING(*phase)),
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_INTEGER(TPM2_PCR_KERNEL_BOOT)),
+ SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_HEX(pcr_states[i].value, pcr_states[i].value_size)));
if (r < 0)
return log_error_errno(r, "Failed to append JSON object to array: %m");
@@ -944,11 +943,11 @@ static int verb_sign(int argc, char *argv[], void *userdata) {
return log_error_errno(r, "Failed to build JSON PCR mask array: %m");
_cleanup_(sd_json_variant_unrefp) sd_json_variant *bv = NULL;
- r = sd_json_build(&bv, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcrs", SD_JSON_BUILD_VARIANT(a)), /* PCR mask */
- SD_JSON_BUILD_PAIR("pkfp", SD_JSON_BUILD_HEX(pubkey_fp, pubkey_fp_size)), /* SHA256 fingerprint of public key (DER) used for the signature */
- SD_JSON_BUILD_PAIR("pol", SD_JSON_BUILD_HEX(pcr_policy_digest.buffer, pcr_policy_digest.size)), /* TPM2 policy hash that is signed */
- SD_JSON_BUILD_PAIR("sig", SD_JSON_BUILD_BASE64(sig, ss)))); /* signature data */
+ r = sd_json_buildo(&bv,
+ SD_JSON_BUILD_PAIR("pcrs", SD_JSON_BUILD_VARIANT(a)), /* PCR mask */
+ SD_JSON_BUILD_PAIR("pkfp", SD_JSON_BUILD_HEX(pubkey_fp, pubkey_fp_size)), /* SHA256 fingerprint of public key (DER) used for the signature */
+ SD_JSON_BUILD_PAIR("pol", SD_JSON_BUILD_HEX(pcr_policy_digest.buffer, pcr_policy_digest.size)), /* TPM2 policy hash that is signed */
+ SD_JSON_BUILD_PAIR("sig", SD_JSON_BUILD_BASE64(sig, ss))); /* signature data */
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
@@ -1112,12 +1111,10 @@ static int verb_status(int argc, char *argv[], void *userdata) {
} else {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *bv = NULL, *a = NULL;
- r = sd_json_build(&bv,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_INTEGER(relevant_pcrs[i])),
- SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_HEX(h, l))
- )
- );
+ r = sd_json_buildo(
+ &bv,
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_INTEGER(relevant_pcrs[i])),
+ SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_HEX(h, l)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index c06f7ec6a8..5061afe6c9 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -1214,7 +1214,7 @@ static int message_json(sd_bus_message *m, FILE *f) {
if (ts == 0)
ts = now(CLOCK_REALTIME);
- r = sd_json_build(&w, SD_JSON_BUILD_OBJECT(
+ r = sd_json_buildo(&w,
SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(bus_message_type_to_string(m->header->type))),
SD_JSON_BUILD_PAIR("endian", SD_JSON_BUILD_STRING(e)),
SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(m->header->flags)),
@@ -1231,7 +1231,7 @@ static int message_json(sd_bus_message *m, FILE *f) {
SD_JSON_BUILD_PAIR_CONDITION(m->realtime != 0, "realtime", SD_JSON_BUILD_INTEGER(m->realtime)),
SD_JSON_BUILD_PAIR_CONDITION(m->seqnum != 0, "seqnum", SD_JSON_BUILD_INTEGER(m->seqnum)),
SD_JSON_BUILD_PAIR_CONDITION(!!m->error.name, "error_name", SD_JSON_BUILD_STRING(m->error.name)),
- SD_JSON_BUILD_PAIR("payload", SD_JSON_BUILD_VARIANT(v))));
+ SD_JSON_BUILD_PAIR("payload", SD_JSON_BUILD_VARIANT(v)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
@@ -1735,8 +1735,9 @@ static int json_transform_variant(sd_bus_message *m, const char *contents, sd_js
if (r < 0)
return r;
- r = sd_json_build(ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(contents)),
- SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(value))));
+ r = sd_json_buildo(ret,
+ SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(contents)),
+ SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(value)));
if (r < 0)
return log_oom();
@@ -2008,8 +2009,9 @@ static int json_transform_message(sd_bus_message *m, sd_json_variant **ret) {
if (r < 0)
return r;
- r = sd_json_build(ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(type)),
- SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(v))));
+ r = sd_json_buildo(ret,
+ SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(type)),
+ SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(v)));
if (r < 0)
return log_oom();
diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c
index 42d045a8ad..8457392e7a 100644
--- a/src/core/core-varlink.c
+++ b/src/core/core-varlink.c
@@ -29,8 +29,7 @@ static int build_user_json(const char *user_name, uid_t uid, sd_json_variant **r
assert(uid_is_valid(uid));
assert(ret);
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
+ return sd_json_buildo(ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)),
SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)),
SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(uid)),
@@ -39,7 +38,7 @@ static int build_user_json(const char *user_name, uid_t uid, sd_json_variant **r
SD_JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)),
SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)),
SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")),
- SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic"))))));
+ SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic")))));
}
static bool user_match_lookup_parameters(LookupParameters *p, const char *name, uid_t uid) {
@@ -86,11 +85,11 @@ static int build_managed_oom_json_array_element(Unit *u, const char *property, s
} else
return -EINVAL;
- return sd_json_build(ret_v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("mode", SD_JSON_BUILD_STRING(mode)),
- SD_JSON_BUILD_PAIR("path", SD_JSON_BUILD_STRING(crt->cgroup_path)),
- SD_JSON_BUILD_PAIR("property", SD_JSON_BUILD_STRING(property)),
- SD_JSON_BUILD_PAIR_CONDITION(use_limit, "limit", SD_JSON_BUILD_UNSIGNED(c->moom_mem_pressure_limit))));
+ return sd_json_buildo(ret_v,
+ SD_JSON_BUILD_PAIR("mode", SD_JSON_BUILD_STRING(mode)),
+ SD_JSON_BUILD_PAIR("path", SD_JSON_BUILD_STRING(crt->cgroup_path)),
+ SD_JSON_BUILD_PAIR("property", SD_JSON_BUILD_STRING(property)),
+ SD_JSON_BUILD_PAIR_CONDITION(use_limit, "limit", SD_JSON_BUILD_UNSIGNED(c->moom_mem_pressure_limit)));
}
int manager_varlink_send_managed_oom_update(Unit *u) {
@@ -141,7 +140,7 @@ int manager_varlink_send_managed_oom_update(Unit *u) {
return r;
}
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("cgroups", SD_JSON_BUILD_VARIANT(arr))));
+ r = sd_json_buildo(&v, SD_JSON_BUILD_PAIR("cgroups", SD_JSON_BUILD_VARIANT(arr)));
if (r < 0)
return r;
@@ -203,7 +202,7 @@ static int build_managed_oom_cgroups_json(Manager *m, sd_json_variant **ret) {
}
}
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("cgroups", SD_JSON_BUILD_VARIANT(arr))));
+ r = sd_json_buildo(&v, SD_JSON_BUILD_PAIR("cgroups", SD_JSON_BUILD_VARIANT(arr)));
if (r < 0)
return r;
@@ -362,13 +361,12 @@ static int build_group_json(const char *group_name, gid_t gid, sd_json_variant *
assert(gid_is_valid(gid));
assert(ret);
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
+ return sd_json_buildo(ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(group_name)),
SD_JSON_BUILD_PAIR("description", JSON_BUILD_CONST_STRING("Dynamic Group")),
SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)),
SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")),
- SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic"))))));
+ SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic")))));
}
static bool group_match_lookup_parameters(LookupParameters *p, const char *name, gid_t gid) {
diff --git a/src/creds/creds.c b/src/creds/creds.c
index 0cff4d8890..05f69ad926 100644
--- a/src/creds/creds.c
+++ b/src/creds/creds.c
@@ -1257,7 +1257,7 @@ static int vl_method_encrypt(Varlink *link, sd_json_variant *parameters, Varlink
_cleanup_(sd_json_variant_unrefp) sd_json_variant *reply = NULL;
- r = sd_json_build(&reply, SD_JSON_BUILD_OBJECT(JSON_BUILD_PAIR_IOVEC_BASE64("blob", &output)));
+ r = sd_json_buildo(&reply, JSON_BUILD_PAIR_IOVEC_BASE64("blob", &output));
if (r < 0)
return r;
@@ -1377,7 +1377,7 @@ static int vl_method_decrypt(Varlink *link, sd_json_variant *parameters, Varlink
_cleanup_(sd_json_variant_unrefp) sd_json_variant *reply = NULL;
- r = sd_json_build(&reply, SD_JSON_BUILD_OBJECT(JSON_BUILD_PAIR_IOVEC_BASE64("data", &output)));
+ r = sd_json_buildo(&reply, JSON_BUILD_PAIR_IOVEC_BASE64("data", &output));
if (r < 0)
return r;
diff --git a/src/cryptenroll/cryptenroll-fido2.c b/src/cryptenroll/cryptenroll-fido2.c
index 0baf276878..89986bad95 100644
--- a/src/cryptenroll/cryptenroll-fido2.c
+++ b/src/cryptenroll/cryptenroll-fido2.c
@@ -130,16 +130,15 @@ int enroll_fido2(
if (asprintf(&keyslot_as_string, "%i", keyslot) < 0)
return log_oom();
- r = sd_json_build(&v,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-fido2")),
- SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string))),
- SD_JSON_BUILD_PAIR("fido2-credential", SD_JSON_BUILD_BASE64(cid, cid_size)),
- SD_JSON_BUILD_PAIR("fido2-salt", SD_JSON_BUILD_BASE64(salt, salt_size)),
- SD_JSON_BUILD_PAIR("fido2-rp", JSON_BUILD_CONST_STRING("io.systemd.cryptsetup")),
- SD_JSON_BUILD_PAIR("fido2-clientPin-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN))),
- SD_JSON_BUILD_PAIR("fido2-up-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))),
- SD_JSON_BUILD_PAIR("fido2-uv-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV)))));
+ r = sd_json_buildo(&v,
+ SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-fido2")),
+ SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string))),
+ SD_JSON_BUILD_PAIR("fido2-credential", SD_JSON_BUILD_BASE64(cid, cid_size)),
+ SD_JSON_BUILD_PAIR("fido2-salt", SD_JSON_BUILD_BASE64(salt, salt_size)),
+ SD_JSON_BUILD_PAIR("fido2-rp", JSON_BUILD_CONST_STRING("io.systemd.cryptsetup")),
+ SD_JSON_BUILD_PAIR("fido2-clientPin-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN))),
+ SD_JSON_BUILD_PAIR("fido2-up-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))),
+ SD_JSON_BUILD_PAIR("fido2-uv-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV))));
if (r < 0)
return log_error_errno(r, "Failed to prepare FIDO2 JSON token object: %m");
diff --git a/src/cryptenroll/cryptenroll-pkcs11.c b/src/cryptenroll/cryptenroll-pkcs11.c
index f7cf700084..7c9dfb99c8 100644
--- a/src/cryptenroll/cryptenroll-pkcs11.c
+++ b/src/cryptenroll/cryptenroll-pkcs11.c
@@ -100,12 +100,11 @@ int enroll_pkcs11(
if (r < 0)
return r;
- r = sd_json_build(&v,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-pkcs11")),
- SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string))),
- SD_JSON_BUILD_PAIR("pkcs11-uri", SD_JSON_BUILD_STRING(private_uri ?: uri)),
- SD_JSON_BUILD_PAIR("pkcs11-key", SD_JSON_BUILD_BASE64(saved_key, saved_key_size))));
+ r = sd_json_buildo(&v,
+ SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-pkcs11")),
+ SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string))),
+ SD_JSON_BUILD_PAIR("pkcs11-uri", SD_JSON_BUILD_STRING(private_uri ?: uri)),
+ SD_JSON_BUILD_PAIR("pkcs11-key", SD_JSON_BUILD_BASE64(saved_key, saved_key_size)));
if (r < 0)
return log_error_errno(r, "Failed to prepare PKCS#11 JSON token object: %m");
diff --git a/src/cryptenroll/cryptenroll-recovery.c b/src/cryptenroll/cryptenroll-recovery.c
index 6b42a54c8a..c4bf1fab95 100644
--- a/src/cryptenroll/cryptenroll-recovery.c
+++ b/src/cryptenroll/cryptenroll-recovery.c
@@ -74,10 +74,9 @@ int enroll_recovery(
goto rollback;
}
- r = sd_json_build(&v,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-recovery")),
- SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string)))));
+ r = sd_json_buildo(&v,
+ SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-recovery")),
+ SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string))));
if (r < 0) {
log_error_errno(r, "Failed to prepare recovery key JSON token object: %m");
goto rollback;
diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c
index 7e28b39ea2..1ea2f248d8 100644
--- a/src/dissect/dissect.c
+++ b/src/dissect/dissect.c
@@ -980,29 +980,30 @@ static int action_dissect(
Architecture a = dissected_image_architecture(m);
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(bn)),
- SD_JSON_BUILD_PAIR_CONDITION(size != UINT64_MAX, "size", SD_JSON_BUILD_INTEGER(size)),
- SD_JSON_BUILD_PAIR("sectorSize", SD_JSON_BUILD_INTEGER(m->sector_size)),
- SD_JSON_BUILD_PAIR_CONDITION(a >= 0, "architecture", SD_JSON_BUILD_STRING(architecture_to_string(a))),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(m->image_uuid), "imageUuid", SD_JSON_BUILD_UUID(m->image_uuid)),
- SD_JSON_BUILD_PAIR_CONDITION(!!m->hostname, "hostname", SD_JSON_BUILD_STRING(m->hostname)),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(m->machine_id), "machineId", SD_JSON_BUILD_ID128(m->machine_id)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->machine_info), "machineInfo", JSON_BUILD_STRV_ENV_PAIR(m->machine_info)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->os_release), "osRelease", JSON_BUILD_STRV_ENV_PAIR(m->os_release)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->initrd_release), "initrdRelease", JSON_BUILD_STRV_ENV_PAIR(m->initrd_release)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->sysext_release), "sysextRelease", JSON_BUILD_STRV_ENV_PAIR(m->sysext_release)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->confext_release), "confextRelease", JSON_BUILD_STRV_ENV_PAIR(m->confext_release)),
- SD_JSON_BUILD_PAIR("useBootableUefi", SD_JSON_BUILD_BOOLEAN(dissected_image_is_bootable_uefi(m))),
- SD_JSON_BUILD_PAIR("useBootableContainer", SD_JSON_BUILD_BOOLEAN(dissected_image_is_bootable_os(m))),
- SD_JSON_BUILD_PAIR("useInitrd", SD_JSON_BUILD_BOOLEAN(dissected_image_is_initrd(m))),
- SD_JSON_BUILD_PAIR("usePortableService", SD_JSON_BUILD_BOOLEAN(dissected_image_is_portable(m))),
- SD_JSON_BUILD_PAIR("useSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "system"))),
- SD_JSON_BUILD_PAIR("useInitRDSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "initrd"))),
- SD_JSON_BUILD_PAIR("usePortableSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "portable"))),
- SD_JSON_BUILD_PAIR("useConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "system"))),
- SD_JSON_BUILD_PAIR("useInitRDConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "initrd"))),
- SD_JSON_BUILD_PAIR("usePortableConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "portable")))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(bn)),
+ SD_JSON_BUILD_PAIR_CONDITION(size != UINT64_MAX, "size", SD_JSON_BUILD_INTEGER(size)),
+ SD_JSON_BUILD_PAIR("sectorSize", SD_JSON_BUILD_INTEGER(m->sector_size)),
+ SD_JSON_BUILD_PAIR_CONDITION(a >= 0, "architecture", SD_JSON_BUILD_STRING(architecture_to_string(a))),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(m->image_uuid), "imageUuid", SD_JSON_BUILD_UUID(m->image_uuid)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!m->hostname, "hostname", SD_JSON_BUILD_STRING(m->hostname)),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(m->machine_id), "machineId", SD_JSON_BUILD_ID128(m->machine_id)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->machine_info), "machineInfo", JSON_BUILD_STRV_ENV_PAIR(m->machine_info)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->os_release), "osRelease", JSON_BUILD_STRV_ENV_PAIR(m->os_release)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->initrd_release), "initrdRelease", JSON_BUILD_STRV_ENV_PAIR(m->initrd_release)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->sysext_release), "sysextRelease", JSON_BUILD_STRV_ENV_PAIR(m->sysext_release)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->confext_release), "confextRelease", JSON_BUILD_STRV_ENV_PAIR(m->confext_release)),
+ SD_JSON_BUILD_PAIR("useBootableUefi", SD_JSON_BUILD_BOOLEAN(dissected_image_is_bootable_uefi(m))),
+ SD_JSON_BUILD_PAIR("useBootableContainer", SD_JSON_BUILD_BOOLEAN(dissected_image_is_bootable_os(m))),
+ SD_JSON_BUILD_PAIR("useInitrd", SD_JSON_BUILD_BOOLEAN(dissected_image_is_initrd(m))),
+ SD_JSON_BUILD_PAIR("usePortableService", SD_JSON_BUILD_BOOLEAN(dissected_image_is_portable(m))),
+ SD_JSON_BUILD_PAIR("useSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "system"))),
+ SD_JSON_BUILD_PAIR("useInitRDSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "initrd"))),
+ SD_JSON_BUILD_PAIR("usePortableSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "portable"))),
+ SD_JSON_BUILD_PAIR("useConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "system"))),
+ SD_JSON_BUILD_PAIR("useInitRDConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "initrd"))),
+ SD_JSON_BUILD_PAIR("usePortableConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "portable"))));
if (r < 0)
return log_oom();
}
diff --git a/src/home/homectl-fido2.c b/src/home/homectl-fido2.c
index 332865c8d9..b49419664b 100644
--- a/src/home/homectl-fido2.c
+++ b/src/home/homectl-fido2.c
@@ -87,13 +87,13 @@ static int add_fido2_salt(
if (r < 0)
return log_error_errno(errno_or_else(EINVAL), "Failed to UNIX hash secret key: %m");
- r = sd_json_build(&e, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("credential", SD_JSON_BUILD_BASE64(cid, cid_size)),
- SD_JSON_BUILD_PAIR("salt", SD_JSON_BUILD_BASE64(fido2_salt, fido2_salt_size)),
- SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)),
- SD_JSON_BUILD_PAIR("up", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))),
- SD_JSON_BUILD_PAIR("uv", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV))),
- SD_JSON_BUILD_PAIR("clientPin", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN)))));
+ r = sd_json_buildo(&e,
+ SD_JSON_BUILD_PAIR("credential", SD_JSON_BUILD_BASE64(cid, cid_size)),
+ SD_JSON_BUILD_PAIR("salt", SD_JSON_BUILD_BASE64(fido2_salt, fido2_salt_size)),
+ SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)),
+ SD_JSON_BUILD_PAIR("up", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))),
+ SD_JSON_BUILD_PAIR("uv", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV))),
+ SD_JSON_BUILD_PAIR("clientPin", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN))));
if (r < 0)
return log_error_errno(r, "Failed to build FIDO2 salt JSON key object: %m");
diff --git a/src/home/homectl-pkcs11.c b/src/home/homectl-pkcs11.c
index 1102feded5..9a75da74d3 100644
--- a/src/home/homectl-pkcs11.c
+++ b/src/home/homectl-pkcs11.c
@@ -119,10 +119,10 @@ static int add_pkcs11_encrypted_key(
if (r < 0)
return log_error_errno(errno_or_else(EINVAL), "Failed to UNIX hash secret key: %m");
- r = sd_json_build(&e, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("uri", SD_JSON_BUILD_STRING(uri)),
- SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_BASE64(encrypted_key, encrypted_key_size)),
- SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed))));
+ r = sd_json_buildo(&e,
+ SD_JSON_BUILD_PAIR("uri", SD_JSON_BUILD_STRING(uri)),
+ SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_BASE64(encrypted_key, encrypted_key_size)),
+ SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)));
if (r < 0)
return log_error_errno(r, "Failed to build encrypted JSON key object: %m");
diff --git a/src/home/homectl-recovery-key.c b/src/home/homectl-recovery-key.c
index c27063009d..015d265435 100644
--- a/src/home/homectl-recovery-key.c
+++ b/src/home/homectl-recovery-key.c
@@ -19,9 +19,8 @@ static int add_privileged(sd_json_variant **v, const char *hashed) {
assert(v);
assert(hashed);
- r = sd_json_build(&e, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("modhex64")),
- SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed))));
+ r = sd_json_buildo(&e, SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("modhex64")),
+ SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)));
if (r < 0)
return log_error_errno(r, "Failed to build recover key JSON object: %m");
diff --git a/src/home/homectl.c b/src/home/homectl.c
index f2a04d5a0c..3c5763d9ab 100644
--- a/src/home/homectl.c
+++ b/src/home/homectl.c
@@ -3179,11 +3179,10 @@ static int parse_argv(int argc, char *argv[]) {
if (!t)
return log_oom();
- r = sd_json_variant_set_fieldb(
+ r = sd_json_variant_set_fieldbo(
&arg_identity_extra_rlimits, t,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("cur", SD_JSON_BUILD_VARIANT(jcur)),
- SD_JSON_BUILD_PAIR("max", SD_JSON_BUILD_VARIANT(jmax))));
+ SD_JSON_BUILD_PAIR("cur", SD_JSON_BUILD_VARIANT(jcur)),
+ SD_JSON_BUILD_PAIR("max", SD_JSON_BUILD_VARIANT(jmax)));
if (r < 0)
return log_error_errno(r, "Failed to set %s field: %m", rlimit_to_string(l));
diff --git a/src/home/homed-bus.c b/src/home/homed-bus.c
index 41c4ad65a3..74f1fd702f 100644
--- a/src/home/homed-bus.c
+++ b/src/home/homed-bus.c
@@ -23,7 +23,7 @@ int bus_message_read_secret(sd_bus_message *m, UserRecord **ret, sd_bus_error *e
if (r < 0)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Failed to parse JSON secret record at %u:%u: %m", line, column);
- r = sd_json_build(&full, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("secret", SD_JSON_BUILD_VARIANT(v))));
+ r = sd_json_buildo(&full, SD_JSON_BUILD_PAIR("secret", SD_JSON_BUILD_VARIANT(v)));
if (r < 0)
return r;
diff --git a/src/home/homed-home.c b/src/home/homed-home.c
index 10c24d1dc5..da64d1a8b6 100644
--- a/src/home/homed-home.c
+++ b/src/home/homed-home.c
@@ -2654,22 +2654,20 @@ int home_augment_status(
if (disk_ceiling == UINT64_MAX || disk_ceiling > USER_DISK_SIZE_MAX)
disk_ceiling = USER_DISK_SIZE_MAX;
- r = sd_json_build(&status,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("state", SD_JSON_BUILD_STRING(home_state_to_string(state))),
- SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home")),
- SD_JSON_BUILD_PAIR("useFallback", SD_JSON_BUILD_BOOLEAN(!HOME_STATE_IS_ACTIVE(state))),
- SD_JSON_BUILD_PAIR("fallbackShell", JSON_BUILD_CONST_STRING(BINDIR "/systemd-home-fallback-shell")),
- SD_JSON_BUILD_PAIR("fallbackHomeDirectory", JSON_BUILD_CONST_STRING("/")),
- SD_JSON_BUILD_PAIR_CONDITION(disk_size != UINT64_MAX, "diskSize", SD_JSON_BUILD_UNSIGNED(disk_size)),
- SD_JSON_BUILD_PAIR_CONDITION(disk_usage != UINT64_MAX, "diskUsage", SD_JSON_BUILD_UNSIGNED(disk_usage)),
- SD_JSON_BUILD_PAIR_CONDITION(disk_free != UINT64_MAX, "diskFree", SD_JSON_BUILD_UNSIGNED(disk_free)),
- SD_JSON_BUILD_PAIR_CONDITION(disk_ceiling != UINT64_MAX, "diskCeiling", SD_JSON_BUILD_UNSIGNED(disk_ceiling)),
- SD_JSON_BUILD_PAIR_CONDITION(disk_floor != UINT64_MAX, "diskFloor", SD_JSON_BUILD_UNSIGNED(disk_floor)),
- SD_JSON_BUILD_PAIR_CONDITION(h->signed_locally >= 0, "signedLocally", SD_JSON_BUILD_BOOLEAN(h->signed_locally)),
- SD_JSON_BUILD_PAIR_CONDITION(!!fstype, "fileSystemType", SD_JSON_BUILD_STRING(fstype)),
- SD_JSON_BUILD_PAIR_CONDITION(access_mode != MODE_INVALID, "accessMode", SD_JSON_BUILD_UNSIGNED(access_mode))
- ));
+ r = sd_json_buildo(&status,
+ SD_JSON_BUILD_PAIR("state", SD_JSON_BUILD_STRING(home_state_to_string(state))),
+ SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home")),
+ SD_JSON_BUILD_PAIR("useFallback", SD_JSON_BUILD_BOOLEAN(!HOME_STATE_IS_ACTIVE(state))),
+ SD_JSON_BUILD_PAIR("fallbackShell", JSON_BUILD_CONST_STRING(BINDIR "/systemd-home-fallback-shell")),
+ SD_JSON_BUILD_PAIR("fallbackHomeDirectory", JSON_BUILD_CONST_STRING("/")),
+ SD_JSON_BUILD_PAIR_CONDITION(disk_size != UINT64_MAX, "diskSize", SD_JSON_BUILD_UNSIGNED(disk_size)),
+ SD_JSON_BUILD_PAIR_CONDITION(disk_usage != UINT64_MAX, "diskUsage", SD_JSON_BUILD_UNSIGNED(disk_usage)),
+ SD_JSON_BUILD_PAIR_CONDITION(disk_free != UINT64_MAX, "diskFree", SD_JSON_BUILD_UNSIGNED(disk_free)),
+ SD_JSON_BUILD_PAIR_CONDITION(disk_ceiling != UINT64_MAX, "diskCeiling", SD_JSON_BUILD_UNSIGNED(disk_ceiling)),
+ SD_JSON_BUILD_PAIR_CONDITION(disk_floor != UINT64_MAX, "diskFloor", SD_JSON_BUILD_UNSIGNED(disk_floor)),
+ SD_JSON_BUILD_PAIR_CONDITION(h->signed_locally >= 0, "signedLocally", SD_JSON_BUILD_BOOLEAN(h->signed_locally)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!fstype, "fileSystemType", SD_JSON_BUILD_STRING(fstype)),
+ SD_JSON_BUILD_PAIR_CONDITION(access_mode != MODE_INVALID, "accessMode", SD_JSON_BUILD_UNSIGNED(access_mode)));
if (r < 0)
return r;
diff --git a/src/home/homed-varlink.c b/src/home/homed-varlink.c
index 41f99c429b..bde25353ab 100644
--- a/src/home/homed-varlink.c
+++ b/src/home/homed-varlink.c
@@ -52,9 +52,9 @@ static int build_user_json(Home *h, bool trusted, sd_json_variant **ret) {
if (r < 0)
return r;
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(augmented->json)),
- SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(augmented->incomplete))));
+ return sd_json_buildo(ret,
+ SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(augmented->json)),
+ SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(augmented->incomplete)));
}
static bool home_user_match_lookup_parameters(LookupParameters *p, Home *h) {
@@ -167,9 +167,7 @@ static int build_group_json(Home *h, sd_json_variant **ret) {
assert(!FLAGS_SET(g->mask, USER_RECORD_SECRET));
assert(!FLAGS_SET(g->mask, USER_RECORD_PRIVILEGED));
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(g->json))));
+ return sd_json_buildo(ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(g->json)));
}
static bool home_group_match_lookup_parameters(LookupParameters *p, Home *h) {
@@ -288,14 +286,18 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
if (!strv_contains(h->record->member_of, p.group_name))
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name))));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name)));
}
STRV_FOREACH(i, h->record->member_of) {
if (last) {
- r = varlink_notifyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last))));
+ r = varlink_notifybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last)));
if (r < 0)
return r;
}
@@ -304,8 +306,10 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
}
if (last)
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last))));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last)));
} else if (p.group_name) {
const char *last = NULL;
@@ -316,8 +320,10 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
continue;
if (last) {
- r = varlink_notifyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name))));
+ r = varlink_notifybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name)));
if (r < 0)
return r;
}
@@ -326,8 +332,10 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
}
if (last)
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name))));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name)));
} else {
const char *last_user_name = NULL, *last_group_name = NULL;
@@ -337,8 +345,10 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
if (last_user_name) {
assert(last_group_name);
- r = varlink_notifyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name))));
+ r = varlink_notifybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name)));
if (r < 0)
return r;
@@ -350,8 +360,10 @@ int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters, Varlin
if (last_user_name) {
assert(last_group_name);
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name))));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name)));
}
}
diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c
index 1730674771..ed5ee930c1 100644
--- a/src/home/homework-luks.c
+++ b/src/home/homework-luks.c
@@ -998,12 +998,12 @@ static int format_luks_token_text(
assert((size_t) encrypted_size_out1 + (size_t) encrypted_size_out2 <= encrypted_size);
- r = sd_json_build(&v,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-homed")),
- SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_EMPTY_ARRAY),
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_BASE64(encrypted, encrypted_size_out1 + encrypted_size_out2)),
- SD_JSON_BUILD_PAIR("iv", SD_JSON_BUILD_BASE64(iv, iv_size))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-homed")),
+ SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_EMPTY_ARRAY),
+ SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_BASE64(encrypted, encrypted_size_out1 + encrypted_size_out2)),
+ SD_JSON_BUILD_PAIR("iv", SD_JSON_BUILD_BASE64(iv, iv_size)));
if (r < 0)
return log_error_errno(r, "Failed to prepare LUKS JSON token object: %m");
diff --git a/src/home/user-record-util.c b/src/home/user-record-util.c
index 546db9de9b..907dd43512 100644
--- a/src/home/user-record-util.c
+++ b/src/home/user-record-util.c
@@ -84,18 +84,18 @@ int user_record_synthesize(
if (!hd)
return -ENOMEM;
- r = sd_json_build(&h->json,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)),
- SD_JSON_BUILD_PAIR_CONDITION(!!rr, "realm", SD_JSON_BUILD_STRING(realm)),
- SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("regular")),
- SD_JSON_BUILD_PAIR("binding", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("imagePath", SD_JSON_BUILD_STRING(image_path)),
- SD_JSON_BUILD_PAIR("homeDirectory", SD_JSON_BUILD_STRING(hd)),
- SD_JSON_BUILD_PAIR("storage", SD_JSON_BUILD_STRING(user_storage_to_string(storage))),
- SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)),
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid))))))));
+ r = sd_json_buildo(
+ &h->json,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!rr, "realm", SD_JSON_BUILD_STRING(realm)),
+ SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("regular")),
+ SD_JSON_BUILD_PAIR("binding", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR("imagePath", SD_JSON_BUILD_STRING(image_path)),
+ SD_JSON_BUILD_PAIR("homeDirectory", SD_JSON_BUILD_STRING(hd)),
+ SD_JSON_BUILD_PAIR("storage", SD_JSON_BUILD_STRING(user_storage_to_string(storage))),
+ SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)),
+ SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)))))));
if (r < 0)
return r;
@@ -144,18 +144,18 @@ int group_record_synthesize(GroupRecord *g, UserRecord *h) {
if (!description)
return -ENOMEM;
- r = sd_json_build(&g->json,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(un)),
- SD_JSON_BUILD_PAIR_CONDITION(!!rr, "realm", SD_JSON_BUILD_STRING(rr)),
- SD_JSON_BUILD_PAIR("description", SD_JSON_BUILD_STRING(description)),
- SD_JSON_BUILD_PAIR("binding", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(user_record_gid(h))))))),
- SD_JSON_BUILD_PAIR_CONDITION(h->disposition >= 0, "disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(user_record_disposition(h)))),
- SD_JSON_BUILD_PAIR("status", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home"))))))));
+ r = sd_json_buildo(
+ &g->json,
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(un)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!rr, "realm", SD_JSON_BUILD_STRING(rr)),
+ SD_JSON_BUILD_PAIR("description", SD_JSON_BUILD_STRING(description)),
+ SD_JSON_BUILD_PAIR("binding", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(user_record_gid(h))))))),
+ SD_JSON_BUILD_PAIR_CONDITION(h->disposition >= 0, "disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(user_record_disposition(h)))),
+ SD_JSON_BUILD_PAIR("status", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home")))))));
if (r < 0)
return r;
@@ -338,21 +338,21 @@ int user_record_add_binding(
return -ENOMEM;
}
- r = sd_json_build(&new_binding_entry,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("blobDirectory", SD_JSON_BUILD_STRING(blob)),
- SD_JSON_BUILD_PAIR_CONDITION(!!image_path, "imagePath", SD_JSON_BUILD_STRING(image_path)),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(partition_uuid), "partitionUuid", SD_JSON_BUILD_STRING(SD_ID128_TO_UUID_STRING(partition_uuid))),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(luks_uuid), "luksUuid", SD_JSON_BUILD_STRING(SD_ID128_TO_UUID_STRING(luks_uuid))),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(fs_uuid), "fileSystemUuid", SD_JSON_BUILD_STRING(SD_ID128_TO_UUID_STRING(fs_uuid))),
- SD_JSON_BUILD_PAIR_CONDITION(!!luks_cipher, "luksCipher", SD_JSON_BUILD_STRING(luks_cipher)),
- SD_JSON_BUILD_PAIR_CONDITION(!!luks_cipher_mode, "luksCipherMode", SD_JSON_BUILD_STRING(luks_cipher_mode)),
- SD_JSON_BUILD_PAIR_CONDITION(luks_volume_key_size != UINT64_MAX, "luksVolumeKeySize", SD_JSON_BUILD_UNSIGNED(luks_volume_key_size)),
- SD_JSON_BUILD_PAIR_CONDITION(!!file_system_type, "fileSystemType", SD_JSON_BUILD_STRING(file_system_type)),
- SD_JSON_BUILD_PAIR_CONDITION(!!home_directory, "homeDirectory", SD_JSON_BUILD_STRING(home_directory)),
- SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(uid), "uid", SD_JSON_BUILD_UNSIGNED(uid)),
- SD_JSON_BUILD_PAIR_CONDITION(gid_is_valid(gid), "gid", SD_JSON_BUILD_UNSIGNED(gid)),
- SD_JSON_BUILD_PAIR_CONDITION(storage >= 0, "storage", SD_JSON_BUILD_STRING(user_storage_to_string(storage)))));
+ r = sd_json_buildo(
+ &new_binding_entry,
+ SD_JSON_BUILD_PAIR("blobDirectory", SD_JSON_BUILD_STRING(blob)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!image_path, "imagePath", SD_JSON_BUILD_STRING(image_path)),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(partition_uuid), "partitionUuid", SD_JSON_BUILD_STRING(SD_ID128_TO_UUID_STRING(partition_uuid))),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(luks_uuid), "luksUuid", SD_JSON_BUILD_STRING(SD_ID128_TO_UUID_STRING(luks_uuid))),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(fs_uuid), "fileSystemUuid", SD_JSON_BUILD_STRING(SD_ID128_TO_UUID_STRING(fs_uuid))),
+ SD_JSON_BUILD_PAIR_CONDITION(!!luks_cipher, "luksCipher", SD_JSON_BUILD_STRING(luks_cipher)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!luks_cipher_mode, "luksCipherMode", SD_JSON_BUILD_STRING(luks_cipher_mode)),
+ SD_JSON_BUILD_PAIR_CONDITION(luks_volume_key_size != UINT64_MAX, "luksVolumeKeySize", SD_JSON_BUILD_UNSIGNED(luks_volume_key_size)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!file_system_type, "fileSystemType", SD_JSON_BUILD_STRING(file_system_type)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!home_directory, "homeDirectory", SD_JSON_BUILD_STRING(home_directory)),
+ SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(uid), "uid", SD_JSON_BUILD_UNSIGNED(uid)),
+ SD_JSON_BUILD_PAIR_CONDITION(gid_is_valid(gid), "gid", SD_JSON_BUILD_UNSIGNED(gid)),
+ SD_JSON_BUILD_PAIR_CONDITION(storage >= 0, "storage", SD_JSON_BUILD_STRING(user_storage_to_string(storage))));
if (r < 0)
return r;
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index ea9b3b3843..cda1205e26 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -1415,37 +1415,38 @@ static int build_describe_response(Context *c, bool privileged, sd_json_variant
(void) load_os_release_pairs(/* root= */ NULL, &os_release_pairs);
(void) load_env_file_pairs(/* f=*/ NULL, "/etc/machine-info", &machine_info_pairs);
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("Hostname", SD_JSON_BUILD_STRING(hn)),
- SD_JSON_BUILD_PAIR("StaticHostname", SD_JSON_BUILD_STRING(c->data[PROP_STATIC_HOSTNAME])),
- SD_JSON_BUILD_PAIR("PrettyHostname", SD_JSON_BUILD_STRING(c->data[PROP_PRETTY_HOSTNAME])),
- SD_JSON_BUILD_PAIR("DefaultHostname", SD_JSON_BUILD_STRING(dhn)),
- SD_JSON_BUILD_PAIR("HostnameSource", SD_JSON_BUILD_STRING(hostname_source_to_string(c->hostname_source))),
- SD_JSON_BUILD_PAIR("IconName", SD_JSON_BUILD_STRING(in ?: c->data[PROP_ICON_NAME])),
- SD_JSON_BUILD_PAIR("Chassis", SD_JSON_BUILD_STRING(chassis)),
- SD_JSON_BUILD_PAIR("Deployment", SD_JSON_BUILD_STRING(c->data[PROP_DEPLOYMENT])),
- SD_JSON_BUILD_PAIR("Location", SD_JSON_BUILD_STRING(c->data[PROP_LOCATION])),
- SD_JSON_BUILD_PAIR("KernelName", SD_JSON_BUILD_STRING(u.sysname)),
- SD_JSON_BUILD_PAIR("KernelRelease", SD_JSON_BUILD_STRING(u.release)),
- SD_JSON_BUILD_PAIR("KernelVersion", SD_JSON_BUILD_STRING(u.version)),
- SD_JSON_BUILD_PAIR("OperatingSystemPrettyName", SD_JSON_BUILD_STRING(c->data[PROP_OS_PRETTY_NAME])),
- SD_JSON_BUILD_PAIR("OperatingSystemCPEName", SD_JSON_BUILD_STRING(c->data[PROP_OS_CPE_NAME])),
- SD_JSON_BUILD_PAIR("OperatingSystemHomeURL", SD_JSON_BUILD_STRING(c->data[PROP_OS_HOME_URL])),
- JSON_BUILD_PAIR_FINITE_USEC("OperatingSystemSupportEnd", eol),
- SD_JSON_BUILD_PAIR("OperatingSystemReleaseData", JSON_BUILD_STRV_ENV_PAIR(os_release_pairs)),
- SD_JSON_BUILD_PAIR("MachineInformationData", JSON_BUILD_STRV_ENV_PAIR(machine_info_pairs)),
- SD_JSON_BUILD_PAIR("HardwareVendor", SD_JSON_BUILD_STRING(vendor ?: c->data[PROP_HARDWARE_VENDOR])),
- SD_JSON_BUILD_PAIR("HardwareModel", SD_JSON_BUILD_STRING(model ?: c->data[PROP_HARDWARE_MODEL])),
- SD_JSON_BUILD_PAIR("HardwareSerial", SD_JSON_BUILD_STRING(serial)),
- SD_JSON_BUILD_PAIR("FirmwareVersion", SD_JSON_BUILD_STRING(firmware_version)),
- SD_JSON_BUILD_PAIR("FirmwareVendor", SD_JSON_BUILD_STRING(firmware_vendor)),
- JSON_BUILD_PAIR_FINITE_USEC("FirmwareDate", firmware_date),
- SD_JSON_BUILD_PAIR_ID128("MachineID", machine_id),
- SD_JSON_BUILD_PAIR_ID128("BootID", boot_id),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(product_uuid), "ProductUUID", SD_JSON_BUILD_ID128(product_uuid)),
- SD_JSON_BUILD_PAIR_CONDITION(sd_id128_is_null(product_uuid), "ProductUUID", SD_JSON_BUILD_NULL),
- SD_JSON_BUILD_PAIR_CONDITION(local_cid != VMADDR_CID_ANY, "VSockCID", SD_JSON_BUILD_UNSIGNED(local_cid)),
- SD_JSON_BUILD_PAIR_CONDITION(local_cid == VMADDR_CID_ANY, "VSockCID", SD_JSON_BUILD_NULL)));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("Hostname", SD_JSON_BUILD_STRING(hn)),
+ SD_JSON_BUILD_PAIR("StaticHostname", SD_JSON_BUILD_STRING(c->data[PROP_STATIC_HOSTNAME])),
+ SD_JSON_BUILD_PAIR("PrettyHostname", SD_JSON_BUILD_STRING(c->data[PROP_PRETTY_HOSTNAME])),
+ SD_JSON_BUILD_PAIR("DefaultHostname", SD_JSON_BUILD_STRING(dhn)),
+ SD_JSON_BUILD_PAIR("HostnameSource", SD_JSON_BUILD_STRING(hostname_source_to_string(c->hostname_source))),
+ SD_JSON_BUILD_PAIR("IconName", SD_JSON_BUILD_STRING(in ?: c->data[PROP_ICON_NAME])),
+ SD_JSON_BUILD_PAIR("Chassis", SD_JSON_BUILD_STRING(chassis)),
+ SD_JSON_BUILD_PAIR("Deployment", SD_JSON_BUILD_STRING(c->data[PROP_DEPLOYMENT])),
+ SD_JSON_BUILD_PAIR("Location", SD_JSON_BUILD_STRING(c->data[PROP_LOCATION])),
+ SD_JSON_BUILD_PAIR("KernelName", SD_JSON_BUILD_STRING(u.sysname)),
+ SD_JSON_BUILD_PAIR("KernelRelease", SD_JSON_BUILD_STRING(u.release)),
+ SD_JSON_BUILD_PAIR("KernelVersion", SD_JSON_BUILD_STRING(u.version)),
+ SD_JSON_BUILD_PAIR("OperatingSystemPrettyName", SD_JSON_BUILD_STRING(c->data[PROP_OS_PRETTY_NAME])),
+ SD_JSON_BUILD_PAIR("OperatingSystemCPEName", SD_JSON_BUILD_STRING(c->data[PROP_OS_CPE_NAME])),
+ SD_JSON_BUILD_PAIR("OperatingSystemHomeURL", SD_JSON_BUILD_STRING(c->data[PROP_OS_HOME_URL])),
+ JSON_BUILD_PAIR_FINITE_USEC("OperatingSystemSupportEnd", eol),
+ SD_JSON_BUILD_PAIR("OperatingSystemReleaseData", JSON_BUILD_STRV_ENV_PAIR(os_release_pairs)),
+ SD_JSON_BUILD_PAIR("MachineInformationData", JSON_BUILD_STRV_ENV_PAIR(machine_info_pairs)),
+ SD_JSON_BUILD_PAIR("HardwareVendor", SD_JSON_BUILD_STRING(vendor ?: c->data[PROP_HARDWARE_VENDOR])),
+ SD_JSON_BUILD_PAIR("HardwareModel", SD_JSON_BUILD_STRING(model ?: c->data[PROP_HARDWARE_MODEL])),
+ SD_JSON_BUILD_PAIR("HardwareSerial", SD_JSON_BUILD_STRING(serial)),
+ SD_JSON_BUILD_PAIR("FirmwareVersion", SD_JSON_BUILD_STRING(firmware_version)),
+ SD_JSON_BUILD_PAIR("FirmwareVendor", SD_JSON_BUILD_STRING(firmware_vendor)),
+ JSON_BUILD_PAIR_FINITE_USEC("FirmwareDate", firmware_date),
+ SD_JSON_BUILD_PAIR_ID128("MachineID", machine_id),
+ SD_JSON_BUILD_PAIR_ID128("BootID", boot_id),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(product_uuid), "ProductUUID", SD_JSON_BUILD_ID128(product_uuid)),
+ SD_JSON_BUILD_PAIR_CONDITION(sd_id128_is_null(product_uuid), "ProductUUID", SD_JSON_BUILD_NULL),
+ SD_JSON_BUILD_PAIR_CONDITION(local_cid != VMADDR_CID_ANY, "VSockCID", SD_JSON_BUILD_UNSIGNED(local_cid)),
+ SD_JSON_BUILD_PAIR_CONDITION(local_cid == VMADDR_CID_ANY, "VSockCID", SD_JSON_BUILD_NULL));
if (r < 0)
return log_error_errno(r, "Failed to build JSON data: %m");
diff --git a/src/libsystemd-network/lldp-neighbor.c b/src/libsystemd-network/lldp-neighbor.c
index 77e516c1a8..457b1e5926 100644
--- a/src/libsystemd-network/lldp-neighbor.c
+++ b/src/libsystemd-network/lldp-neighbor.c
@@ -779,13 +779,14 @@ int lldp_neighbor_build_json(sd_lldp_neighbor *n, sd_json_variant **ret) {
valid_cc = sd_lldp_neighbor_get_enabled_capabilities(n, &cc) >= 0;
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_STRING_NON_EMPTY("ChassisID", chassis_id),
- SD_JSON_BUILD_PAIR_BYTE_ARRAY("RawChassisID", n->id.chassis_id, n->id.chassis_id_size),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("PortID", port_id),
- SD_JSON_BUILD_PAIR_BYTE_ARRAY("RawPortID", n->id.port_id, n->id.port_id_size),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("PortDescription", port_description),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("SystemName", system_name),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("SystemDescription", system_description),
- SD_JSON_BUILD_PAIR_CONDITION(valid_cc, "EnabledCapabilities", SD_JSON_BUILD_UNSIGNED(cc))));
+ return sd_json_buildo(
+ ret,
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("ChassisID", chassis_id),
+ SD_JSON_BUILD_PAIR_BYTE_ARRAY("RawChassisID", n->id.chassis_id, n->id.chassis_id_size),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("PortID", port_id),
+ SD_JSON_BUILD_PAIR_BYTE_ARRAY("RawPortID", n->id.port_id, n->id.port_id_size),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("PortDescription", port_description),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("SystemName", system_name),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("SystemDescription", system_description),
+ SD_JSON_BUILD_PAIR_CONDITION(valid_cc, "EnabledCapabilities", SD_JSON_BUILD_UNSIGNED(cc)));
}
diff --git a/src/libsystemd-network/sd-dhcp-server-lease.c b/src/libsystemd-network/sd-dhcp-server-lease.c
index 69a285b44a..32c7764f73 100644
--- a/src/libsystemd-network/sd-dhcp-server-lease.c
+++ b/src/libsystemd-network/sd-dhcp-server-lease.c
@@ -214,11 +214,11 @@ static int dhcp_server_lease_append_json(sd_dhcp_server_lease *lease, sd_json_va
assert(lease);
assert(ret);
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_BYTE_ARRAY("ClientId", lease->client_id.raw, lease->client_id.size),
- JSON_BUILD_PAIR_IN4_ADDR_NON_NULL("Address", &(struct in_addr) { .s_addr = lease->address }),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("Hostname", lease->hostname)));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR_BYTE_ARRAY("ClientId", lease->client_id.raw, lease->client_id.size),
+ JSON_BUILD_PAIR_IN4_ADDR_NON_NULL("Address", &(struct in_addr) { .s_addr = lease->address }),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("Hostname", lease->hostname));
}
int dhcp_server_bound_leases_append_json(sd_dhcp_server *server, sd_json_variant **v) {
@@ -247,10 +247,10 @@ int dhcp_server_bound_leases_append_json(sd_dhcp_server *server, sd_json_variant
usec_t exp_r = map_clock_usec_raw(lease->expiration, now_b, now_r);
- r = sd_json_variant_merge_objectb(&w,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("ExpirationUSec", lease->expiration),
- SD_JSON_BUILD_PAIR_UNSIGNED("ExpirationRealtimeUSec", exp_r)));
+ r = sd_json_variant_merge_objectbo(
+ &w,
+ SD_JSON_BUILD_PAIR_UNSIGNED("ExpirationUSec", lease->expiration),
+ SD_JSON_BUILD_PAIR_UNSIGNED("ExpirationRealtimeUSec", exp_r));
if (r < 0)
return r;
@@ -308,11 +308,12 @@ int dhcp_server_save_leases(sd_dhcp_server *server) {
if (r < 0)
return r;
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_ID128("BootID", boot_id),
- JSON_BUILD_PAIR_IN4_ADDR("Address", &(struct in_addr) { .s_addr = server->address }),
- SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength",
- in4_addr_netmask_to_prefixlen(&(struct in_addr) { .s_addr = server->netmask }))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR_ID128("BootID", boot_id),
+ JSON_BUILD_PAIR_IN4_ADDR("Address", &(struct in_addr) { .s_addr = server->address }),
+ SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength",
+ in4_addr_netmask_to_prefixlen(&(struct in_addr) { .s_addr = server->netmask })));
if (r < 0)
return r;
diff --git a/src/machine/machined-varlink.c b/src/machine/machined-varlink.c
index 3c680b92a4..dc35877c49 100644
--- a/src/machine/machined-varlink.c
+++ b/src/machine/machined-varlink.c
@@ -25,17 +25,18 @@ static int build_user_json(const char *user_name, uid_t uid, const char *real_na
assert(uid_is_valid(uid));
assert(ret);
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)),
- SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)),
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(GID_NOBODY)),
- SD_JSON_BUILD_PAIR_CONDITION(!isempty(real_name), "realName", SD_JSON_BUILD_STRING(real_name)),
- SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")),
- SD_JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)),
- SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)),
- SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Machine")),
- SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("container"))))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)),
+ SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)),
+ SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(GID_NOBODY)),
+ SD_JSON_BUILD_PAIR_CONDITION(!isempty(real_name), "realName", SD_JSON_BUILD_STRING(real_name)),
+ SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")),
+ SD_JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)),
+ SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)),
+ SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Machine")),
+ SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("container")))));
}
static bool user_match_lookup_parameters(LookupParameters *p, const char *name, uid_t uid) {
@@ -196,14 +197,15 @@ static int build_group_json(const char *group_name, gid_t gid, const char *descr
assert(gid_is_valid(gid));
assert(ret);
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(group_name)),
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)),
- SD_JSON_BUILD_PAIR_CONDITION(!isempty(description), "description", SD_JSON_BUILD_STRING(description)),
- SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Machine")),
- SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("container"))))));
- }
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(group_name)),
+ SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)),
+ SD_JSON_BUILD_PAIR_CONDITION(!isempty(description), "description", SD_JSON_BUILD_STRING(description)),
+ SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Machine")),
+ SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("container")))));
+}
static bool group_match_lookup_parameters(LookupParameters *p, const char *name, gid_t gid) {
assert(p);
diff --git a/src/mountfsd/mountwork.c b/src/mountfsd/mountwork.c
index 27d9cc3d2d..cfeb8b60e8 100644
--- a/src/mountfsd/mountwork.c
+++ b/src/mountfsd/mountwork.c
@@ -487,7 +487,6 @@ static int vl_method_mount_image(
return r;
for (PartitionDesignator d = 0; d < _PARTITION_DESIGNATOR_MAX; d++) {
- _cleanup_(sd_json_variant_unrefp) sd_json_variant *pj = NULL;
DissectedPartition *pp = di->partitions + d;
int fd_idx;
@@ -509,35 +508,32 @@ static int vl_method_mount_image(
TAKE_FD(pp->fsmount_fd);
- r = sd_json_build(&pj,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("designator", SD_JSON_BUILD_STRING(partition_designator_to_string(d))),
- SD_JSON_BUILD_PAIR("writable", SD_JSON_BUILD_BOOLEAN(pp->rw)),
- SD_JSON_BUILD_PAIR("growFileSystem", SD_JSON_BUILD_BOOLEAN(pp->growfs)),
- SD_JSON_BUILD_PAIR_CONDITION(pp->partno > 0, "partitionNumber", SD_JSON_BUILD_INTEGER(pp->partno)),
- SD_JSON_BUILD_PAIR_CONDITION(pp->architecture > 0, "architecture", SD_JSON_BUILD_STRING(architecture_to_string(pp->architecture))),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(pp->uuid), "partitionUuid", SD_JSON_BUILD_UUID(pp->uuid)),
- SD_JSON_BUILD_PAIR("fileSystemType", SD_JSON_BUILD_STRING(dissected_partition_fstype(pp))),
- SD_JSON_BUILD_PAIR_CONDITION(!!pp->label, "partitionLabel", SD_JSON_BUILD_STRING(pp->label)),
- SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_INTEGER(pp->size)),
- SD_JSON_BUILD_PAIR("offset", SD_JSON_BUILD_INTEGER(pp->offset)),
- SD_JSON_BUILD_PAIR("mountFileDescriptor", SD_JSON_BUILD_INTEGER(fd_idx))));
- if (r < 0)
- return r;
-
- r = sd_json_variant_append_array(&aj, pj);
+ r = sd_json_variant_append_arraybo(
+ &aj,
+ SD_JSON_BUILD_PAIR("designator", SD_JSON_BUILD_STRING(partition_designator_to_string(d))),
+ SD_JSON_BUILD_PAIR("writable", SD_JSON_BUILD_BOOLEAN(pp->rw)),
+ SD_JSON_BUILD_PAIR("growFileSystem", SD_JSON_BUILD_BOOLEAN(pp->growfs)),
+ SD_JSON_BUILD_PAIR_CONDITION(pp->partno > 0, "partitionNumber", SD_JSON_BUILD_INTEGER(pp->partno)),
+ SD_JSON_BUILD_PAIR_CONDITION(pp->architecture > 0, "architecture", SD_JSON_BUILD_STRING(architecture_to_string(pp->architecture))),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(pp->uuid), "partitionUuid", SD_JSON_BUILD_UUID(pp->uuid)),
+ SD_JSON_BUILD_PAIR("fileSystemType", SD_JSON_BUILD_STRING(dissected_partition_fstype(pp))),
+ SD_JSON_BUILD_PAIR_CONDITION(!!pp->label, "partitionLabel", SD_JSON_BUILD_STRING(pp->label)),
+ SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_INTEGER(pp->size)),
+ SD_JSON_BUILD_PAIR("offset", SD_JSON_BUILD_INTEGER(pp->offset)),
+ SD_JSON_BUILD_PAIR("mountFileDescriptor", SD_JSON_BUILD_INTEGER(fd_idx)));
if (r < 0)
return r;
}
loop_device_relinquish(loop);
- r = varlink_replyb(link, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("partitions", SD_JSON_BUILD_VARIANT(aj)),
- SD_JSON_BUILD_PAIR("imagePolicy", SD_JSON_BUILD_STRING(ps)),
- SD_JSON_BUILD_PAIR("imageSize", SD_JSON_BUILD_INTEGER(di->image_size)),
- SD_JSON_BUILD_PAIR("sectorSize", SD_JSON_BUILD_INTEGER(di->sector_size)),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(di->image_uuid), "imageUuid", SD_JSON_BUILD_UUID(di->image_uuid))));
+ r = varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR("partitions", SD_JSON_BUILD_VARIANT(aj)),
+ SD_JSON_BUILD_PAIR("imagePolicy", SD_JSON_BUILD_STRING(ps)),
+ SD_JSON_BUILD_PAIR("imageSize", SD_JSON_BUILD_INTEGER(di->image_size)),
+ SD_JSON_BUILD_PAIR("sectorSize", SD_JSON_BUILD_INTEGER(di->sector_size)),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(di->image_uuid), "imageUuid", SD_JSON_BUILD_UUID(di->image_uuid)));
if (r < 0)
return r;
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 1384a83216..792be3c124 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -1371,8 +1371,11 @@ static int dump_lldp_neighbors(Varlink *vl, Table *table, int ifindex) {
assert(table);
assert(ifindex > 0);
- r = varlink_callb_and_log(vl, "io.systemd.Network.GetLLDPNeighbors", &reply,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("InterfaceIndex", ifindex)));
+ r = varlink_callbo_and_log(
+ vl,
+ "io.systemd.Network.GetLLDPNeighbors",
+ &reply,
+ SD_JSON_BUILD_PAIR_INTEGER("InterfaceIndex", ifindex));
if (r < 0)
return r;
@@ -2576,10 +2579,10 @@ static int dump_lldp_neighbors_json(sd_json_variant *reply, char * const *patter
return log_error_errno(r, "Failed to append json variant to array: %m");
}
- r = sd_json_build(&v,
- SD_JSON_BUILD_OBJECT(
+ r = sd_json_buildo(
+ &v,
SD_JSON_BUILD_PAIR_CONDITION(sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_EMPTY_ARRAY),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_VARIANT(array))));
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_VARIANT(array)));
if (r < 0)
return log_error_errno(r, "Failed to build json varinat: %m");
@@ -2955,8 +2958,11 @@ static int verb_persistent_storage(int argc, char *argv[], void *userdata) {
TAKE_FD(fd);
}
- return varlink_callb_and_log(vl, "io.systemd.Network.SetPersistentStorage", /* reply = */ NULL,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_BOOLEAN("Ready", ready)));
+ return varlink_callbo_and_log(
+ vl,
+ "io.systemd.Network.SetPersistentStorage",
+ /* reply= */ NULL,
+ SD_JSON_BUILD_PAIR_BOOLEAN("Ready", ready));
}
static int help(void) {
diff --git a/src/network/networkd-json.c b/src/network/networkd-json.c
index 2fddd6796c..299e029922 100644
--- a/src/network/networkd-json.c
+++ b/src/network/networkd-json.c
@@ -47,26 +47,25 @@ static int address_append_json(Address *address, sd_json_variant **array) {
if (r < 0)
return r;
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_INTEGER("Family", address->family),
- JSON_BUILD_PAIR_IN_ADDR("Address", &address->in_addr, address->family),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("Peer", &address->in_addr_peer, address->family),
- JSON_BUILD_PAIR_IN4_ADDR_NON_NULL("Broadcast", &address->broadcast),
- SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength", address->prefixlen),
- SD_JSON_BUILD_PAIR_UNSIGNED("Scope", address->scope),
- SD_JSON_BUILD_PAIR_STRING("ScopeString", scope),
- SD_JSON_BUILD_PAIR_UNSIGNED("Flags", address->flags),
- SD_JSON_BUILD_PAIR_STRING("FlagsString", flags),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("Label", address->label),
- JSON_BUILD_PAIR_FINITE_USEC("PreferredLifetimeUSec", address->lifetime_preferred_usec),
- JSON_BUILD_PAIR_FINITE_USEC("PreferredLifetimeUsec", address->lifetime_preferred_usec), /* for backward compat */
- JSON_BUILD_PAIR_FINITE_USEC("ValidLifetimeUSec", address->lifetime_valid_usec),
- JSON_BUILD_PAIR_FINITE_USEC("ValidLifetimeUsec", address->lifetime_valid_usec), /* for backward compat */
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(address->source)),
- SD_JSON_BUILD_PAIR_STRING("ConfigState", state),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", &address->provider, address->family)));
+ SD_JSON_BUILD_PAIR_INTEGER("Family", address->family),
+ JSON_BUILD_PAIR_IN_ADDR("Address", &address->in_addr, address->family),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("Peer", &address->in_addr_peer, address->family),
+ JSON_BUILD_PAIR_IN4_ADDR_NON_NULL("Broadcast", &address->broadcast),
+ SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength", address->prefixlen),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Scope", address->scope),
+ SD_JSON_BUILD_PAIR_STRING("ScopeString", scope),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Flags", address->flags),
+ SD_JSON_BUILD_PAIR_STRING("FlagsString", flags),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("Label", address->label),
+ JSON_BUILD_PAIR_FINITE_USEC("PreferredLifetimeUSec", address->lifetime_preferred_usec),
+ JSON_BUILD_PAIR_FINITE_USEC("PreferredLifetimeUsec", address->lifetime_preferred_usec), /* for backward compat */
+ JSON_BUILD_PAIR_FINITE_USEC("ValidLifetimeUSec", address->lifetime_valid_usec),
+ JSON_BUILD_PAIR_FINITE_USEC("ValidLifetimeUsec", address->lifetime_valid_usec), /* for backward compat */
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(address->source)),
+ SD_JSON_BUILD_PAIR_STRING("ConfigState", state),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", &address->provider, address->family));
}
static int addresses_append_json(Set *addresses, sd_json_variant **v) {
@@ -96,14 +95,13 @@ static int neighbor_append_json(Neighbor *n, sd_json_variant **array) {
if (r < 0)
return r;
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_INTEGER("Family", n->family),
- JSON_BUILD_PAIR_IN_ADDR("Destination", &n->in_addr, n->family),
- JSON_BUILD_PAIR_HW_ADDR("LinkLayerAddress", &n->ll_addr),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(n->source)),
- SD_JSON_BUILD_PAIR_STRING("ConfigState", state)));
+ SD_JSON_BUILD_PAIR_INTEGER("Family", n->family),
+ JSON_BUILD_PAIR_IN_ADDR("Destination", &n->in_addr, n->family),
+ JSON_BUILD_PAIR_HW_ADDR("LinkLayerAddress", &n->ll_addr),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(n->source)),
+ SD_JSON_BUILD_PAIR_STRING("ConfigState", state));
}
static int neighbors_append_json(Set *neighbors, sd_json_variant **v) {
@@ -131,11 +129,10 @@ static int nexthop_group_build_json(NextHop *nexthop, sd_json_variant **ret) {
assert(ret);
HASHMAP_FOREACH(g, nexthop->group) {
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("ID", g->id),
- SD_JSON_BUILD_PAIR_UNSIGNED("Weight", g->weight+1)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("ID", g->id),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Weight", g->weight+1));
if (r < 0)
return r;
}
@@ -168,19 +165,18 @@ static int nexthop_append_json(NextHop *n, sd_json_variant **array) {
if (r < 0)
return r;
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("ID", n->id),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("Gateway", &n->gw, n->family),
- SD_JSON_BUILD_PAIR_UNSIGNED("Flags", n->flags),
- SD_JSON_BUILD_PAIR_STRING("FlagsString", strempty(flags)),
- SD_JSON_BUILD_PAIR_UNSIGNED("Protocol", n->protocol),
- SD_JSON_BUILD_PAIR_STRING("ProtocolString", protocol),
- SD_JSON_BUILD_PAIR_BOOLEAN("Blackhole", n->blackhole),
- JSON_BUILD_PAIR_VARIANT_NON_NULL("Group", group),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(n->source)),
- SD_JSON_BUILD_PAIR_STRING("ConfigState", state)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("ID", n->id),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("Gateway", &n->gw, n->family),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Flags", n->flags),
+ SD_JSON_BUILD_PAIR_STRING("FlagsString", strempty(flags)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Protocol", n->protocol),
+ SD_JSON_BUILD_PAIR_STRING("ProtocolString", protocol),
+ SD_JSON_BUILD_PAIR_BOOLEAN("Blackhole", n->blackhole),
+ JSON_BUILD_PAIR_VARIANT_NON_NULL("Group", group),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(n->source)),
+ SD_JSON_BUILD_PAIR_STRING("ConfigState", state));
}
static int nexthops_append_json(Manager *manager, int ifindex, sd_json_variant **v) {
@@ -230,34 +226,33 @@ static int route_append_json(Route *route, sd_json_variant **array) {
if (r < 0)
return r;
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_INTEGER("Family", route->family),
- JSON_BUILD_PAIR_IN_ADDR("Destination", &route->dst, route->family),
- SD_JSON_BUILD_PAIR_UNSIGNED("DestinationPrefixLength", route->dst_prefixlen),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("Gateway", &route->nexthop.gw, route->nexthop.family),
- SD_JSON_BUILD_PAIR_CONDITION(route->src_prefixlen > 0,
- "Source", JSON_BUILD_IN_ADDR(&route->src, route->family)),
- JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("SourcePrefixLength", route->src_prefixlen),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("PreferredSource", &route->prefsrc, route->family),
- SD_JSON_BUILD_PAIR_UNSIGNED("Scope", route->scope),
- SD_JSON_BUILD_PAIR_STRING("ScopeString", scope),
- SD_JSON_BUILD_PAIR_UNSIGNED("Protocol", route->protocol),
- SD_JSON_BUILD_PAIR_STRING("ProtocolString", protocol),
- SD_JSON_BUILD_PAIR_UNSIGNED("Type", route->type),
- SD_JSON_BUILD_PAIR_STRING("TypeString", route_type_to_string(route->type)),
- SD_JSON_BUILD_PAIR_UNSIGNED("Priority", route->priority),
- SD_JSON_BUILD_PAIR_UNSIGNED("Table", route->table),
- SD_JSON_BUILD_PAIR_STRING("TableString", table),
- JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("MTU", route_metric_get(&route->metric, RTAX_MTU)),
- SD_JSON_BUILD_PAIR_UNSIGNED("Preference", route->pref),
- SD_JSON_BUILD_PAIR_UNSIGNED("Flags", route->flags),
- SD_JSON_BUILD_PAIR_STRING("FlagsString", strempty(flags)),
- JSON_BUILD_PAIR_FINITE_USEC("LifetimeUSec", route->lifetime_usec),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(route->source)),
- SD_JSON_BUILD_PAIR_STRING("ConfigState", state),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", &route->provider, route->family)));
+ SD_JSON_BUILD_PAIR_INTEGER("Family", route->family),
+ JSON_BUILD_PAIR_IN_ADDR("Destination", &route->dst, route->family),
+ SD_JSON_BUILD_PAIR_UNSIGNED("DestinationPrefixLength", route->dst_prefixlen),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("Gateway", &route->nexthop.gw, route->nexthop.family),
+ SD_JSON_BUILD_PAIR_CONDITION(route->src_prefixlen > 0,
+ "Source", JSON_BUILD_IN_ADDR(&route->src, route->family)),
+ JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("SourcePrefixLength", route->src_prefixlen),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("PreferredSource", &route->prefsrc, route->family),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Scope", route->scope),
+ SD_JSON_BUILD_PAIR_STRING("ScopeString", scope),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Protocol", route->protocol),
+ SD_JSON_BUILD_PAIR_STRING("ProtocolString", protocol),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Type", route->type),
+ SD_JSON_BUILD_PAIR_STRING("TypeString", route_type_to_string(route->type)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Priority", route->priority),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Table", route->table),
+ SD_JSON_BUILD_PAIR_STRING("TableString", table),
+ JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("MTU", route_metric_get(&route->metric, RTAX_MTU)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Preference", route->pref),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Flags", route->flags),
+ SD_JSON_BUILD_PAIR_STRING("FlagsString", strempty(flags)),
+ JSON_BUILD_PAIR_FINITE_USEC("LifetimeUSec", route->lifetime_usec),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(route->source)),
+ SD_JSON_BUILD_PAIR_STRING("ConfigState", state),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", &route->provider, route->family));
}
static int routes_append_json(Manager *manager, int ifindex, sd_json_variant **v) {
@@ -300,43 +295,42 @@ static int routing_policy_rule_append_json(RoutingPolicyRule *rule, sd_json_vari
if (r < 0)
return r;
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_INTEGER("Family", rule->family),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("FromPrefix", &rule->from, rule->family),
- SD_JSON_BUILD_PAIR_CONDITION(in_addr_is_set(rule->family, &rule->from),
- "FromPrefixLength", SD_JSON_BUILD_UNSIGNED(rule->from_prefixlen)),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ToPrefix", &rule->to, rule->family),
- SD_JSON_BUILD_PAIR_CONDITION(in_addr_is_set(rule->family, &rule->to),
- "ToPrefixLength", SD_JSON_BUILD_UNSIGNED(rule->to_prefixlen)),
- SD_JSON_BUILD_PAIR_UNSIGNED("Protocol", rule->protocol),
- SD_JSON_BUILD_PAIR_STRING("ProtocolString", protocol),
- SD_JSON_BUILD_PAIR_UNSIGNED("TOS", rule->tos),
- SD_JSON_BUILD_PAIR_UNSIGNED("Type", rule->type),
- SD_JSON_BUILD_PAIR_STRING("TypeString", fr_act_type_full_to_string(rule->type)),
- SD_JSON_BUILD_PAIR_UNSIGNED("IPProtocol", rule->ipproto),
- SD_JSON_BUILD_PAIR_STRING("IPProtocolString", ip_protocol_to_name(rule->ipproto)),
- SD_JSON_BUILD_PAIR_UNSIGNED("Priority", rule->priority),
- SD_JSON_BUILD_PAIR_UNSIGNED("FirewallMark", rule->fwmark),
- SD_JSON_BUILD_PAIR_UNSIGNED("FirewallMask", rule->fwmask),
- JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("Table", rule->table),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("TableString", table),
- SD_JSON_BUILD_PAIR_BOOLEAN("Invert", rule->invert_rule),
- SD_JSON_BUILD_PAIR_CONDITION(rule->suppress_prefixlen >= 0,
- "SuppressPrefixLength", SD_JSON_BUILD_UNSIGNED(rule->suppress_prefixlen)),
- SD_JSON_BUILD_PAIR_CONDITION(rule->suppress_ifgroup >= 0,
- "SuppressInterfaceGroup", SD_JSON_BUILD_UNSIGNED(rule->suppress_ifgroup)),
- SD_JSON_BUILD_PAIR_CONDITION(rule->sport.start != 0 || rule->sport.end != 0, "SourcePort",
- SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_UNSIGNED(rule->sport.start), SD_JSON_BUILD_UNSIGNED(rule->sport.end))),
- SD_JSON_BUILD_PAIR_CONDITION(rule->dport.start != 0 || rule->dport.end != 0, "DestinationPort",
- SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_UNSIGNED(rule->dport.start), SD_JSON_BUILD_UNSIGNED(rule->dport.end))),
- SD_JSON_BUILD_PAIR_CONDITION(rule->uid_range.start != UID_INVALID && rule->uid_range.end != UID_INVALID, "User",
- SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_UNSIGNED(rule->uid_range.start), SD_JSON_BUILD_UNSIGNED(rule->uid_range.end))),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("IncomingInterface", rule->iif),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("OutgoingInterface", rule->oif),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(rule->source)),
- SD_JSON_BUILD_PAIR_STRING("ConfigState", state)));
+ SD_JSON_BUILD_PAIR_INTEGER("Family", rule->family),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("FromPrefix", &rule->from, rule->family),
+ SD_JSON_BUILD_PAIR_CONDITION(in_addr_is_set(rule->family, &rule->from),
+ "FromPrefixLength", SD_JSON_BUILD_UNSIGNED(rule->from_prefixlen)),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ToPrefix", &rule->to, rule->family),
+ SD_JSON_BUILD_PAIR_CONDITION(in_addr_is_set(rule->family, &rule->to),
+ "ToPrefixLength", SD_JSON_BUILD_UNSIGNED(rule->to_prefixlen)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Protocol", rule->protocol),
+ SD_JSON_BUILD_PAIR_STRING("ProtocolString", protocol),
+ SD_JSON_BUILD_PAIR_UNSIGNED("TOS", rule->tos),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Type", rule->type),
+ SD_JSON_BUILD_PAIR_STRING("TypeString", fr_act_type_full_to_string(rule->type)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("IPProtocol", rule->ipproto),
+ SD_JSON_BUILD_PAIR_STRING("IPProtocolString", ip_protocol_to_name(rule->ipproto)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Priority", rule->priority),
+ SD_JSON_BUILD_PAIR_UNSIGNED("FirewallMark", rule->fwmark),
+ SD_JSON_BUILD_PAIR_UNSIGNED("FirewallMask", rule->fwmask),
+ JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("Table", rule->table),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("TableString", table),
+ SD_JSON_BUILD_PAIR_BOOLEAN("Invert", rule->invert_rule),
+ SD_JSON_BUILD_PAIR_CONDITION(rule->suppress_prefixlen >= 0,
+ "SuppressPrefixLength", SD_JSON_BUILD_UNSIGNED(rule->suppress_prefixlen)),
+ SD_JSON_BUILD_PAIR_CONDITION(rule->suppress_ifgroup >= 0,
+ "SuppressInterfaceGroup", SD_JSON_BUILD_UNSIGNED(rule->suppress_ifgroup)),
+ SD_JSON_BUILD_PAIR_CONDITION(rule->sport.start != 0 || rule->sport.end != 0, "SourcePort",
+ SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_UNSIGNED(rule->sport.start), SD_JSON_BUILD_UNSIGNED(rule->sport.end))),
+ SD_JSON_BUILD_PAIR_CONDITION(rule->dport.start != 0 || rule->dport.end != 0, "DestinationPort",
+ SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_UNSIGNED(rule->dport.start), SD_JSON_BUILD_UNSIGNED(rule->dport.end))),
+ SD_JSON_BUILD_PAIR_CONDITION(rule->uid_range.start != UID_INVALID && rule->uid_range.end != UID_INVALID, "User",
+ SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_UNSIGNED(rule->uid_range.start), SD_JSON_BUILD_UNSIGNED(rule->uid_range.end))),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("IncomingInterface", rule->iif),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("OutgoingInterface", rule->oif),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(rule->source)),
+ SD_JSON_BUILD_PAIR_STRING("ConfigState", state));
}
static int routing_policy_rules_append_json(Set *rules, sd_json_variant **v) {
@@ -361,18 +355,18 @@ static int network_append_json(Network *network, sd_json_variant **v) {
if (!network)
return 0;
- return sd_json_variant_merge_objectb(
- v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("NetworkFile", network->filename),
- SD_JSON_BUILD_PAIR_STRV("NetworkFileDropins", network->dropins),
- SD_JSON_BUILD_PAIR_BOOLEAN("RequiredForOnline", network->required_for_online),
- SD_JSON_BUILD_PAIR("RequiredOperationalStateForOnline",
- SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(link_operstate_to_string(network->required_operstate_for_online.min)),
- SD_JSON_BUILD_STRING(link_operstate_to_string(network->required_operstate_for_online.max)))),
- SD_JSON_BUILD_PAIR_STRING("RequiredFamilyForOnline",
- link_required_address_family_to_string(network->required_family_for_online)),
- SD_JSON_BUILD_PAIR_STRING("ActivationPolicy",
- activation_policy_to_string(network->activation_policy))));
+ return sd_json_variant_merge_objectbo(
+ v,
+ SD_JSON_BUILD_PAIR_STRING("NetworkFile", network->filename),
+ SD_JSON_BUILD_PAIR_STRV("NetworkFileDropins", network->dropins),
+ SD_JSON_BUILD_PAIR_BOOLEAN("RequiredForOnline", network->required_for_online),
+ SD_JSON_BUILD_PAIR("RequiredOperationalStateForOnline",
+ SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(link_operstate_to_string(network->required_operstate_for_online.min)),
+ SD_JSON_BUILD_STRING(link_operstate_to_string(network->required_operstate_for_online.max)))),
+ SD_JSON_BUILD_PAIR_STRING("RequiredFamilyForOnline",
+ link_required_address_family_to_string(network->required_family_for_online)),
+ SD_JSON_BUILD_PAIR_STRING("ActivationPolicy",
+ activation_policy_to_string(network->activation_policy)));
}
static int device_append_json(sd_device *device, sd_json_variant **v) {
@@ -398,14 +392,13 @@ static int device_append_json(sd_device *device, sd_json_variant **v) {
(void) device_get_vendor_string(device, &vendor);
(void) device_get_model_string(device, &model);
- return sd_json_variant_merge_objectb(
+ return sd_json_variant_merge_objectbo(
v,
- SD_JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_STRING_NON_EMPTY("LinkFile", link),
- JSON_BUILD_PAIR_STRV_NON_EMPTY("LinkFileDropins", link_dropins),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("Path", path),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("Vendor", vendor),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("Model", model)));
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("LinkFile", link),
+ JSON_BUILD_PAIR_STRV_NON_EMPTY("LinkFileDropins", link_dropins),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("Path", path),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("Vendor", vendor),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("Model", model));
}
static int dns_append_json_one(Link *link, const struct in_addr_full *a, NetworkConfigSource s, const union in_addr_union *p, sd_json_variant **array) {
@@ -416,16 +409,15 @@ static int dns_append_json_one(Link *link, const struct in_addr_full *a, Network
if (a->ifindex != 0 && a->ifindex != link->ifindex)
return 0;
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_INTEGER("Family", a->family),
- JSON_BUILD_PAIR_IN_ADDR("Address", &a->address, a->family),
- JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("Port", a->port),
- SD_JSON_BUILD_PAIR_CONDITION(a->ifindex != 0, "InterfaceIndex", SD_JSON_BUILD_INTEGER(a->ifindex)),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("ServerName", a->server_name),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", p, a->family)));
+ SD_JSON_BUILD_PAIR_INTEGER("Family", a->family),
+ JSON_BUILD_PAIR_IN_ADDR("Address", &a->address, a->family),
+ JSON_BUILD_PAIR_UNSIGNED_NON_ZERO("Port", a->port),
+ SD_JSON_BUILD_PAIR_CONDITION(a->ifindex != 0, "InterfaceIndex", SD_JSON_BUILD_INTEGER(a->ifindex)),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("ServerName", a->server_name),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", p, a->family));
}
static int dns_append_json(Link *link, sd_json_variant **v) {
@@ -516,13 +508,12 @@ static int server_append_json_one_addr(int family, const union in_addr_union *a,
assert(a);
assert(array);
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_INTEGER("Family", family),
- JSON_BUILD_PAIR_IN_ADDR("Address", a, family),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", p, family)));
+ SD_JSON_BUILD_PAIR_INTEGER("Family", family),
+ JSON_BUILD_PAIR_IN_ADDR("Address", a, family),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", p, family));
}
static int server_append_json_one_fqdn(int family, const char *fqdn, NetworkConfigSource s, const union in_addr_union *p, sd_json_variant **array) {
@@ -530,12 +521,11 @@ static int server_append_json_one_fqdn(int family, const char *fqdn, NetworkConf
assert(fqdn);
assert(array);
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("Server", fqdn),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", p, family)));
+ SD_JSON_BUILD_PAIR_STRING("Server", fqdn),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", p, family));
}
static int server_append_json_one_string(const char *str, NetworkConfigSource s, sd_json_variant **array) {
@@ -663,12 +653,11 @@ static int domain_append_json(int family, const char *domain, NetworkConfigSourc
assert(domain);
assert(array);
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("Domain", domain),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)),
- JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", p, family)));
+ SD_JSON_BUILD_PAIR_STRING("Domain", domain),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)),
+ JSON_BUILD_PAIR_IN_ADDR_NON_NULL("ConfigProvider", p, family));
}
static int domains_append_json(Link *link, bool is_route, sd_json_variant **v) {
@@ -753,11 +742,10 @@ static int nta_append_json(const char *nta, NetworkConfigSource s, sd_json_varia
assert(nta);
assert(array);
- return sd_json_variant_append_arrayb(
+ return sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("DNSSECNegativeTrustAnchor", nta),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s))));
+ SD_JSON_BUILD_PAIR_STRING("DNSSECNegativeTrustAnchor", nta),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(s)));
}
static int ntas_append_json(Link *link, sd_json_variant **v) {
@@ -799,11 +787,10 @@ static int dns_misc_append_json(Link *link, sd_json_variant **v) {
if (resolve_support >= 0) {
source = link->llmnr >= 0 ? NETWORK_CONFIG_SOURCE_RUNTIME : NETWORK_CONFIG_SOURCE_STATIC;
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("LLMNR", resolve_support_to_string(resolve_support)),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(source))));
+ SD_JSON_BUILD_PAIR_STRING("LLMNR", resolve_support_to_string(resolve_support)),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(source)));
if (r < 0)
return r;
}
@@ -812,11 +799,10 @@ static int dns_misc_append_json(Link *link, sd_json_variant **v) {
if (resolve_support >= 0) {
source = link->mdns >= 0 ? NETWORK_CONFIG_SOURCE_RUNTIME : NETWORK_CONFIG_SOURCE_STATIC;
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("MDNS", resolve_support_to_string(resolve_support)),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(source))));
+ SD_JSON_BUILD_PAIR_STRING("MDNS", resolve_support_to_string(resolve_support)),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(source)));
if (r < 0)
return r;
}
@@ -825,11 +811,10 @@ static int dns_misc_append_json(Link *link, sd_json_variant **v) {
if (t >= 0) {
source = link->dns_default_route >= 0 ? NETWORK_CONFIG_SOURCE_RUNTIME : NETWORK_CONFIG_SOURCE_STATIC;
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_BOOLEAN("DNSDefaultRoute", t),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(source))));
+ SD_JSON_BUILD_PAIR_BOOLEAN("DNSDefaultRoute", t),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(source)));
if (r < 0)
return r;
}
@@ -838,11 +823,10 @@ static int dns_misc_append_json(Link *link, sd_json_variant **v) {
if (mode >= 0) {
source = link->dns_over_tls_mode >= 0 ? NETWORK_CONFIG_SOURCE_RUNTIME : NETWORK_CONFIG_SOURCE_STATIC;
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("DNSOverTLS", dns_over_tls_mode_to_string(mode)),
- SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(source))));
+ SD_JSON_BUILD_PAIR_STRING("DNSOverTLS", dns_over_tls_mode_to_string(mode)),
+ SD_JSON_BUILD_PAIR_STRING("ConfigSource", network_config_source_to_string(source)));
if (r < 0)
return r;
}
@@ -861,7 +845,7 @@ static int captive_portal_append_json(Link *link, sd_json_variant **v) {
if (r <= 0)
return r;
- return sd_json_variant_merge_objectb(v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_STRING("CaptivePortal", captive_portal)));
+ return sd_json_variant_merge_objectbo(v, SD_JSON_BUILD_PAIR_STRING("CaptivePortal", captive_portal));
}
static int pref64_append_json(Link *link, sd_json_variant **v) {
@@ -876,12 +860,12 @@ static int pref64_append_json(Link *link, sd_json_variant **v) {
return 0;
SET_FOREACH(i, link->ndisc_pref64) {
- r = sd_json_variant_append_arrayb(&array,
- SD_JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_IN6_ADDR_NON_NULL("Prefix", &i->prefix),
- SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength", i->prefix_len),
- JSON_BUILD_PAIR_FINITE_USEC("LifetimeUSec", i->lifetime_usec),
- JSON_BUILD_PAIR_IN6_ADDR_NON_NULL("ConfigProvider", &i->router)));
+ r = sd_json_variant_append_arraybo(
+ &array,
+ JSON_BUILD_PAIR_IN6_ADDR_NON_NULL("Prefix", &i->prefix),
+ SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength", i->prefix_len),
+ JSON_BUILD_PAIR_FINITE_USEC("LifetimeUSec", i->lifetime_usec),
+ JSON_BUILD_PAIR_IN6_ADDR_NON_NULL("ConfigProvider", &i->router));
if (r < 0)
return r;
}
@@ -903,10 +887,10 @@ static int dhcp_server_append_json(Link *link, sd_json_variant **v) {
if (!link->dhcp_server)
return 0;
- r = sd_json_build(&w,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("PoolOffset", link->dhcp_server->pool_offset),
- SD_JSON_BUILD_PAIR_UNSIGNED("PoolSize", link->dhcp_server->pool_size)));
+ r = sd_json_buildo(
+ &w,
+ SD_JSON_BUILD_PAIR_UNSIGNED("PoolOffset", link->dhcp_server->pool_offset),
+ SD_JSON_BUILD_PAIR_UNSIGNED("PoolSize", link->dhcp_server->pool_size));
if (r < 0)
return r;
@@ -935,11 +919,11 @@ static int dhcp6_client_vendor_options_append_json(Link *link, sd_json_variant *
n_vendor_options = sd_dhcp6_lease_get_vendor_options(link->dhcp6_lease, &options);
FOREACH_ARRAY(option, options, n_vendor_options) {
- r = sd_json_variant_append_arrayb(&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("EnterpriseId", (*option)->enterprise_identifier),
- SD_JSON_BUILD_PAIR_UNSIGNED("SubOptionCode", (*option)->option),
- SD_JSON_BUILD_PAIR_HEX("SubOptionData", (*option)->data, (*option)->length)));
+ r = sd_json_variant_append_arraybo(
+ &array,
+ SD_JSON_BUILD_PAIR_UNSIGNED("EnterpriseId", (*option)->enterprise_identifier),
+ SD_JSON_BUILD_PAIR_UNSIGNED("SubOptionCode", (*option)->option),
+ SD_JSON_BUILD_PAIR_HEX("SubOptionData", (*option)->data, (*option)->length));
if (r < 0)
return r;
}
@@ -970,10 +954,11 @@ static int dhcp6_client_lease_append_json(Link *link, sd_json_variant **v) {
if (r < 0 && r != -ENODATA)
return r;
- r = sd_json_build(&w, SD_JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_FINITE_USEC("Timeout1USec", t1),
- JSON_BUILD_PAIR_FINITE_USEC("Timeout2USec", t2),
- JSON_BUILD_PAIR_FINITE_USEC("LeaseTimestampUSec", ts)));
+ r = sd_json_buildo(
+ &w,
+ JSON_BUILD_PAIR_FINITE_USEC("Timeout1USec", t1),
+ JSON_BUILD_PAIR_FINITE_USEC("Timeout2USec", t2),
+ JSON_BUILD_PAIR_FINITE_USEC("LeaseTimestampUSec", ts));
if (r < 0)
return r;
@@ -1006,11 +991,12 @@ static int dhcp6_client_pd_append_json(Link *link, sd_json_variant **v) {
if (r < 0)
return r;
- r = sd_json_variant_append_arrayb(&array, SD_JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_IN6_ADDR("Prefix", &prefix),
- SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength", prefix_len),
- JSON_BUILD_PAIR_FINITE_USEC("PreferredLifetimeUSec", lifetime_preferred_usec),
- JSON_BUILD_PAIR_FINITE_USEC("ValidLifetimeUSec", lifetime_valid_usec)));
+ r = sd_json_variant_append_arraybo(
+ &array,
+ JSON_BUILD_PAIR_IN6_ADDR("Prefix", &prefix),
+ SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength", prefix_len),
+ JSON_BUILD_PAIR_FINITE_USEC("PreferredLifetimeUSec", lifetime_preferred_usec),
+ JSON_BUILD_PAIR_FINITE_USEC("ValidLifetimeUSec", lifetime_valid_usec));
if (r < 0)
return r;
}
@@ -1038,7 +1024,7 @@ static int dhcp6_client_duid_append_json(Link *link, sd_json_variant **v) {
if (r < 0)
return 0;
- return sd_json_variant_merge_objectb(v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_BYTE_ARRAY("DUID", data, data_size)));
+ return sd_json_variant_merge_objectbo(v, SD_JSON_BUILD_PAIR_BYTE_ARRAY("DUID", data, data_size));
}
static int dhcp6_client_append_json(Link *link, sd_json_variant **v) {
@@ -1093,10 +1079,10 @@ static int dhcp_client_lease_append_json(Link *link, sd_json_variant **v) {
if (r < 0 && r != -ENODATA)
return r;
- r = sd_json_build(&w, SD_JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_FINITE_USEC("LeaseTimestampUSec", lease_timestamp_usec),
- JSON_BUILD_PAIR_FINITE_USEC("Timeout1USec", t1),
- JSON_BUILD_PAIR_FINITE_USEC("Timeout2USec", t2)));
+ r = sd_json_buildo(&w,
+ JSON_BUILD_PAIR_FINITE_USEC("LeaseTimestampUSec", lease_timestamp_usec),
+ JSON_BUILD_PAIR_FINITE_USEC("Timeout1USec", t1),
+ JSON_BUILD_PAIR_FINITE_USEC("Timeout2USec", t2));
if (r < 0)
return r;
@@ -1128,11 +1114,12 @@ static int dhcp_client_pd_append_json(Link *link, sd_json_variant **v) {
return r;
}
- r = sd_json_build(&array, SD_JSON_BUILD_OBJECT(
- JSON_BUILD_PAIR_IN6_ADDR("Prefix", &sixrd_prefix),
- SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength", sixrd_prefixlen),
- SD_JSON_BUILD_PAIR_UNSIGNED("IPv4MaskLength", ipv4masklen),
- JSON_BUILD_PAIR_VARIANT_NON_NULL("BorderRouters", addresses)));
+ r = sd_json_buildo(
+ &array,
+ JSON_BUILD_PAIR_IN6_ADDR("Prefix", &sixrd_prefix),
+ SD_JSON_BUILD_PAIR_UNSIGNED("PrefixLength", sixrd_prefixlen),
+ SD_JSON_BUILD_PAIR_UNSIGNED("IPv4MaskLength", ipv4masklen),
+ JSON_BUILD_PAIR_VARIANT_NON_NULL("BorderRouters", addresses));
if (r < 0)
return r;
@@ -1151,11 +1138,10 @@ static int dhcp_client_private_options_append_json(Link *link, sd_json_variant *
LIST_FOREACH(options, option, link->dhcp_lease->private_options) {
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("Option", option->tag),
- SD_JSON_BUILD_PAIR_HEX("PrivateOptionData", option->data, option->length)));
+ SD_JSON_BUILD_PAIR_UNSIGNED("Option", option->tag),
+ SD_JSON_BUILD_PAIR_HEX("PrivateOptionData", option->data, option->length));
if (r < 0)
return 0;
}
@@ -1182,7 +1168,7 @@ static int dhcp_client_id_append_json(Link *link, sd_json_variant **v) {
if (r < 0)
return 0;
- return sd_json_variant_merge_objectb(v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_BYTE_ARRAY("ClientIdentifier", data, l)));
+ return sd_json_variant_merge_objectbo(v, SD_JSON_BUILD_PAIR_BYTE_ARRAY("ClientIdentifier", data, l));
}
static int dhcp_client_append_json(Link *link, sd_json_variant **v) {
@@ -1230,42 +1216,43 @@ int link_build_json(Link *link, sd_json_variant **ret) {
if (r < 0)
return r;
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- /* basic information */
- SD_JSON_BUILD_PAIR_INTEGER("Index", link->ifindex),
- SD_JSON_BUILD_PAIR_STRING("Name", link->ifname),
- JSON_BUILD_PAIR_STRV_NON_EMPTY("AlternativeNames", link->alternative_names),
- SD_JSON_BUILD_PAIR_CONDITION(link->master_ifindex > 0,
- "MasterInterfaceIndex", SD_JSON_BUILD_INTEGER(link->master_ifindex)),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("Kind", link->kind),
- SD_JSON_BUILD_PAIR_STRING("Type", type),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("Driver", link->driver),
- SD_JSON_BUILD_PAIR_UNSIGNED("Flags", link->flags),
- SD_JSON_BUILD_PAIR_STRING("FlagsString", flags),
- SD_JSON_BUILD_PAIR_UNSIGNED("KernelOperationalState", link->kernel_operstate),
- SD_JSON_BUILD_PAIR_STRING("KernelOperationalStateString", kernel_operstate_to_string(link->kernel_operstate)),
- SD_JSON_BUILD_PAIR_UNSIGNED("MTU", link->mtu),
- SD_JSON_BUILD_PAIR_UNSIGNED("MinimumMTU", link->min_mtu),
- SD_JSON_BUILD_PAIR_UNSIGNED("MaximumMTU", link->max_mtu),
- JSON_BUILD_PAIR_HW_ADDR_NON_NULL("HardwareAddress", &link->hw_addr),
- JSON_BUILD_PAIR_HW_ADDR_NON_NULL("PermanentHardwareAddress", &link->permanent_hw_addr),
- JSON_BUILD_PAIR_HW_ADDR_NON_NULL("BroadcastAddress", &link->bcast_addr),
- JSON_BUILD_PAIR_IN6_ADDR_NON_NULL("IPv6LinkLocalAddress", &link->ipv6ll_address),
- /* wlan information */
- SD_JSON_BUILD_PAIR_CONDITION(link->wlan_iftype > 0, "WirelessLanInterfaceType",
- SD_JSON_BUILD_UNSIGNED(link->wlan_iftype)),
- SD_JSON_BUILD_PAIR_CONDITION(link->wlan_iftype > 0, "WirelessLanInterfaceTypeString",
- SD_JSON_BUILD_STRING(nl80211_iftype_to_string(link->wlan_iftype))),
- JSON_BUILD_PAIR_STRING_NON_EMPTY("SSID", link->ssid),
- JSON_BUILD_PAIR_ETHER_ADDR_NON_NULL("BSSID", &link->bssid),
- /* link state */
- SD_JSON_BUILD_PAIR_STRING("AdministrativeState", link_state_to_string(link->state)),
- SD_JSON_BUILD_PAIR_STRING("OperationalState", link_operstate_to_string(link->operstate)),
- SD_JSON_BUILD_PAIR_STRING("CarrierState", link_carrier_state_to_string(link->carrier_state)),
- SD_JSON_BUILD_PAIR_STRING("AddressState", link_address_state_to_string(link->address_state)),
- SD_JSON_BUILD_PAIR_STRING("IPv4AddressState", link_address_state_to_string(link->ipv4_address_state)),
- SD_JSON_BUILD_PAIR_STRING("IPv6AddressState", link_address_state_to_string(link->ipv6_address_state)),
- SD_JSON_BUILD_PAIR_STRING("OnlineState", link_online_state_to_string(link->online_state))));
+ r = sd_json_buildo(
+ &v,
+ /* basic information */
+ SD_JSON_BUILD_PAIR_INTEGER("Index", link->ifindex),
+ SD_JSON_BUILD_PAIR_STRING("Name", link->ifname),
+ JSON_BUILD_PAIR_STRV_NON_EMPTY("AlternativeNames", link->alternative_names),
+ SD_JSON_BUILD_PAIR_CONDITION(link->master_ifindex > 0,
+ "MasterInterfaceIndex", SD_JSON_BUILD_INTEGER(link->master_ifindex)),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("Kind", link->kind),
+ SD_JSON_BUILD_PAIR_STRING("Type", type),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("Driver", link->driver),
+ SD_JSON_BUILD_PAIR_UNSIGNED("Flags", link->flags),
+ SD_JSON_BUILD_PAIR_STRING("FlagsString", flags),
+ SD_JSON_BUILD_PAIR_UNSIGNED("KernelOperationalState", link->kernel_operstate),
+ SD_JSON_BUILD_PAIR_STRING("KernelOperationalStateString", kernel_operstate_to_string(link->kernel_operstate)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("MTU", link->mtu),
+ SD_JSON_BUILD_PAIR_UNSIGNED("MinimumMTU", link->min_mtu),
+ SD_JSON_BUILD_PAIR_UNSIGNED("MaximumMTU", link->max_mtu),
+ JSON_BUILD_PAIR_HW_ADDR_NON_NULL("HardwareAddress", &link->hw_addr),
+ JSON_BUILD_PAIR_HW_ADDR_NON_NULL("PermanentHardwareAddress", &link->permanent_hw_addr),
+ JSON_BUILD_PAIR_HW_ADDR_NON_NULL("BroadcastAddress", &link->bcast_addr),
+ JSON_BUILD_PAIR_IN6_ADDR_NON_NULL("IPv6LinkLocalAddress", &link->ipv6ll_address),
+ /* wlan information */
+ SD_JSON_BUILD_PAIR_CONDITION(link->wlan_iftype > 0, "WirelessLanInterfaceType",
+ SD_JSON_BUILD_UNSIGNED(link->wlan_iftype)),
+ SD_JSON_BUILD_PAIR_CONDITION(link->wlan_iftype > 0, "WirelessLanInterfaceTypeString",
+ SD_JSON_BUILD_STRING(nl80211_iftype_to_string(link->wlan_iftype))),
+ JSON_BUILD_PAIR_STRING_NON_EMPTY("SSID", link->ssid),
+ JSON_BUILD_PAIR_ETHER_ADDR_NON_NULL("BSSID", &link->bssid),
+ /* link state */
+ SD_JSON_BUILD_PAIR_STRING("AdministrativeState", link_state_to_string(link->state)),
+ SD_JSON_BUILD_PAIR_STRING("OperationalState", link_operstate_to_string(link->operstate)),
+ SD_JSON_BUILD_PAIR_STRING("CarrierState", link_carrier_state_to_string(link->carrier_state)),
+ SD_JSON_BUILD_PAIR_STRING("AddressState", link_address_state_to_string(link->address_state)),
+ SD_JSON_BUILD_PAIR_STRING("IPv4AddressState", link_address_state_to_string(link->ipv4_address_state)),
+ SD_JSON_BUILD_PAIR_STRING("IPv6AddressState", link_address_state_to_string(link->ipv6_address_state)),
+ SD_JSON_BUILD_PAIR_STRING("OnlineState", link_online_state_to_string(link->online_state)));
if (r < 0)
return r;
diff --git a/src/network/networkd-manager-varlink.c b/src/network/networkd-manager-varlink.c
index 8422f124f1..3ecb450172 100644
--- a/src/network/networkd-manager-varlink.c
+++ b/src/network/networkd-manager-varlink.c
@@ -20,14 +20,14 @@ static int vl_method_get_states(Varlink *link, sd_json_variant *parameters, Varl
if (sd_json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
- return varlink_replyb(link,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("AddressState", link_address_state_to_string(m->address_state)),
- SD_JSON_BUILD_PAIR_STRING("IPv4AddressState", link_address_state_to_string(m->ipv4_address_state)),
- SD_JSON_BUILD_PAIR_STRING("IPv6AddressState", link_address_state_to_string(m->ipv6_address_state)),
- SD_JSON_BUILD_PAIR_STRING("CarrierState", link_carrier_state_to_string(m->carrier_state)),
- SD_JSON_BUILD_PAIR_CONDITION(m->online_state >= 0, "OnlineState", SD_JSON_BUILD_STRING(link_online_state_to_string(m->online_state))),
- SD_JSON_BUILD_PAIR_STRING("OperationalState", link_operstate_to_string(m->operational_state))));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR_STRING("AddressState", link_address_state_to_string(m->address_state)),
+ SD_JSON_BUILD_PAIR_STRING("IPv4AddressState", link_address_state_to_string(m->ipv4_address_state)),
+ SD_JSON_BUILD_PAIR_STRING("IPv6AddressState", link_address_state_to_string(m->ipv6_address_state)),
+ SD_JSON_BUILD_PAIR_STRING("CarrierState", link_carrier_state_to_string(m->carrier_state)),
+ SD_JSON_BUILD_PAIR_CONDITION(m->online_state >= 0, "OnlineState", SD_JSON_BUILD_STRING(link_online_state_to_string(m->online_state))),
+ SD_JSON_BUILD_PAIR_STRING("OperationalState", link_operstate_to_string(m->operational_state)));
}
static int vl_method_get_namespace_id(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
@@ -55,11 +55,10 @@ static int vl_method_get_namespace_id(Varlink *link, sd_json_variant *parameters
if (r < 0)
log_full_errno(r == -ENODATA ? LOG_DEBUG : LOG_WARNING, r, "Failed to query network nsid, ignoring: %m");
- return varlink_replyb(link,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("NamespaceId", inode),
- SD_JSON_BUILD_PAIR_CONDITION(nsid == UINT32_MAX, "NamespaceNSID", SD_JSON_BUILD_NULL),
- SD_JSON_BUILD_PAIR_CONDITION(nsid != UINT32_MAX, "NamespaceNSID", SD_JSON_BUILD_UNSIGNED(nsid))));
+ return varlink_replybo(link,
+ SD_JSON_BUILD_PAIR_UNSIGNED("NamespaceId", inode),
+ SD_JSON_BUILD_PAIR_CONDITION(nsid == UINT32_MAX, "NamespaceNSID", SD_JSON_BUILD_NULL),
+ SD_JSON_BUILD_PAIR_CONDITION(nsid != UINT32_MAX, "NamespaceNSID", SD_JSON_BUILD_UNSIGNED(nsid)));
}
typedef struct InterfaceInfo {
@@ -111,13 +110,13 @@ static int link_append_lldp_neighbors(Link *link, sd_json_variant *v, sd_json_va
assert(link);
assert(array);
- return sd_json_variant_append_arrayb(array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_INTEGER("InterfaceIndex", link->ifindex),
- SD_JSON_BUILD_PAIR_STRING("InterfaceName", link->ifname),
- JSON_BUILD_PAIR_STRV_NON_EMPTY("InterfaceAlternativeNames", link->alternative_names),
- SD_JSON_BUILD_PAIR_CONDITION(sd_json_variant_is_blank_array(v), "Neighbors", SD_JSON_BUILD_EMPTY_ARRAY),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_array(v), "Neighbors", SD_JSON_BUILD_VARIANT(v))));
+ return sd_json_variant_append_arraybo(
+ array,
+ SD_JSON_BUILD_PAIR_INTEGER("InterfaceIndex", link->ifindex),
+ SD_JSON_BUILD_PAIR_STRING("InterfaceName", link->ifname),
+ JSON_BUILD_PAIR_STRV_NON_EMPTY("InterfaceAlternativeNames", link->alternative_names),
+ SD_JSON_BUILD_PAIR_CONDITION(sd_json_variant_is_blank_array(v), "Neighbors", SD_JSON_BUILD_EMPTY_ARRAY),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_array(v), "Neighbors", SD_JSON_BUILD_VARIANT(v)));
}
static int vl_method_get_lldp_neighbors(Varlink *vlink, sd_json_variant *parameters, VarlinkMethodFlags flags, Manager *manager) {
@@ -163,10 +162,10 @@ static int vl_method_get_lldp_neighbors(Varlink *vlink, sd_json_variant *paramet
return r;
}
- return varlink_replyb(vlink,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_EMPTY_ARRAY),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_VARIANT(array))));
+ return varlink_replybo(
+ vlink,
+ SD_JSON_BUILD_PAIR_CONDITION(sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_EMPTY_ARRAY),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_array(array), "Neighbors", SD_JSON_BUILD_VARIANT(array)));
}
static int vl_method_set_persistent_storage(Varlink *vlink, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
diff --git a/src/nsresourced/nsresourcework.c b/src/nsresourced/nsresourcework.c
index 0d06881839..1c33aebcce 100644
--- a/src/nsresourced/nsresourcework.c
+++ b/src/nsresourced/nsresourcework.c
@@ -82,16 +82,17 @@ static int build_user_json(UserNamespaceInfo *userns_info, uid_t offset, sd_json
if (r < 0)
return -ENOMEM;
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(name)),
- SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(userns_info->start + offset)),
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(GID_NOBODY)),
- SD_JSON_BUILD_PAIR("realName", SD_JSON_BUILD_STRING(realname)),
- SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")),
- SD_JSON_BUILD_PAIR("shell", SD_JSON_BUILD_STRING(NOLOGIN)),
- SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)),
- SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NamespaceResource")),
- SD_JSON_BUILD_PAIR("disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(disposition)))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(name)),
+ SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(userns_info->start + offset)),
+ SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(GID_NOBODY)),
+ SD_JSON_BUILD_PAIR("realName", SD_JSON_BUILD_STRING(realname)),
+ SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")),
+ SD_JSON_BUILD_PAIR("shell", SD_JSON_BUILD_STRING(NOLOGIN)),
+ SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)),
+ SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NamespaceResource")),
+ SD_JSON_BUILD_PAIR("disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(disposition))));
}
static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
@@ -185,7 +186,7 @@ static int vl_method_get_user_record(Varlink *link, sd_json_variant *parameters,
if (r < 0)
return r;
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v))));
+ return varlink_replybo(link, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)));
not_found:
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
@@ -212,12 +213,13 @@ static int build_group_json(UserNamespaceInfo *userns_info, gid_t offset, sd_jso
if (r < 0)
return -ENOMEM;
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(name)),
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(userns_info->start + offset)),
- SD_JSON_BUILD_PAIR("description", SD_JSON_BUILD_STRING(description)),
- SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NamespaceResource")),
- SD_JSON_BUILD_PAIR("disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(disposition)))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(name)),
+ SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(userns_info->start + offset)),
+ SD_JSON_BUILD_PAIR("description", SD_JSON_BUILD_STRING(description)),
+ SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NamespaceResource")),
+ SD_JSON_BUILD_PAIR("disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(disposition))));
}
static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
@@ -311,7 +313,7 @@ static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters
if (r < 0)
return r;
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v))));
+ return varlink_replybo(link, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)));
not_found:
return varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL);
@@ -1612,8 +1614,10 @@ static int vl_method_add_netif_to_user_namespace(Varlink *link, sd_json_variant
log_debug("Adding veth tunnel %s from host to userns " INO_FMT " ('%s' @ UID " UID_FMT ", interface %s).",
ifname_host, userns_st.st_ino, userns_info->name, userns_info->start, ifname_namespace);
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("hostInterfaceName", SD_JSON_BUILD_STRING(ifname_host)),
- SD_JSON_BUILD_PAIR("namespaceInterfaceName", SD_JSON_BUILD_STRING(ifname_namespace))));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR("hostInterfaceName", SD_JSON_BUILD_STRING(ifname_host)),
+ SD_JSON_BUILD_PAIR("namespaceInterfaceName", SD_JSON_BUILD_STRING(ifname_namespace)));
}
static int process_connection(VarlinkServer *server, int _fd) {
diff --git a/src/nsresourced/userns-registry.c b/src/nsresourced/userns-registry.c
index 13f94aa751..8c62e71708 100644
--- a/src/nsresourced/userns-registry.c
+++ b/src/nsresourced/userns-registry.c
@@ -361,14 +361,15 @@ int userns_registry_store(int dir_fd, UserNamespaceInfo *info) {
}
_cleanup_(sd_json_variant_unrefp) sd_json_variant *def = NULL;
- r = sd_json_build(&def, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("owner", SD_JSON_BUILD_UNSIGNED(info->owner)),
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(info->name)),
- SD_JSON_BUILD_PAIR("userns", SD_JSON_BUILD_UNSIGNED(info->userns_inode)),
- SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(info->start), "start", SD_JSON_BUILD_UNSIGNED(info->start)),
- SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(info->start), "size", SD_JSON_BUILD_UNSIGNED(info->size)),
- SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(info->start), "target", SD_JSON_BUILD_UNSIGNED(info->target)),
- SD_JSON_BUILD_PAIR_CONDITION(!!cgroup_array, "cgroups", SD_JSON_BUILD_VARIANT(cgroup_array))));
+ r = sd_json_buildo(
+ &def,
+ SD_JSON_BUILD_PAIR("owner", SD_JSON_BUILD_UNSIGNED(info->owner)),
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(info->name)),
+ SD_JSON_BUILD_PAIR("userns", SD_JSON_BUILD_UNSIGNED(info->userns_inode)),
+ SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(info->start), "start", SD_JSON_BUILD_UNSIGNED(info->start)),
+ SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(info->start), "size", SD_JSON_BUILD_UNSIGNED(info->size)),
+ SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(info->start), "target", SD_JSON_BUILD_UNSIGNED(info->target)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!cgroup_array, "cgroups", SD_JSON_BUILD_VARIANT(cgroup_array)));
if (r < 0)
return r;
diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c
index 21e278f5a2..537e0f6c17 100644
--- a/src/nss-resolve/nss-resolve.c
+++ b/src/nss-resolve/nss-resolve.c
@@ -251,9 +251,10 @@ enum nss_status _nss_resolve_gethostbyname4_r(
if (r < 0)
goto fail;
- r = sd_json_build(&cparams, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags()))));
+ r = sd_json_buildo(
+ &cparams,
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags())));
if (r < 0)
goto fail;
@@ -418,9 +419,11 @@ enum nss_status _nss_resolve_gethostbyname3_r(
if (r < 0)
goto fail;
- r = sd_json_build(&cparams, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
- SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(af)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags()))));
+ r = sd_json_buildo(
+ &cparams,
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
+ SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(af)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags())));
if (r < 0)
goto fail;
@@ -636,9 +639,11 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
if (r < 0)
goto fail;
- r = sd_json_build(&cparams, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(addr, len)),
- SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(af)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags()))));
+ r = sd_json_buildo(
+ &cparams,
+ SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(addr, len)),
+ SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(af)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags())));
if (r < 0)
goto fail;
diff --git a/src/partition/repart.c b/src/partition/repart.c
index c47115df30..bee48b770c 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -4467,13 +4467,11 @@ static int partition_format_verity_sig(Context *context, Partition *p) {
if (r < 0)
return log_error_errno(r, "Unable to calculate X509 certificate fingerprint: %m");
- r = sd_json_build(&v,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("rootHash", SD_JSON_BUILD_HEX(hp->roothash.iov_base, hp->roothash.iov_len)),
- SD_JSON_BUILD_PAIR("certificateFingerprint", SD_JSON_BUILD_HEX(fp, sizeof(fp))),
- SD_JSON_BUILD_PAIR("signature", JSON_BUILD_IOVEC_BASE64(&sig))
- )
- );
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("rootHash", SD_JSON_BUILD_HEX(hp->roothash.iov_base, hp->roothash.iov_len)),
+ SD_JSON_BUILD_PAIR("certificateFingerprint", SD_JSON_BUILD_HEX(fp, sizeof(fp))),
+ SD_JSON_BUILD_PAIR("signature", JSON_BUILD_IOVEC_BASE64(&sig)));
if (r < 0)
return log_error_errno(r, "Failed to build verity signature JSON object: %m");
diff --git a/src/pcrlock/pcrlock.c b/src/pcrlock/pcrlock.c
index 935d60d3db..585a00fc6e 100644
--- a/src/pcrlock/pcrlock.c
+++ b/src/pcrlock/pcrlock.c
@@ -2427,9 +2427,10 @@ static int verb_show_log(int argc, char *argv[], void *userdata) {
if (want_json) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *object = NULL;
- r = sd_json_build(&object, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_VARIANT("log", log_table),
- SD_JSON_BUILD_PAIR_VARIANT("pcrs", pcr_table)));
+ r = sd_json_buildo(
+ &object,
+ SD_JSON_BUILD_PAIR_VARIANT("log", log_table),
+ SD_JSON_BUILD_PAIR_VARIANT("pcrs", pcr_table));
if (r < 0)
return log_error_errno(r, "Failed to generate combined object: %m");
@@ -2452,10 +2453,10 @@ static int event_log_record_to_cel(EventLogRecord *record, uint64_t *recnum, sd_
assert(ret);
LIST_FOREACH(banks, bank, record->banks) {
- r = sd_json_variant_append_arrayb(
- &ja, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("hashAlg", tpm2_hash_alg_to_string(bank->algorithm)),
- SD_JSON_BUILD_PAIR_HEX("digest", bank->hash.buffer, bank->hash.size)));
+ r = sd_json_variant_append_arraybo(
+ &ja,
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", tpm2_hash_alg_to_string(bank->algorithm)),
+ SD_JSON_BUILD_PAIR_HEX("digest", bank->hash.buffer, bank->hash.size));
if (r < 0)
return log_error_errno(r, "Failed to append CEL digest entry: %m");
}
@@ -2484,9 +2485,10 @@ static int event_log_record_to_cel(EventLogRecord *record, uint64_t *recnum, sd_
} else if (asprintf(&et, "%" PRIu32, record->firmware_event_type) < 0)
return log_oom();
- r = sd_json_build(&fj, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("event_type", et),
- SD_JSON_BUILD_PAIR_HEX("event_data", record->firmware_payload, record->firmware_payload_size)));
+ r = sd_json_buildo(
+ &fj,
+ SD_JSON_BUILD_PAIR_STRING("event_type", et),
+ SD_JSON_BUILD_PAIR_HEX("event_data", record->firmware_payload, record->firmware_payload_size));
if (r < 0)
return log_error_errno(r, "Failed to build firmware event data: %m");
@@ -2497,13 +2499,13 @@ static int event_log_record_to_cel(EventLogRecord *record, uint64_t *recnum, sd_
ct = "systemd";
}
- r = sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("pcr", record->pcr),
- SD_JSON_BUILD_PAIR_UNSIGNED("recnum", ++(*recnum)),
- SD_JSON_BUILD_PAIR_VARIANT("digests", ja),
- SD_JSON_BUILD_PAIR_CONDITION(!!ct, "content_type", SD_JSON_BUILD_STRING(ct)),
- SD_JSON_BUILD_PAIR_CONDITION(!!cd, "content", SD_JSON_BUILD_VARIANT(cd))));
+ r = sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR_UNSIGNED("pcr", record->pcr),
+ SD_JSON_BUILD_PAIR_UNSIGNED("recnum", ++(*recnum)),
+ SD_JSON_BUILD_PAIR_VARIANT("digests", ja),
+ SD_JSON_BUILD_PAIR_CONDITION(!!ct, "content_type", SD_JSON_BUILD_STRING(ct)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!cd, "content", SD_JSON_BUILD_VARIANT(cd)));
if (r < 0)
return log_error_errno(r, "Failed to make CEL record: %m");
@@ -2691,19 +2693,17 @@ static int make_pcrlock_record(
if (EVP_Digest(data, data_size, hash, &hash_usize, md, NULL) != 1)
return log_error_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), "Failed to hash data with algorithm '%s'.", a);
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_usize))));
+ SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_usize)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
}
- r = sd_json_build(ret_record,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(pcr)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests))));
+ r = sd_json_buildo(ret_record,
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(pcr)),
+ SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
if (r < 0)
return log_error_errno(r, "Failed to build record object: %m");
@@ -2775,11 +2775,10 @@ static int make_pcrlock_record_from_stream(
return log_error_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE),
"Failed to finalize hash context for algorithn '%s'.", a);
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_usize))));
+ SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_usize)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
}
@@ -2790,10 +2789,10 @@ static int make_pcrlock_record_from_stream(
if (!FLAGS_SET(pcr_mask, UINT32_C(1) << i))
continue;
- r = sd_json_build(&record,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(i)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests))));
+ r = sd_json_buildo(
+ &record,
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(i)),
+ SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
if (r < 0)
return log_error_errno(r, "Failed to build record object: %m");
@@ -2823,8 +2822,9 @@ static int write_pcrlock(sd_json_variant *array, const char *default_pcrlock_pat
array = a;
}
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("records", SD_JSON_BUILD_VARIANT(array))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("records", SD_JSON_BUILD_VARIANT(array)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
@@ -3146,20 +3146,18 @@ static int verb_lock_secureboot_authority(int argc, char *argv[], void *userdata
log_debug("Locking down authority '%s'.", strna(rec->description));
LIST_FOREACH(banks, bank, rec->banks) {
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(bank->algorithm))),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(bank->hash.buffer, bank->hash.size))));
+ SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(bank->algorithm))),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(bank->hash.buffer, bank->hash.size)));
if (r < 0)
return log_error_errno(r, "Failed to build digests array: %m");
}
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(rec->pcr)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests))));
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(rec->pcr)),
+ SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
if (r < 0)
return log_error_errno(r, "Failed to build record array: %m");
}
@@ -3439,20 +3437,18 @@ static int verb_lock_firmware(int argc, char *argv[], void *userdata) {
}
LIST_FOREACH(banks, bank, rec->banks) {
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&digests,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(bank->algorithm))),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(bank->hash.buffer, bank->hash.size))));
+ SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(bank->algorithm))),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(bank->hash.buffer, bank->hash.size)));
if (r < 0)
return log_error_errno(r, "Failed to build digests array: %m");
}
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
FLAGS_SET(separator_seen_mask, bit) ? &array_late : &array_early,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(rec->pcr)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests))));
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(rec->pcr)),
+ SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
if (r < 0)
return log_error_errno(r, "Failed to build record array: %m");
}
@@ -3660,19 +3656,18 @@ static int verb_lock_pe(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to hash PE binary: %m");
- r = sd_json_variant_append_arrayb(&digests,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_size))));
+ r = sd_json_variant_append_arraybo(
+ &digests,
+ SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_size)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
}
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(i)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests))));
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(i)),
+ SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
}
@@ -3717,11 +3712,10 @@ static int verb_lock_uki(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to hash PE binary: %m");
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&pe_digests,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(peh, hash_sizes[i]))));
+ SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(peh, hash_sizes[i])));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
@@ -3730,11 +3724,10 @@ static int verb_lock_uki(int argc, char *argv[], void *userdata) {
return log_error_errno(r, "Failed to UKI hash PE binary: %m");
}
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(TPM2_PCR_BOOT_LOADER_CODE)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(pe_digests))));
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(TPM2_PCR_BOOT_LOADER_CODE)),
+ SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(pe_digests)));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
@@ -3754,11 +3747,10 @@ static int verb_lock_uki(int argc, char *argv[], void *userdata) {
assert_se(a = tpm2_hash_alg_to_string(tpm2_hash_algorithms[i]));
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&section_digests,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_sizes[i]))));
+ SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_sizes[i])));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
}
@@ -3776,11 +3768,10 @@ static int verb_lock_uki(int argc, char *argv[], void *userdata) {
return log_error_errno(r, "Failed to append JSON record array: %m");
/* And then append a record for the section contents digests as well */
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(TPM2_PCR_KERNEL_BOOT /* =11 */)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(section_digests))));
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(TPM2_PCR_KERNEL_BOOT /* =11 */)),
+ SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(section_digests)));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
}
@@ -4759,16 +4750,16 @@ static int make_policy(bool force, RecoveryPinMode recovery_pin_mode) {
}
_cleanup_(sd_json_variant_unrefp) sd_json_variant *new_configuration_json = NULL;
- r = sd_json_build(&new_configuration_json,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("pcrBank", tpm2_hash_alg_to_string(el->primary_algorithm)),
- SD_JSON_BUILD_PAIR_VARIANT("pcrValues", new_prediction_json),
- SD_JSON_BUILD_PAIR_INTEGER("nvIndex", nv_index),
- JSON_BUILD_PAIR_IOVEC_BASE64("nvHandle", &nv_blob),
- JSON_BUILD_PAIR_IOVEC_BASE64("nvPublic", &nv_public_blob),
- JSON_BUILD_PAIR_IOVEC_BASE64("srkHandle", &srk_blob),
- JSON_BUILD_PAIR_IOVEC_BASE64("pinPublic", &pin_public),
- JSON_BUILD_PAIR_IOVEC_BASE64("pinPrivate", &pin_private)));
+ r = sd_json_buildo(
+ &new_configuration_json,
+ SD_JSON_BUILD_PAIR_STRING("pcrBank", tpm2_hash_alg_to_string(el->primary_algorithm)),
+ SD_JSON_BUILD_PAIR_VARIANT("pcrValues", new_prediction_json),
+ SD_JSON_BUILD_PAIR_INTEGER("nvIndex", nv_index),
+ JSON_BUILD_PAIR_IOVEC_BASE64("nvHandle", &nv_blob),
+ JSON_BUILD_PAIR_IOVEC_BASE64("nvPublic", &nv_public_blob),
+ JSON_BUILD_PAIR_IOVEC_BASE64("srkHandle", &srk_blob),
+ JSON_BUILD_PAIR_IOVEC_BASE64("pinPublic", &pin_public),
+ JSON_BUILD_PAIR_IOVEC_BASE64("pinPrivate", &pin_private));
if (r < 0)
return log_error_errno(r, "Failed to generate JSON: %m");
@@ -5245,8 +5236,7 @@ static int vl_method_read_event_log(Varlink *link, sd_json_variant *parameters,
FOREACH_ARRAY(rr, el->records, el->n_records) {
if (rec_cel) {
- r = varlink_notifyb(link,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_VARIANT("record", rec_cel)));
+ r = varlink_notifybo(link, SD_JSON_BUILD_PAIR_VARIANT("record", rec_cel));
if (r < 0)
return r;
@@ -5258,8 +5248,7 @@ static int vl_method_read_event_log(Varlink *link, sd_json_variant *parameters,
return r;
}
- return varlink_replyb(link,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_CONDITION(!!rec_cel, "record", SD_JSON_BUILD_VARIANT(rec_cel))));
+ return varlink_replybo(link, SD_JSON_BUILD_PAIR_CONDITION(!!rec_cel, "record", SD_JSON_BUILD_VARIANT(rec_cel)));
}
typedef struct MethodMakePolicyParameters {
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
index afda571ed5..f80f9dff8a 100644
--- a/src/resolve/resolved-dns-cache.c
+++ b/src/resolve/resolved-dns-cache.c
@@ -1456,11 +1456,10 @@ int dns_cache_dump_to_json(DnsCache *cache, sd_json_variant **ret) {
if (r < 0)
return r;
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&l,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_VARIANT("rr", rj),
- SD_JSON_BUILD_PAIR_BASE64("raw", j->rr->wire_format, j->rr->wire_format_size)));
+ SD_JSON_BUILD_PAIR_VARIANT("rr", rj),
+ SD_JSON_BUILD_PAIR_BASE64("raw", j->rr->wire_format, j->rr->wire_format_size));
if (r < 0)
return r;
}
@@ -1471,23 +1470,23 @@ int dns_cache_dump_to_json(DnsCache *cache, sd_json_variant **ret) {
return r;
}
- r = sd_json_build(&d,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_VARIANT("key", k),
- SD_JSON_BUILD_PAIR_VARIANT("rrs", l),
- SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until)));
+ r = sd_json_buildo(
+ &d,
+ SD_JSON_BUILD_PAIR_VARIANT("key", k),
+ SD_JSON_BUILD_PAIR_VARIANT("rrs", l),
+ SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until));
} else if (i->type == DNS_CACHE_NODATA) {
- r = sd_json_build(&d,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_VARIANT("key", k),
- SD_JSON_BUILD_PAIR_EMPTY_ARRAY("rrs"),
- SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until)));
+ r = sd_json_buildo(
+ &d,
+ SD_JSON_BUILD_PAIR_VARIANT("key", k),
+ SD_JSON_BUILD_PAIR_EMPTY_ARRAY("rrs"),
+ SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until));
} else
- r = sd_json_build(&d,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_VARIANT("key", k),
- SD_JSON_BUILD_PAIR_STRING("type", dns_cache_item_type_to_string(i)),
- SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until)));
+ r = sd_json_buildo(
+ &d,
+ SD_JSON_BUILD_PAIR_VARIANT("key", k),
+ SD_JSON_BUILD_PAIR_STRING("type", dns_cache_item_type_to_string(i)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("until", i->until));
if (r < 0)
return r;
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index 33ee644efd..e9d667f7d5 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -2135,11 +2135,11 @@ int dns_resource_key_to_json(DnsResourceKey *key, sd_json_variant **ret) {
assert(key);
assert(ret);
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("class", SD_JSON_BUILD_INTEGER(key->class)),
- SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_INTEGER(key->type)),
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(dns_resource_key_name(key)))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("class", SD_JSON_BUILD_INTEGER(key->class)),
+ SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_INTEGER(key->type)),
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(dns_resource_key_name(key))));
}
int dns_resource_key_from_json(sd_json_variant *v, DnsResourceKey **ret) {
@@ -2263,29 +2263,29 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) {
switch (rr->unparsable ? _DNS_TYPE_INVALID : rr->key->type) {
case DNS_TYPE_SRV:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->srv.priority)),
- SD_JSON_BUILD_PAIR("weight", SD_JSON_BUILD_UNSIGNED(rr->srv.weight)),
- SD_JSON_BUILD_PAIR("port", SD_JSON_BUILD_UNSIGNED(rr->srv.port)),
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(rr->srv.name))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->srv.priority)),
+ SD_JSON_BUILD_PAIR("weight", SD_JSON_BUILD_UNSIGNED(rr->srv.weight)),
+ SD_JSON_BUILD_PAIR("port", SD_JSON_BUILD_UNSIGNED(rr->srv.port)),
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(rr->srv.name)));
case DNS_TYPE_PTR:
case DNS_TYPE_NS:
case DNS_TYPE_CNAME:
case DNS_TYPE_DNAME:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(rr->ptr.name))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(rr->ptr.name)));
case DNS_TYPE_HINFO:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("cpu", SD_JSON_BUILD_STRING(rr->hinfo.cpu)),
- SD_JSON_BUILD_PAIR("os", SD_JSON_BUILD_STRING(rr->hinfo.os))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("cpu", SD_JSON_BUILD_STRING(rr->hinfo.cpu)),
+ SD_JSON_BUILD_PAIR("os", SD_JSON_BUILD_STRING(rr->hinfo.os)));
case DNS_TYPE_SPF:
case DNS_TYPE_TXT: {
@@ -2295,93 +2295,93 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) {
if (r < 0)
return r;
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("items", SD_JSON_BUILD_VARIANT(l))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("items", SD_JSON_BUILD_VARIANT(l)));
}
case DNS_TYPE_A:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("address", JSON_BUILD_IN4_ADDR(&rr->a.in_addr))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("address", JSON_BUILD_IN4_ADDR(&rr->a.in_addr)));
case DNS_TYPE_AAAA:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("address", JSON_BUILD_IN6_ADDR(&rr->aaaa.in6_addr))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("address", JSON_BUILD_IN6_ADDR(&rr->aaaa.in6_addr)));
case DNS_TYPE_SOA:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("mname", SD_JSON_BUILD_STRING(rr->soa.mname)),
- SD_JSON_BUILD_PAIR("rname", SD_JSON_BUILD_STRING(rr->soa.rname)),
- SD_JSON_BUILD_PAIR("serial", SD_JSON_BUILD_UNSIGNED(rr->soa.serial)),
- SD_JSON_BUILD_PAIR("refresh", SD_JSON_BUILD_UNSIGNED(rr->soa.refresh)),
- SD_JSON_BUILD_PAIR("expire", SD_JSON_BUILD_UNSIGNED(rr->soa.retry)),
- SD_JSON_BUILD_PAIR("minimum", SD_JSON_BUILD_UNSIGNED(rr->soa.minimum))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("mname", SD_JSON_BUILD_STRING(rr->soa.mname)),
+ SD_JSON_BUILD_PAIR("rname", SD_JSON_BUILD_STRING(rr->soa.rname)),
+ SD_JSON_BUILD_PAIR("serial", SD_JSON_BUILD_UNSIGNED(rr->soa.serial)),
+ SD_JSON_BUILD_PAIR("refresh", SD_JSON_BUILD_UNSIGNED(rr->soa.refresh)),
+ SD_JSON_BUILD_PAIR("expire", SD_JSON_BUILD_UNSIGNED(rr->soa.retry)),
+ SD_JSON_BUILD_PAIR("minimum", SD_JSON_BUILD_UNSIGNED(rr->soa.minimum)));
case DNS_TYPE_MX:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->mx.priority)),
- SD_JSON_BUILD_PAIR("exchange", SD_JSON_BUILD_STRING(rr->mx.exchange))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->mx.priority)),
+ SD_JSON_BUILD_PAIR("exchange", SD_JSON_BUILD_STRING(rr->mx.exchange)));
case DNS_TYPE_LOC:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("version", SD_JSON_BUILD_UNSIGNED(rr->loc.version)),
- SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_UNSIGNED(rr->loc.size)),
- SD_JSON_BUILD_PAIR("horiz_pre", SD_JSON_BUILD_UNSIGNED(rr->loc.horiz_pre)),
- SD_JSON_BUILD_PAIR("vert_pre", SD_JSON_BUILD_UNSIGNED(rr->loc.vert_pre)),
- SD_JSON_BUILD_PAIR("latitude", SD_JSON_BUILD_UNSIGNED(rr->loc.latitude)),
- SD_JSON_BUILD_PAIR("longitude", SD_JSON_BUILD_UNSIGNED(rr->loc.longitude)),
- SD_JSON_BUILD_PAIR("altitude", SD_JSON_BUILD_UNSIGNED(rr->loc.altitude))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("version", SD_JSON_BUILD_UNSIGNED(rr->loc.version)),
+ SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_UNSIGNED(rr->loc.size)),
+ SD_JSON_BUILD_PAIR("horiz_pre", SD_JSON_BUILD_UNSIGNED(rr->loc.horiz_pre)),
+ SD_JSON_BUILD_PAIR("vert_pre", SD_JSON_BUILD_UNSIGNED(rr->loc.vert_pre)),
+ SD_JSON_BUILD_PAIR("latitude", SD_JSON_BUILD_UNSIGNED(rr->loc.latitude)),
+ SD_JSON_BUILD_PAIR("longitude", SD_JSON_BUILD_UNSIGNED(rr->loc.longitude)),
+ SD_JSON_BUILD_PAIR("altitude", SD_JSON_BUILD_UNSIGNED(rr->loc.altitude)));
case DNS_TYPE_DS:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("keyTag", SD_JSON_BUILD_UNSIGNED(rr->ds.key_tag)),
- SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->ds.algorithm)),
- SD_JSON_BUILD_PAIR("digestType", SD_JSON_BUILD_UNSIGNED(rr->ds.digest_type)),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(rr->ds.digest, rr->ds.digest_size))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("keyTag", SD_JSON_BUILD_UNSIGNED(rr->ds.key_tag)),
+ SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->ds.algorithm)),
+ SD_JSON_BUILD_PAIR("digestType", SD_JSON_BUILD_UNSIGNED(rr->ds.digest_type)),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(rr->ds.digest, rr->ds.digest_size)));
case DNS_TYPE_SSHFP:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->sshfp.algorithm)),
- SD_JSON_BUILD_PAIR("fptype", SD_JSON_BUILD_UNSIGNED(rr->sshfp.fptype)),
- SD_JSON_BUILD_PAIR("fingerprint", SD_JSON_BUILD_HEX(rr->sshfp.fingerprint, rr->sshfp.fingerprint_size))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->sshfp.algorithm)),
+ SD_JSON_BUILD_PAIR("fptype", SD_JSON_BUILD_UNSIGNED(rr->sshfp.fptype)),
+ SD_JSON_BUILD_PAIR("fingerprint", SD_JSON_BUILD_HEX(rr->sshfp.fingerprint, rr->sshfp.fingerprint_size)));
case DNS_TYPE_DNSKEY:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->dnskey.flags)),
- SD_JSON_BUILD_PAIR("protocol", SD_JSON_BUILD_UNSIGNED(rr->dnskey.protocol)),
- SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->dnskey.algorithm)),
- SD_JSON_BUILD_PAIR("dnskey", SD_JSON_BUILD_BASE64(rr->dnskey.key, rr->dnskey.key_size))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->dnskey.flags)),
+ SD_JSON_BUILD_PAIR("protocol", SD_JSON_BUILD_UNSIGNED(rr->dnskey.protocol)),
+ SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->dnskey.algorithm)),
+ SD_JSON_BUILD_PAIR("dnskey", SD_JSON_BUILD_BASE64(rr->dnskey.key, rr->dnskey.key_size)));
case DNS_TYPE_RRSIG:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("signer", SD_JSON_BUILD_STRING(rr->rrsig.signer)),
- SD_JSON_BUILD_PAIR("typeCovered", SD_JSON_BUILD_UNSIGNED(rr->rrsig.type_covered)),
- SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->rrsig.algorithm)),
- SD_JSON_BUILD_PAIR("labels", SD_JSON_BUILD_UNSIGNED(rr->rrsig.labels)),
- SD_JSON_BUILD_PAIR("originalTtl", SD_JSON_BUILD_UNSIGNED(rr->rrsig.original_ttl)),
- SD_JSON_BUILD_PAIR("expiration", SD_JSON_BUILD_UNSIGNED(rr->rrsig.expiration)),
- SD_JSON_BUILD_PAIR("inception", SD_JSON_BUILD_UNSIGNED(rr->rrsig.inception)),
- SD_JSON_BUILD_PAIR("keyTag", SD_JSON_BUILD_UNSIGNED(rr->rrsig.key_tag)),
- SD_JSON_BUILD_PAIR("signature", SD_JSON_BUILD_BASE64(rr->rrsig.signature, rr->rrsig.signature_size))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("signer", SD_JSON_BUILD_STRING(rr->rrsig.signer)),
+ SD_JSON_BUILD_PAIR("typeCovered", SD_JSON_BUILD_UNSIGNED(rr->rrsig.type_covered)),
+ SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->rrsig.algorithm)),
+ SD_JSON_BUILD_PAIR("labels", SD_JSON_BUILD_UNSIGNED(rr->rrsig.labels)),
+ SD_JSON_BUILD_PAIR("originalTtl", SD_JSON_BUILD_UNSIGNED(rr->rrsig.original_ttl)),
+ SD_JSON_BUILD_PAIR("expiration", SD_JSON_BUILD_UNSIGNED(rr->rrsig.expiration)),
+ SD_JSON_BUILD_PAIR("inception", SD_JSON_BUILD_UNSIGNED(rr->rrsig.inception)),
+ SD_JSON_BUILD_PAIR("keyTag", SD_JSON_BUILD_UNSIGNED(rr->rrsig.key_tag)),
+ SD_JSON_BUILD_PAIR("signature", SD_JSON_BUILD_BASE64(rr->rrsig.signature, rr->rrsig.signature_size)));
case DNS_TYPE_NSEC: {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *bm = NULL;
@@ -2390,11 +2390,11 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) {
if (r < 0)
return r;
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("nextDomain", SD_JSON_BUILD_STRING(rr->nsec.next_domain_name)),
- SD_JSON_BUILD_PAIR("types", SD_JSON_BUILD_VARIANT(bm))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("nextDomain", SD_JSON_BUILD_STRING(rr->nsec.next_domain_name)),
+ SD_JSON_BUILD_PAIR("types", SD_JSON_BUILD_VARIANT(bm)));
}
case DNS_TYPE_NSEC3: {
@@ -2404,25 +2404,25 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) {
if (r < 0)
return r;
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->nsec3.algorithm)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->nsec3.flags)),
- SD_JSON_BUILD_PAIR("iterations", SD_JSON_BUILD_UNSIGNED(rr->nsec3.iterations)),
- SD_JSON_BUILD_PAIR("salt", SD_JSON_BUILD_HEX(rr->nsec3.salt, rr->nsec3.salt_size)),
- SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_BASE32HEX(rr->nsec3.next_hashed_name, rr->nsec3.next_hashed_name_size)),
- SD_JSON_BUILD_PAIR("types", SD_JSON_BUILD_VARIANT(bm))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("algorithm", SD_JSON_BUILD_UNSIGNED(rr->nsec3.algorithm)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->nsec3.flags)),
+ SD_JSON_BUILD_PAIR("iterations", SD_JSON_BUILD_UNSIGNED(rr->nsec3.iterations)),
+ SD_JSON_BUILD_PAIR("salt", SD_JSON_BUILD_HEX(rr->nsec3.salt, rr->nsec3.salt_size)),
+ SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_BASE32HEX(rr->nsec3.next_hashed_name, rr->nsec3.next_hashed_name_size)),
+ SD_JSON_BUILD_PAIR("types", SD_JSON_BUILD_VARIANT(bm)));
}
case DNS_TYPE_TLSA:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("certUsage", SD_JSON_BUILD_UNSIGNED(rr->tlsa.cert_usage)),
- SD_JSON_BUILD_PAIR("selector", SD_JSON_BUILD_UNSIGNED(rr->tlsa.selector)),
- SD_JSON_BUILD_PAIR("matchingType", SD_JSON_BUILD_UNSIGNED(rr->tlsa.matching_type)),
- SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_HEX(rr->tlsa.data, rr->tlsa.data_size))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("certUsage", SD_JSON_BUILD_UNSIGNED(rr->tlsa.cert_usage)),
+ SD_JSON_BUILD_PAIR("selector", SD_JSON_BUILD_UNSIGNED(rr->tlsa.selector)),
+ SD_JSON_BUILD_PAIR("matchingType", SD_JSON_BUILD_UNSIGNED(rr->tlsa.matching_type)),
+ SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_HEX(rr->tlsa.data, rr->tlsa.data_size)));
case DNS_TYPE_SVCB:
case DNS_TYPE_HTTPS: {
@@ -2431,33 +2431,33 @@ int dns_resource_record_to_json(DnsResourceRecord *rr, sd_json_variant **ret) {
if (r < 0)
return r;
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->svcb.priority)),
- SD_JSON_BUILD_PAIR("target", SD_JSON_BUILD_STRING(rr->svcb.target_name)),
- SD_JSON_BUILD_PAIR("params", SD_JSON_BUILD_VARIANT(p))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->svcb.priority)),
+ SD_JSON_BUILD_PAIR("target", SD_JSON_BUILD_STRING(rr->svcb.target_name)),
+ SD_JSON_BUILD_PAIR("params", SD_JSON_BUILD_VARIANT(p)));
}
case DNS_TYPE_CAA:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->caa.flags)),
- SD_JSON_BUILD_PAIR("tag", SD_JSON_BUILD_STRING(rr->caa.tag)),
- SD_JSON_BUILD_PAIR("value", SD_JSON_BUILD_OCTESCAPE(rr->caa.value, rr->caa.value_size))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(rr->caa.flags)),
+ SD_JSON_BUILD_PAIR("tag", SD_JSON_BUILD_STRING(rr->caa.tag)),
+ SD_JSON_BUILD_PAIR("value", SD_JSON_BUILD_OCTESCAPE(rr->caa.value, rr->caa.value_size)));
case DNS_TYPE_NAPTR:
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
- SD_JSON_BUILD_PAIR("order", SD_JSON_BUILD_UNSIGNED(rr->naptr.order)),
- SD_JSON_BUILD_PAIR("preference", SD_JSON_BUILD_UNSIGNED(rr->naptr.preference)),
- /* NB: we name this flags field here naptrFlags, because there's already another "flags" field (for example in CAA) which has a different type */
- SD_JSON_BUILD_PAIR("naptrFlags", SD_JSON_BUILD_STRING(rr->naptr.flags)),
- SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_STRING(rr->naptr.services)),
- SD_JSON_BUILD_PAIR("regexp", SD_JSON_BUILD_STRING(rr->naptr.regexp)),
- SD_JSON_BUILD_PAIR("replacement", SD_JSON_BUILD_STRING(rr->naptr.replacement))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_VARIANT(k)),
+ SD_JSON_BUILD_PAIR("order", SD_JSON_BUILD_UNSIGNED(rr->naptr.order)),
+ SD_JSON_BUILD_PAIR("preference", SD_JSON_BUILD_UNSIGNED(rr->naptr.preference)),
+ /* NB: we name this flags field here naptrFlags, because there's already another "flags" field (for example in CAA) which has a different type */
+ SD_JSON_BUILD_PAIR("naptrFlags", SD_JSON_BUILD_STRING(rr->naptr.flags)),
+ SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_STRING(rr->naptr.services)),
+ SD_JSON_BUILD_PAIR("regexp", SD_JSON_BUILD_STRING(rr->naptr.regexp)),
+ SD_JSON_BUILD_PAIR("replacement", SD_JSON_BUILD_STRING(rr->naptr.replacement)));
default:
/* Can't provide broken-down format */
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index a2756c1162..21b9844e04 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -1726,13 +1726,13 @@ int dns_scope_dump_cache_to_json(DnsScope *scope, sd_json_variant **ret) {
if (r < 0)
return r;
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("protocol", dns_protocol_to_string(scope->protocol)),
- SD_JSON_BUILD_PAIR_CONDITION(scope->family != AF_UNSPEC, "family", SD_JSON_BUILD_INTEGER(scope->family)),
- SD_JSON_BUILD_PAIR_CONDITION(!!scope->link, "ifindex", SD_JSON_BUILD_INTEGER(scope->link ? scope->link->ifindex : 0)),
- SD_JSON_BUILD_PAIR_CONDITION(!!scope->link, "ifname", SD_JSON_BUILD_STRING(scope->link ? scope->link->ifname : NULL)),
- SD_JSON_BUILD_PAIR_VARIANT("cache", cache)));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR_STRING("protocol", dns_protocol_to_string(scope->protocol)),
+ SD_JSON_BUILD_PAIR_CONDITION(scope->family != AF_UNSPEC, "family", SD_JSON_BUILD_INTEGER(scope->family)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!scope->link, "ifindex", SD_JSON_BUILD_INTEGER(scope->link ? scope->link->ifindex : 0)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!scope->link, "ifname", SD_JSON_BUILD_STRING(scope->link ? scope->link->ifname : NULL)),
+ SD_JSON_BUILD_PAIR_VARIANT("cache", cache));
}
int dns_type_suitable_for_protocol(uint16_t type, DnsProtocol protocol) {
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
index 8abba8b064..70894977eb 100644
--- a/src/resolve/resolved-dns-server.c
+++ b/src/resolve/resolved-dns-server.c
@@ -1111,22 +1111,22 @@ int dns_server_dump_state_to_json(DnsServer *server, sd_json_variant **ret) {
assert(server);
assert(ret);
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("Server", strna(dns_server_string_full(server))),
- SD_JSON_BUILD_PAIR_STRING("Type", strna(dns_server_type_to_string(server->type))),
- SD_JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "Interface", SD_JSON_BUILD_STRING(server->link ? server->link->ifname : NULL)),
- SD_JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "InterfaceIndex", SD_JSON_BUILD_UNSIGNED(server->link ? server->link->ifindex : 0)),
- SD_JSON_BUILD_PAIR_STRING("VerifiedFeatureLevel", strna(dns_server_feature_level_to_string(server->verified_feature_level))),
- SD_JSON_BUILD_PAIR_STRING("PossibleFeatureLevel", strna(dns_server_feature_level_to_string(server->possible_feature_level))),
- SD_JSON_BUILD_PAIR_STRING("DNSSECMode", strna(dnssec_mode_to_string(dns_server_get_dnssec_mode(server)))),
- SD_JSON_BUILD_PAIR_BOOLEAN("DNSSECSupported", dns_server_dnssec_supported(server)),
- SD_JSON_BUILD_PAIR_UNSIGNED("ReceivedUDPFragmentMax", server->received_udp_fragment_max),
- SD_JSON_BUILD_PAIR_UNSIGNED("FailedUDPAttempts", server->n_failed_udp),
- SD_JSON_BUILD_PAIR_UNSIGNED("FailedTCPAttempts", server->n_failed_tcp),
- SD_JSON_BUILD_PAIR_BOOLEAN("PacketTruncated", server->packet_truncated),
- SD_JSON_BUILD_PAIR_BOOLEAN("PacketBadOpt", server->packet_bad_opt),
- SD_JSON_BUILD_PAIR_BOOLEAN("PacketRRSIGMissing", server->packet_rrsig_missing),
- SD_JSON_BUILD_PAIR_BOOLEAN("PacketInvalid", server->packet_invalid),
- SD_JSON_BUILD_PAIR_BOOLEAN("PacketDoOff", server->packet_do_off)));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR_STRING("Server", strna(dns_server_string_full(server))),
+ SD_JSON_BUILD_PAIR_STRING("Type", strna(dns_server_type_to_string(server->type))),
+ SD_JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "Interface", SD_JSON_BUILD_STRING(server->link ? server->link->ifname : NULL)),
+ SD_JSON_BUILD_PAIR_CONDITION(server->type == DNS_SERVER_LINK, "InterfaceIndex", SD_JSON_BUILD_UNSIGNED(server->link ? server->link->ifindex : 0)),
+ SD_JSON_BUILD_PAIR_STRING("VerifiedFeatureLevel", strna(dns_server_feature_level_to_string(server->verified_feature_level))),
+ SD_JSON_BUILD_PAIR_STRING("PossibleFeatureLevel", strna(dns_server_feature_level_to_string(server->possible_feature_level))),
+ SD_JSON_BUILD_PAIR_STRING("DNSSECMode", strna(dnssec_mode_to_string(dns_server_get_dnssec_mode(server)))),
+ SD_JSON_BUILD_PAIR_BOOLEAN("DNSSECSupported", dns_server_dnssec_supported(server)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("ReceivedUDPFragmentMax", server->received_udp_fragment_max),
+ SD_JSON_BUILD_PAIR_UNSIGNED("FailedUDPAttempts", server->n_failed_udp),
+ SD_JSON_BUILD_PAIR_UNSIGNED("FailedTCPAttempts", server->n_failed_tcp),
+ SD_JSON_BUILD_PAIR_BOOLEAN("PacketTruncated", server->packet_truncated),
+ SD_JSON_BUILD_PAIR_BOOLEAN("PacketBadOpt", server->packet_bad_opt),
+ SD_JSON_BUILD_PAIR_BOOLEAN("PacketRRSIGMissing", server->packet_rrsig_missing),
+ SD_JSON_BUILD_PAIR_BOOLEAN("PacketInvalid", server->packet_invalid),
+ SD_JSON_BUILD_PAIR_BOOLEAN("PacketDoOff", server->packet_do_off));
}
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 5959546dbb..2eee418adf 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -1211,40 +1211,40 @@ int manager_monitor_send(Manager *m, DnsQuery *q) {
if (r < 0)
return log_error_errno(r, "Failed to generate RR wire format: %m");
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&janswer,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(!!v, "rr", SD_JSON_BUILD_VARIANT(v)),
- SD_JSON_BUILD_PAIR("raw", SD_JSON_BUILD_BASE64(rri->rr->wire_format, rri->rr->wire_format_size)),
- SD_JSON_BUILD_PAIR_CONDITION(rri->ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(rri->ifindex))));
+ SD_JSON_BUILD_PAIR_CONDITION(!!v, "rr", SD_JSON_BUILD_VARIANT(v)),
+ SD_JSON_BUILD_PAIR("raw", SD_JSON_BUILD_BASE64(rri->rr->wire_format, rri->rr->wire_format_size)),
+ SD_JSON_BUILD_PAIR_CONDITION(rri->ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(rri->ifindex)));
if (r < 0)
return log_debug_errno(r, "Failed to append notification entry to array: %m");
}
SET_FOREACH(connection, m->varlink_subscription) {
- r = varlink_notifyb(connection,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("state", SD_JSON_BUILD_STRING(dns_transaction_state_to_string(q->state))),
- SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_DNSSEC_FAILED,
- "result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))),
- SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_RCODE_FAILURE,
- "rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)),
- SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_ERRNO,
- "errno", SD_JSON_BUILD_INTEGER(q->answer_errno)),
- SD_JSON_BUILD_PAIR_CONDITION(IN_SET(q->state,
- DNS_TRANSACTION_DNSSEC_FAILED,
- DNS_TRANSACTION_RCODE_FAILURE) &&
- q->answer_ede_rcode >= 0,
- "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)),
- SD_JSON_BUILD_PAIR_CONDITION(IN_SET(q->state,
- DNS_TRANSACTION_DNSSEC_FAILED,
- DNS_TRANSACTION_RCODE_FAILURE) &&
- q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg),
- "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)),
- SD_JSON_BUILD_PAIR("question", SD_JSON_BUILD_VARIANT(jquestion)),
- SD_JSON_BUILD_PAIR_CONDITION(!!jcollected_questions,
- "collectedQuestions", SD_JSON_BUILD_VARIANT(jcollected_questions)),
- SD_JSON_BUILD_PAIR_CONDITION(!!janswer,
- "answer", SD_JSON_BUILD_VARIANT(janswer))));
+ r = varlink_notifybo(
+ connection,
+ SD_JSON_BUILD_PAIR("state", SD_JSON_BUILD_STRING(dns_transaction_state_to_string(q->state))),
+ SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_DNSSEC_FAILED,
+ "result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))),
+ SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_RCODE_FAILURE,
+ "rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)),
+ SD_JSON_BUILD_PAIR_CONDITION(q->state == DNS_TRANSACTION_ERRNO,
+ "errno", SD_JSON_BUILD_INTEGER(q->answer_errno)),
+ SD_JSON_BUILD_PAIR_CONDITION(IN_SET(q->state,
+ DNS_TRANSACTION_DNSSEC_FAILED,
+ DNS_TRANSACTION_RCODE_FAILURE) &&
+ q->answer_ede_rcode >= 0,
+ "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)),
+ SD_JSON_BUILD_PAIR_CONDITION(IN_SET(q->state,
+ DNS_TRANSACTION_DNSSEC_FAILED,
+ DNS_TRANSACTION_RCODE_FAILURE) &&
+ q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg),
+ "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)),
+ SD_JSON_BUILD_PAIR("question", SD_JSON_BUILD_VARIANT(jquestion)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!jcollected_questions,
+ "collectedQuestions", SD_JSON_BUILD_VARIANT(jcollected_questions)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!janswer,
+ "answer", SD_JSON_BUILD_VARIANT(janswer)));
if (r < 0)
log_debug_errno(r, "Failed to send monitor event, ignoring: %m");
}
@@ -1891,27 +1891,26 @@ int dns_manager_dump_statistics_json(Manager *m, sd_json_variant **ret) {
miss += s->cache.n_miss;
}
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("transactions", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("currentTransactions", hashmap_size(m->dns_transactions)),
- SD_JSON_BUILD_PAIR_UNSIGNED("totalTransactions", m->n_transactions_total),
- SD_JSON_BUILD_PAIR_UNSIGNED("totalTimeouts", m->n_timeouts_total),
- SD_JSON_BUILD_PAIR_UNSIGNED("totalTimeoutsServedStale", m->n_timeouts_served_stale_total),
- SD_JSON_BUILD_PAIR_UNSIGNED("totalFailedResponses", m->n_failure_responses_total),
- SD_JSON_BUILD_PAIR_UNSIGNED("totalFailedResponsesServedStale", m->n_failure_responses_served_stale_total)
- )),
- SD_JSON_BUILD_PAIR("cache", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("size", size),
- SD_JSON_BUILD_PAIR_UNSIGNED("hits", hit),
- SD_JSON_BUILD_PAIR_UNSIGNED("misses", miss)
- )),
- SD_JSON_BUILD_PAIR("dnssec", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UNSIGNED("secure", m->n_dnssec_verdict[DNSSEC_SECURE]),
- SD_JSON_BUILD_PAIR_UNSIGNED("insecure", m->n_dnssec_verdict[DNSSEC_INSECURE]),
- SD_JSON_BUILD_PAIR_UNSIGNED("bogus", m->n_dnssec_verdict[DNSSEC_BOGUS]),
- SD_JSON_BUILD_PAIR_UNSIGNED("indeterminate", m->n_dnssec_verdict[DNSSEC_INDETERMINATE])
- ))));
+ return sd_json_buildo(ret,
+ SD_JSON_BUILD_PAIR("transactions", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR_UNSIGNED("currentTransactions", hashmap_size(m->dns_transactions)),
+ SD_JSON_BUILD_PAIR_UNSIGNED("totalTransactions", m->n_transactions_total),
+ SD_JSON_BUILD_PAIR_UNSIGNED("totalTimeouts", m->n_timeouts_total),
+ SD_JSON_BUILD_PAIR_UNSIGNED("totalTimeoutsServedStale", m->n_timeouts_served_stale_total),
+ SD_JSON_BUILD_PAIR_UNSIGNED("totalFailedResponses", m->n_failure_responses_total),
+ SD_JSON_BUILD_PAIR_UNSIGNED("totalFailedResponsesServedStale", m->n_failure_responses_served_stale_total)
+ )),
+ SD_JSON_BUILD_PAIR("cache", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR_UNSIGNED("size", size),
+ SD_JSON_BUILD_PAIR_UNSIGNED("hits", hit),
+ SD_JSON_BUILD_PAIR_UNSIGNED("misses", miss)
+ )),
+ SD_JSON_BUILD_PAIR("dnssec", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR_UNSIGNED("secure", m->n_dnssec_verdict[DNSSEC_SECURE]),
+ SD_JSON_BUILD_PAIR_UNSIGNED("insecure", m->n_dnssec_verdict[DNSSEC_INSECURE]),
+ SD_JSON_BUILD_PAIR_UNSIGNED("bogus", m->n_dnssec_verdict[DNSSEC_BOGUS]),
+ SD_JSON_BUILD_PAIR_UNSIGNED("indeterminate", m->n_dnssec_verdict[DNSSEC_INDETERMINATE])
+ )));
}
void dns_manager_reset_statistics(Manager *m) {
diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c
index d0da67c78b..3d109026d2 100644
--- a/src/resolve/resolved-varlink.c
+++ b/src/resolve/resolved-varlink.c
@@ -60,12 +60,12 @@ static int reply_query_state(DnsQuery *q) {
return varlink_error(q->varlink_request, "io.systemd.Resolve.QueryAborted", NULL);
case DNS_TRANSACTION_DNSSEC_FAILED:
- return varlink_errorb(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed",
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))),
- SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0,
- "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)),
- SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg),
- "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg))));
+ return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed",
+ SD_JSON_BUILD_PAIR("result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))),
+ SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0,
+ "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)),
+ SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg),
+ "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)));
case DNS_TRANSACTION_NO_TRUST_ANCHOR:
return varlink_error(q->varlink_request, "io.systemd.Resolve.NoTrustAnchor", NULL);
@@ -85,16 +85,16 @@ static int reply_query_state(DnsQuery *q) {
case DNS_TRANSACTION_NOT_FOUND:
/* We return this as NXDOMAIN. This is only generated when a host doesn't implement LLMNR/TCP, and we
* thus quickly know that we cannot resolve an in-addr.arpa or ip6.arpa address. */
- return varlink_errorb(q->varlink_request, "io.systemd.Resolve.DNSError",
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(DNS_RCODE_NXDOMAIN))));
+ return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError",
+ SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(DNS_RCODE_NXDOMAIN)));
case DNS_TRANSACTION_RCODE_FAILURE:
- return varlink_errorb(q->varlink_request, "io.systemd.Resolve.DNSError",
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)),
- SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0,
- "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)),
- SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg),
- "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg))));
+ return varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError",
+ SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)),
+ SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0,
+ "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)),
+ SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg),
+ "extendedDNSErrorMessage", SD_JSON_BUILD_STRING(q->answer_ede_msg)));
case DNS_TRANSACTION_NULL:
case DNS_TRANSACTION_PENDING:
@@ -211,11 +211,11 @@ static int find_addr_records(
return -EAFNOSUPPORT;
}
- r = sd_json_build(&entry,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)),
- SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(family)),
- SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(p, FAMILY_ADDRESS_SIZE(family)))));
+ r = sd_json_buildo(
+ &entry,
+ SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)),
+ SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(family)),
+ SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(p, FAMILY_ADDRESS_SIZE(family))));
if (r < 0)
return r;
@@ -274,11 +274,11 @@ static void vl_method_resolve_hostname_complete(DnsQuery *query) {
if (r < 0)
goto finish;
- r = varlink_replyb(q->varlink_request,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("addresses", SD_JSON_BUILD_VARIANT(array)),
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q)))));
+ r = varlink_replybo(
+ q->varlink_request,
+ SD_JSON_BUILD_PAIR("addresses", SD_JSON_BUILD_VARIANT(array)),
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q))));
finish:
if (r < 0) {
log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send hostname reply: %m");
@@ -311,18 +311,17 @@ static int parse_as_address(Varlink *link, LookupParameters *p) {
if (r < 0)
return r;
- return varlink_replyb(
+ return varlink_replybo(
link,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("addresses",
- SD_JSON_BUILD_ARRAY(
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)),
- SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(ff)),
- SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(&parsed, FAMILY_ADDRESS_SIZE(ff)))))),
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(canonical)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(SD_RESOLVED_FLAGS_MAKE(dns_synthesize_protocol(p->flags), ff, true, true)|
- SD_RESOLVED_SYNTHETIC))));
+ SD_JSON_BUILD_PAIR("addresses",
+ SD_JSON_BUILD_ARRAY(
+ SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)),
+ SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(ff)),
+ SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(&parsed, FAMILY_ADDRESS_SIZE(ff)))))),
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(canonical)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(SD_RESOLVED_FLAGS_MAKE(dns_synthesize_protocol(p->flags), ff, true, true)|
+ SD_RESOLVED_SYNTHETIC)));
}
static int vl_method_resolve_hostname(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
@@ -476,11 +475,10 @@ static void vl_method_resolve_address_complete(DnsQuery *query) {
if (r < 0)
goto finish;
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)),
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized))));
+ SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)),
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(normalized)));
if (r < 0)
goto finish;
}
@@ -490,10 +488,10 @@ static void vl_method_resolve_address_complete(DnsQuery *query) {
goto finish;
}
- r = varlink_replyb(q->varlink_request,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("names", SD_JSON_BUILD_VARIANT(array)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q)))));
+ r = varlink_replybo(
+ q->varlink_request,
+ SD_JSON_BUILD_PAIR("names", SD_JSON_BUILD_VARIANT(array)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q))));
finish:
if (r < 0) {
log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send address reply: %m");
@@ -655,12 +653,12 @@ static int append_srv(
if (r < 0)
return r;
- r = sd_json_build(&v,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->srv.priority)),
- SD_JSON_BUILD_PAIR("weight", SD_JSON_BUILD_UNSIGNED(rr->srv.weight)),
- SD_JSON_BUILD_PAIR("port", SD_JSON_BUILD_UNSIGNED(rr->srv.port)),
- SD_JSON_BUILD_PAIR("hostname", SD_JSON_BUILD_STRING(normalized))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("priority", SD_JSON_BUILD_UNSIGNED(rr->srv.priority)),
+ SD_JSON_BUILD_PAIR("weight", SD_JSON_BUILD_UNSIGNED(rr->srv.weight)),
+ SD_JSON_BUILD_PAIR("port", SD_JSON_BUILD_UNSIGNED(rr->srv.port)),
+ SD_JSON_BUILD_PAIR("hostname", SD_JSON_BUILD_STRING(normalized)));
if (r < 0)
return r;
@@ -830,14 +828,15 @@ static void resolve_service_all_complete(DnsQuery *query) {
if (r < 0)
goto finish;
- r = varlink_replyb(query->varlink_request, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_VARIANT(srv)),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_object(txt), "txt", SD_JSON_BUILD_VARIANT(txt)),
- SD_JSON_BUILD_PAIR("canonical", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
- SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(type)),
- SD_JSON_BUILD_PAIR("domain", SD_JSON_BUILD_STRING(domain)))),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(dns_query_reply_flags_make(query)))));
+ r = varlink_replybo(
+ query->varlink_request,
+ SD_JSON_BUILD_PAIR("services", SD_JSON_BUILD_VARIANT(srv)),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_json_variant_is_blank_object(txt), "txt", SD_JSON_BUILD_VARIANT(txt)),
+ SD_JSON_BUILD_PAIR("canonical", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
+ SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(type)),
+ SD_JSON_BUILD_PAIR("domain", SD_JSON_BUILD_STRING(domain)))),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(dns_query_reply_flags_make(query))));
finish:
if (r < 0) {
@@ -1125,11 +1124,11 @@ static void vl_method_resolve_record_complete(DnsQuery *query) {
if (r < 0)
goto finish;
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&array,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)),
- SD_JSON_BUILD_PAIR_CONDITION(!!v, "rr", SD_JSON_BUILD_VARIANT(v)),
- SD_JSON_BUILD_PAIR("raw", SD_JSON_BUILD_BASE64(rr->wire_format, rr->wire_format_size))));
+ SD_JSON_BUILD_PAIR_CONDITION(ifindex > 0, "ifindex", SD_JSON_BUILD_INTEGER(ifindex)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!v, "rr", SD_JSON_BUILD_VARIANT(v)),
+ SD_JSON_BUILD_PAIR("raw", SD_JSON_BUILD_BASE64(rr->wire_format, rr->wire_format_size)));
if (r < 0)
goto finish;
@@ -1141,10 +1140,10 @@ static void vl_method_resolve_record_complete(DnsQuery *query) {
goto finish;
}
- r = varlink_replyb(q->varlink_request,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("rrs", SD_JSON_BUILD_VARIANT(array)),
- SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q)))));
+ r = varlink_replybo(
+ q->varlink_request,
+ SD_JSON_BUILD_PAIR("rrs", SD_JSON_BUILD_VARIANT(array)),
+ SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(dns_query_reply_flags_make(q))));
finish:
if (r < 0) {
log_full_errno(ERRNO_IS_DISCONNECT(r) ? LOG_DEBUG : LOG_ERR, r, "Failed to send record reply: %m");
@@ -1246,8 +1245,7 @@ static int vl_method_subscribe_query_results(Varlink *link, sd_json_variant *par
/* Send a ready message to the connecting client, to indicate that we are now listinening, and all
* queries issued after the point the client sees this will also be reported to the client. */
- r = varlink_notifyb(link,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true))));
+ r = varlink_notifybo(link, SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true)));
if (r < 0)
return log_error_errno(r, "Failed to report monitor to be established: %m");
@@ -1291,8 +1289,7 @@ static int vl_method_dump_cache(Varlink *link, sd_json_variant *parameters, Varl
return r;
}
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list))));
+ return varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list)));
}
static int dns_server_dump_state_to_json_list(DnsServer *server, sd_json_variant **list) {
@@ -1347,8 +1344,7 @@ static int vl_method_dump_server_state(Varlink *link, sd_json_variant *parameter
return r;
}
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list))));
+ return varlink_replybo(link, SD_JSON_BUILD_PAIR("dump", SD_JSON_BUILD_VARIANT(list)));
}
static int vl_method_dump_statistics(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 0ae74a3e49..05b1d04506 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -1539,11 +1539,10 @@ static int json_addon(
assert(addon);
assert(addon_str);
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
array,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR(addon_str, SD_JSON_BUILD_STRING(addon->location)),
- SD_JSON_BUILD_PAIR("options", SD_JSON_BUILD_STRING(addon->cmdline))));
+ SD_JSON_BUILD_PAIR(addon_str, SD_JSON_BUILD_STRING(addon->location)),
+ SD_JSON_BUILD_PAIR("options", SD_JSON_BUILD_STRING(addon->cmdline)));
if (r < 0)
return log_oom();
@@ -1584,10 +1583,10 @@ static int json_cmdline(
return log_oom();
}
- r = sd_json_variant_merge_objectb(
- v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("addons", SD_JSON_BUILD_VARIANT(addons_array)),
- SD_JSON_BUILD_PAIR_CONDITION(!!combined_cmdline, "cmdline", SD_JSON_BUILD_STRING(combined_cmdline))));
+ r = sd_json_variant_merge_objectbo(
+ v,
+ SD_JSON_BUILD_PAIR("addons", SD_JSON_BUILD_VARIANT(addons_array)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!combined_cmdline, "cmdline", SD_JSON_BUILD_STRING(combined_cmdline)));
if (r < 0)
return log_oom();
return 0;
@@ -1717,38 +1716,37 @@ int boot_entry_to_json(const BootConfig *c, size_t i, sd_json_variant **ret) {
return log_oom();
}
- r = sd_json_variant_merge_objectb(
- &v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(boot_entry_type_json_to_string(e->type))),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->id, "id", SD_JSON_BUILD_STRING(e->id)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->path, "path", SD_JSON_BUILD_STRING(e->path)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->root, "root", SD_JSON_BUILD_STRING(e->root)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->title, "title", SD_JSON_BUILD_STRING(e->title)),
- SD_JSON_BUILD_PAIR_CONDITION(!!boot_entry_title(e), "showTitle", SD_JSON_BUILD_STRING(boot_entry_title(e))),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->sort_key, "sortKey", SD_JSON_BUILD_STRING(e->sort_key)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->version, "version", SD_JSON_BUILD_STRING(e->version)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->machine_id, "machineId", SD_JSON_BUILD_STRING(e->machine_id)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->architecture, "architecture", SD_JSON_BUILD_STRING(e->architecture)),
- SD_JSON_BUILD_PAIR_CONDITION(!!opts, "options", SD_JSON_BUILD_STRING(opts)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->kernel, "linux", SD_JSON_BUILD_STRING(e->kernel)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->efi, "efi", SD_JSON_BUILD_STRING(e->efi)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->initrd), "initrd", SD_JSON_BUILD_STRV(e->initrd)),
- SD_JSON_BUILD_PAIR_CONDITION(!!e->device_tree, "devicetree", SD_JSON_BUILD_STRING(e->device_tree)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->device_tree_overlay), "devicetreeOverlay", SD_JSON_BUILD_STRV(e->device_tree_overlay))));
+ r = sd_json_variant_merge_objectbo(
+ &v,
+ SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(boot_entry_type_json_to_string(e->type))),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->id, "id", SD_JSON_BUILD_STRING(e->id)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->path, "path", SD_JSON_BUILD_STRING(e->path)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->root, "root", SD_JSON_BUILD_STRING(e->root)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->title, "title", SD_JSON_BUILD_STRING(e->title)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!boot_entry_title(e), "showTitle", SD_JSON_BUILD_STRING(boot_entry_title(e))),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->sort_key, "sortKey", SD_JSON_BUILD_STRING(e->sort_key)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->version, "version", SD_JSON_BUILD_STRING(e->version)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->machine_id, "machineId", SD_JSON_BUILD_STRING(e->machine_id)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->architecture, "architecture", SD_JSON_BUILD_STRING(e->architecture)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!opts, "options", SD_JSON_BUILD_STRING(opts)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->kernel, "linux", SD_JSON_BUILD_STRING(e->kernel)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->efi, "efi", SD_JSON_BUILD_STRING(e->efi)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->initrd), "initrd", SD_JSON_BUILD_STRV(e->initrd)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!e->device_tree, "devicetree", SD_JSON_BUILD_STRING(e->device_tree)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(e->device_tree_overlay), "devicetreeOverlay", SD_JSON_BUILD_STRV(e->device_tree_overlay)));
if (r < 0)
return log_oom();
/* Sanitizers (only memory sanitizer?) do not like function call with too many
* arguments and trigger false positive warnings. Let's not add too many json objects
* at once. */
- r = sd_json_variant_merge_objectb(
- &v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("isReported", SD_JSON_BUILD_BOOLEAN(e->reported_by_loader)),
- SD_JSON_BUILD_PAIR_CONDITION(e->tries_left != UINT_MAX, "triesLeft", SD_JSON_BUILD_UNSIGNED(e->tries_left)),
- SD_JSON_BUILD_PAIR_CONDITION(e->tries_done != UINT_MAX, "triesDone", SD_JSON_BUILD_UNSIGNED(e->tries_done)),
- SD_JSON_BUILD_PAIR_CONDITION(c->default_entry >= 0, "isDefault", SD_JSON_BUILD_BOOLEAN(i == (size_t) c->default_entry)),
- SD_JSON_BUILD_PAIR_CONDITION(c->selected_entry >= 0, "isSelected", SD_JSON_BUILD_BOOLEAN(i == (size_t) c->selected_entry))));
-
+ r = sd_json_variant_merge_objectbo(
+ &v,
+ SD_JSON_BUILD_PAIR("isReported", SD_JSON_BUILD_BOOLEAN(e->reported_by_loader)),
+ SD_JSON_BUILD_PAIR_CONDITION(e->tries_left != UINT_MAX, "triesLeft", SD_JSON_BUILD_UNSIGNED(e->tries_left)),
+ SD_JSON_BUILD_PAIR_CONDITION(e->tries_done != UINT_MAX, "triesDone", SD_JSON_BUILD_UNSIGNED(e->tries_done)),
+ SD_JSON_BUILD_PAIR_CONDITION(c->default_entry >= 0, "isDefault", SD_JSON_BUILD_BOOLEAN(i == (size_t) c->default_entry)),
+ SD_JSON_BUILD_PAIR_CONDITION(c->selected_entry >= 0, "isSelected", SD_JSON_BUILD_BOOLEAN(i == (size_t) c->selected_entry)));
if (r < 0)
return log_oom();
diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c
index 7015b0822c..ba3c448db0 100644
--- a/src/shared/creds-util.c
+++ b/src/shared/creds-util.c
@@ -1551,17 +1551,17 @@ int ipc_encrypt_credential(const char *name, usec_t timestamp, usec_t not_after,
_cleanup_(sd_json_variant_unrefp) sd_json_variant *reply = NULL;
const char *error_id = NULL;
- r = varlink_callb(vl,
- "io.systemd.Credentials.Encrypt",
- &reply,
- &error_id,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(!!name, "name", SD_JSON_BUILD_STRING(name)),
- SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(jinput)),
- SD_JSON_BUILD_PAIR_CONDITION(timestamp != USEC_INFINITY, "timestamp", SD_JSON_BUILD_UNSIGNED(timestamp)),
- SD_JSON_BUILD_PAIR_CONDITION(not_after != USEC_INFINITY, "notAfter", SD_JSON_BUILD_UNSIGNED(not_after)),
- SD_JSON_BUILD_PAIR_CONDITION(!FLAGS_SET(flags, CREDENTIAL_ANY_SCOPE), "scope", SD_JSON_BUILD_STRING(uid_is_valid(uid) ? "user" : "system")),
- SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(uid), "uid", SD_JSON_BUILD_UNSIGNED(uid))));
+ r = varlink_callbo(
+ vl,
+ "io.systemd.Credentials.Encrypt",
+ &reply,
+ &error_id,
+ SD_JSON_BUILD_PAIR_CONDITION(!!name, "name", SD_JSON_BUILD_STRING(name)),
+ SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(jinput)),
+ SD_JSON_BUILD_PAIR_CONDITION(timestamp != USEC_INFINITY, "timestamp", SD_JSON_BUILD_UNSIGNED(timestamp)),
+ SD_JSON_BUILD_PAIR_CONDITION(not_after != USEC_INFINITY, "notAfter", SD_JSON_BUILD_UNSIGNED(not_after)),
+ SD_JSON_BUILD_PAIR_CONDITION(!FLAGS_SET(flags, CREDENTIAL_ANY_SCOPE), "scope", SD_JSON_BUILD_STRING(uid_is_valid(uid) ? "user" : "system")),
+ SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(uid), "uid", SD_JSON_BUILD_UNSIGNED(uid)));
if (r < 0)
return log_error_errno(r, "Failed to call Encrypt() varlink call.");
if (!isempty(error_id)) {
@@ -1611,16 +1611,16 @@ int ipc_decrypt_credential(const char *validate_name, usec_t validate_timestamp,
_cleanup_(sd_json_variant_unrefp) sd_json_variant *reply = NULL;
const char *error_id = NULL;
- r = varlink_callb(vl,
- "io.systemd.Credentials.Decrypt",
- &reply,
- &error_id,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(!!validate_name, "name", SD_JSON_BUILD_STRING(validate_name)),
- SD_JSON_BUILD_PAIR("blob", SD_JSON_BUILD_VARIANT(jinput)),
- SD_JSON_BUILD_PAIR_CONDITION(validate_timestamp != USEC_INFINITY, "timestamp", SD_JSON_BUILD_UNSIGNED(validate_timestamp)),
- SD_JSON_BUILD_PAIR_CONDITION(!FLAGS_SET(flags, CREDENTIAL_ANY_SCOPE), "scope", SD_JSON_BUILD_STRING(uid_is_valid(uid) ? "user" : "system")),
- SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(uid), "uid", SD_JSON_BUILD_UNSIGNED(uid))));
+ r = varlink_callbo(
+ vl,
+ "io.systemd.Credentials.Decrypt",
+ &reply,
+ &error_id,
+ SD_JSON_BUILD_PAIR_CONDITION(!!validate_name, "name", SD_JSON_BUILD_STRING(validate_name)),
+ SD_JSON_BUILD_PAIR("blob", SD_JSON_BUILD_VARIANT(jinput)),
+ SD_JSON_BUILD_PAIR_CONDITION(validate_timestamp != USEC_INFINITY, "timestamp", SD_JSON_BUILD_UNSIGNED(validate_timestamp)),
+ SD_JSON_BUILD_PAIR_CONDITION(!FLAGS_SET(flags, CREDENTIAL_ANY_SCOPE), "scope", SD_JSON_BUILD_STRING(uid_is_valid(uid) ? "user" : "system")),
+ SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(uid), "uid", SD_JSON_BUILD_UNSIGNED(uid)));
if (r < 0)
return log_error_errno(r, "Failed to call Decrypt() varlink call.");
if (!isempty(error_id)) {
diff --git a/src/shared/discover-image.c b/src/shared/discover-image.c
index 4813973d17..d7a9df70b1 100644
--- a/src/shared/discover-image.c
+++ b/src/shared/discover-image.c
@@ -1647,19 +1647,19 @@ bool image_in_search_path(
int image_to_json(const struct Image *img, sd_json_variant **ret) {
assert(img);
- return sd_json_build(ret,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("Type", image_type_to_string(img->type)),
- SD_JSON_BUILD_PAIR_STRING("Class", image_class_to_string(img->class)),
- SD_JSON_BUILD_PAIR_STRING("Name", img->name),
- SD_JSON_BUILD_PAIR_CONDITION(!!img->path, "Path", SD_JSON_BUILD_STRING(img->path)),
- SD_JSON_BUILD_PAIR_BOOLEAN("ReadOnly", img->read_only),
- SD_JSON_BUILD_PAIR_CONDITION(img->crtime != 0, "CreationTimestamp", SD_JSON_BUILD_UNSIGNED(img->crtime)),
- SD_JSON_BUILD_PAIR_CONDITION(img->mtime != 0, "ModificationTimestamp", SD_JSON_BUILD_UNSIGNED(img->mtime)),
- SD_JSON_BUILD_PAIR_CONDITION(img->usage != UINT64_MAX, "Usage", SD_JSON_BUILD_UNSIGNED(img->usage)),
- SD_JSON_BUILD_PAIR_CONDITION(img->usage_exclusive != UINT64_MAX, "UsageExclusive", SD_JSON_BUILD_UNSIGNED(img->usage_exclusive)),
- SD_JSON_BUILD_PAIR_CONDITION(img->limit != UINT64_MAX, "Limit", SD_JSON_BUILD_UNSIGNED(img->limit)),
- SD_JSON_BUILD_PAIR_CONDITION(img->limit_exclusive != UINT64_MAX, "LimitExclusive", SD_JSON_BUILD_UNSIGNED(img->limit_exclusive))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR_STRING("Type", image_type_to_string(img->type)),
+ SD_JSON_BUILD_PAIR_STRING("Class", image_class_to_string(img->class)),
+ SD_JSON_BUILD_PAIR_STRING("Name", img->name),
+ SD_JSON_BUILD_PAIR_CONDITION(!!img->path, "Path", SD_JSON_BUILD_STRING(img->path)),
+ SD_JSON_BUILD_PAIR_BOOLEAN("ReadOnly", img->read_only),
+ SD_JSON_BUILD_PAIR_CONDITION(img->crtime != 0, "CreationTimestamp", SD_JSON_BUILD_UNSIGNED(img->crtime)),
+ SD_JSON_BUILD_PAIR_CONDITION(img->mtime != 0, "ModificationTimestamp", SD_JSON_BUILD_UNSIGNED(img->mtime)),
+ SD_JSON_BUILD_PAIR_CONDITION(img->usage != UINT64_MAX, "Usage", SD_JSON_BUILD_UNSIGNED(img->usage)),
+ SD_JSON_BUILD_PAIR_CONDITION(img->usage_exclusive != UINT64_MAX, "UsageExclusive", SD_JSON_BUILD_UNSIGNED(img->usage_exclusive)),
+ SD_JSON_BUILD_PAIR_CONDITION(img->limit != UINT64_MAX, "Limit", SD_JSON_BUILD_UNSIGNED(img->limit)),
+ SD_JSON_BUILD_PAIR_CONDITION(img->limit_exclusive != UINT64_MAX, "LimitExclusive", SD_JSON_BUILD_UNSIGNED(img->limit_exclusive)));
}
static const char* const image_type_table[_IMAGE_TYPE_MAX] = {
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index fa8965efcb..0d23e51931 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -4304,18 +4304,17 @@ int mountfsd_mount_image(
}
sd_json_variant *reply = NULL;
- r = varlink_callb(
+ r = varlink_callbo(
vl,
"io.systemd.MountFileSystem.MountImage",
&reply,
&error_id,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("imageFileDescriptor", SD_JSON_BUILD_UNSIGNED(0)),
- SD_JSON_BUILD_PAIR_CONDITION(userns_fd >= 0, "userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(1)),
- SD_JSON_BUILD_PAIR("readOnly", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(flags, DISSECT_IMAGE_MOUNT_READ_ONLY))),
- SD_JSON_BUILD_PAIR("growFileSystems", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(flags, DISSECT_IMAGE_GROWFS))),
- SD_JSON_BUILD_PAIR_CONDITION(!!ps, "imagePolicy", SD_JSON_BUILD_STRING(ps)),
- SD_JSON_BUILD_PAIR("allowInteractiveAuthentication", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(flags, DISSECT_IMAGE_ALLOW_INTERACTIVE_AUTH)))));
+ SD_JSON_BUILD_PAIR("imageFileDescriptor", SD_JSON_BUILD_UNSIGNED(0)),
+ SD_JSON_BUILD_PAIR_CONDITION(userns_fd >= 0, "userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(1)),
+ SD_JSON_BUILD_PAIR("readOnly", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(flags, DISSECT_IMAGE_MOUNT_READ_ONLY))),
+ SD_JSON_BUILD_PAIR("growFileSystems", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(flags, DISSECT_IMAGE_GROWFS))),
+ SD_JSON_BUILD_PAIR_CONDITION(!!ps, "imagePolicy", SD_JSON_BUILD_STRING(ps)),
+ SD_JSON_BUILD_PAIR("allowInteractiveAuthentication", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(flags, DISSECT_IMAGE_ALLOW_INTERACTIVE_AUTH))));
if (r < 0)
return log_error_errno(r, "Failed to call MountImage() varlink call: %m");
if (!isempty(error_id))
diff --git a/src/shared/elf-util.c b/src/shared/elf-util.c
index 81eae76097..79ff4f8116 100644
--- a/src/shared/elf-util.c
+++ b/src/shared/elf-util.c
@@ -425,7 +425,7 @@ static int parse_package_metadata(const char *name, sd_json_variant *id_json, El
/* Then we build a new object using the module name as the key, and merge it
* with the previous parses, so that in the end it all fits together in a single
* JSON blob. */
- r = sd_json_build(&w, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR(name, SD_JSON_BUILD_VARIANT(v))));
+ r = sd_json_buildo(&w, SD_JSON_BUILD_PAIR(name, SD_JSON_BUILD_VARIANT(v)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
@@ -478,7 +478,7 @@ static int parse_buildid(Dwfl_Module *mod, Elf *elf, const char *name, StackCont
/* We will later parse package metadata json and pass it to our caller. Prepare the
* build-id in json format too, so that it can be appended and parsed cleanly. It
* will then be added as metadata to the journal message with the stack trace. */
- r = sd_json_build(&id_json, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("buildId", SD_JSON_BUILD_HEX(id, id_len))));
+ r = sd_json_buildo(&id_json, SD_JSON_BUILD_PAIR("buildId", SD_JSON_BUILD_HEX(id, id_len)));
if (r < 0)
return log_error_errno(r, "json_build on buildId failed: %m");
}
@@ -695,7 +695,7 @@ static int parse_elf(int fd, const char *executable, char **ret, sd_json_variant
/* If we found a build-id and nothing else, return at least that. */
if (!package_metadata && id_json) {
- r = sd_json_build(&package_metadata, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR(e, SD_JSON_BUILD_VARIANT(id_json))));
+ r = sd_json_buildo(&package_metadata, SD_JSON_BUILD_PAIR(e, SD_JSON_BUILD_VARIANT(id_json)));
if (r < 0)
return log_warning_errno(r, "Failed to build JSON object: %m");
}
@@ -708,23 +708,18 @@ static int parse_elf(int fd, const char *executable, char **ret, sd_json_variant
/* Note that e_type is always DYN for both executables and libraries, so we can't tell them apart from the header,
* but we will search for the PT_INTERP section when parsing the metadata. */
- r = sd_json_build(&elf_metadata, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("elfType", SD_JSON_BUILD_STRING(elf_type))));
+ r = sd_json_buildo(&elf_metadata, SD_JSON_BUILD_PAIR("elfType", SD_JSON_BUILD_STRING(elf_type)));
if (r < 0)
return log_warning_errno(r, "Failed to build JSON object: %m");
#if HAVE_DWELF_ELF_E_MACHINE_STRING
const char *elf_architecture = sym_dwelf_elf_e_machine_string(elf_header.e_machine);
if (elf_architecture) {
- _cleanup_(sd_json_variant_unrefp) sd_json_variant *json_architecture = NULL;
-
- r = sd_json_build(&json_architecture,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("elfArchitecture", SD_JSON_BUILD_STRING(elf_architecture))));
- if (r < 0)
- return log_warning_errno(r, "Failed to build JSON object: %m");
-
- r = sd_json_variant_merge_object(&elf_metadata, json_architecture);
+ r = sd_json_variant_merge_objectbo(
+ &elf_metadata,
+ SD_JSON_BUILD_PAIR("elfArchitecture", SD_JSON_BUILD_STRING(elf_architecture)));
if (r < 0)
- return log_warning_errno(r, "Failed to merge JSON objects: %m");
+ return log_warning_errno(r, "Failed to add elfArchitecture field: %m");
if (ret)
fprintf(c.m.f, "ELF object binary architecture: %s\n", elf_architecture);
diff --git a/src/shared/nsresource.c b/src/shared/nsresource.c
index d1368c22e3..5a34301377 100644
--- a/src/shared/nsresource.c
+++ b/src/shared/nsresource.c
@@ -76,14 +76,14 @@ int nsresource_allocate_userns(const char *name, uint64_t size) {
return log_debug_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
sd_json_variant *reply = NULL;
- r = varlink_callb(vl,
- "io.systemd.NamespaceResource.AllocateUserRange",
- &reply,
- &error_id,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
- SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_UNSIGNED(size)),
- SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx))));
+ r = varlink_callbo(
+ vl,
+ "io.systemd.NamespaceResource.AllocateUserRange",
+ &reply,
+ &error_id,
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
+ SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_UNSIGNED(size)),
+ SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx)));
if (r < 0)
return log_debug_errno(r, "Failed to call AllocateUserRange() varlink call: %m");
if (error_id)
@@ -130,13 +130,13 @@ int nsresource_register_userns(const char *name, int userns_fd) {
return log_debug_errno(userns_fd_idx, "Failed to push userns fd into varlink connection: %m");
sd_json_variant *reply = NULL;
- r = varlink_callb(vl,
- "io.systemd.NamespaceResource.RegisterUserNamespace",
- &reply,
- &error_id,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
- SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx))));
+ r = varlink_callbo(
+ vl,
+ "io.systemd.NamespaceResource.RegisterUserNamespace",
+ &reply,
+ &error_id,
+ SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)),
+ SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx)));
if (r < 0)
return log_debug_errno(r, "Failed to call RegisterUserNamespace() varlink call: %m");
if (error_id)
@@ -178,13 +178,13 @@ int nsresource_add_mount(int userns_fd, int mount_fd) {
return log_error_errno(mount_fd_idx, "Failed to push mount fd into varlink connection: %m");
sd_json_variant *reply = NULL;
- r = varlink_callb(vl,
- "io.systemd.NamespaceResource.AddMountToUserNamespace",
- &reply,
- &error_id,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx)),
- SD_JSON_BUILD_PAIR("mountFileDescriptor", SD_JSON_BUILD_UNSIGNED(mount_fd_idx))));
+ r = varlink_callbo(
+ vl,
+ "io.systemd.NamespaceResource.AddMountToUserNamespace",
+ &reply,
+ &error_id,
+ SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx)),
+ SD_JSON_BUILD_PAIR("mountFileDescriptor", SD_JSON_BUILD_UNSIGNED(mount_fd_idx)));
if (r < 0)
return log_error_errno(r, "Failed to call AddMountToUserNamespace() varlink call: %m");
if (streq_ptr(error_id, "io.systemd.NamespaceResource.UserNamespaceNotRegistered")) {
@@ -230,13 +230,13 @@ int nsresource_add_cgroup(int userns_fd, int cgroup_fd) {
return log_debug_errno(userns_fd_idx, "Failed to push cgroup fd into varlink connection: %m");
sd_json_variant *reply = NULL;
- r = varlink_callb(vl,
- "io.systemd.NamespaceResource.AddControlGroupToUserNamespace",
- &reply,
- &error_id,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx)),
- SD_JSON_BUILD_PAIR("controlGroupFileDescriptor", SD_JSON_BUILD_UNSIGNED(cgroup_fd_idx))));
+ r = varlink_callbo(
+ vl,
+ "io.systemd.NamespaceResource.AddControlGroupToUserNamespace",
+ &reply,
+ &error_id,
+ SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx)),
+ SD_JSON_BUILD_PAIR("controlGroupFileDescriptor", SD_JSON_BUILD_UNSIGNED(cgroup_fd_idx)));
if (r < 0)
return log_debug_errno(r, "Failed to call AddControlGroupToUserNamespace() varlink call: %m");
if (streq_ptr(error_id, "io.systemd.NamespaceResource.UserNamespaceNotRegistered")) {
@@ -294,15 +294,15 @@ int nsresource_add_netif(
return log_debug_errno(netns_fd_idx, "Failed to push netns fd into varlink connection: %m");
sd_json_variant *reply = NULL;
- r = varlink_callb(vl,
- "io.systemd.NamespaceResource.AddNetworkToUserNamespace",
- &reply,
- &error_id,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx)),
- SD_JSON_BUILD_PAIR("networkNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(netns_fd_idx)),
- SD_JSON_BUILD_PAIR("mode", JSON_BUILD_CONST_STRING("veth")),
- SD_JSON_BUILD_PAIR_CONDITION(!!namespace_ifname, "namespaceInterfaceName", SD_JSON_BUILD_STRING(namespace_ifname))));
+ r = varlink_callbo(
+ vl,
+ "io.systemd.NamespaceResource.AddNetworkToUserNamespace",
+ &reply,
+ &error_id,
+ SD_JSON_BUILD_PAIR("userNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(userns_fd_idx)),
+ SD_JSON_BUILD_PAIR("networkNamespaceFileDescriptor", SD_JSON_BUILD_UNSIGNED(netns_fd_idx)),
+ SD_JSON_BUILD_PAIR("mode", JSON_BUILD_CONST_STRING("veth")),
+ SD_JSON_BUILD_PAIR_CONDITION(!!namespace_ifname, "namespaceInterfaceName", SD_JSON_BUILD_STRING(namespace_ifname)));
if (r < 0)
return log_debug_errno(r, "Failed to call AddNetworkToUserNamespace() varlink call: %m");
if (streq_ptr(error_id, "io.systemd.NamespaceResource.UserNamespaceNotRegistered")) {
diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c
index c4a35a9667..9b5683433f 100644
--- a/src/shared/tpm2-util.c
+++ b/src/shared/tpm2-util.c
@@ -6321,10 +6321,10 @@ static int tpm2_userspace_log(
assert_se(a = tpm2_hash_alg_to_string(values->digests[i].hashAlg));
assert_se(implementation = EVP_get_digestbyname(a));
- r = sd_json_variant_append_arrayb(
- &array, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
- SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(&values->digests[i].digest, EVP_MD_size(implementation)))));
+ r = sd_json_variant_append_arraybo(
+ &array,
+ SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
+ SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(&values->digests[i].digest, EVP_MD_size(implementation))));
if (r < 0)
return log_debug_errno(r, "Failed to append digest object to JSON array: %m");
}
@@ -6335,15 +6335,16 @@ static int tpm2_userspace_log(
if (r < 0)
return log_debug_errno(r, "Failed to acquire boot ID: %m");
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(pcr_index)),
- SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(array)),
- SD_JSON_BUILD_PAIR("content_type", SD_JSON_BUILD_STRING("systemd")),
- SD_JSON_BUILD_PAIR("content", SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_CONDITION(!!description, "string", SD_JSON_BUILD_STRING(description)),
- SD_JSON_BUILD_PAIR("bootId", SD_JSON_BUILD_ID128(boot_id)),
- SD_JSON_BUILD_PAIR("timestamp", SD_JSON_BUILD_UNSIGNED(now(CLOCK_BOOTTIME))),
- SD_JSON_BUILD_PAIR_CONDITION(event_type >= 0, "eventType", SD_JSON_BUILD_STRING(tpm2_userspace_event_type_to_string(event_type)))))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(pcr_index)),
+ SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(array)),
+ SD_JSON_BUILD_PAIR("content_type", SD_JSON_BUILD_STRING("systemd")),
+ SD_JSON_BUILD_PAIR("content", SD_JSON_BUILD_OBJECT(
+ SD_JSON_BUILD_PAIR_CONDITION(!!description, "string", SD_JSON_BUILD_STRING(description)),
+ SD_JSON_BUILD_PAIR("bootId", SD_JSON_BUILD_ID128(boot_id)),
+ SD_JSON_BUILD_PAIR("timestamp", SD_JSON_BUILD_UNSIGNED(now(CLOCK_BOOTTIME))),
+ SD_JSON_BUILD_PAIR_CONDITION(event_type >= 0, "eventType", SD_JSON_BUILD_STRING(tpm2_userspace_event_type_to_string(event_type))))));
if (r < 0)
return log_debug_errno(r, "Failed to build log record JSON: %m");
@@ -6622,11 +6623,10 @@ int tpm2_pcr_prediction_to_json(
if (!vj)
continue;
- r = sd_json_variant_append_arrayb(
+ r = sd_json_variant_append_arraybo(
&aj,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_INTEGER("pcr", pcr),
- SD_JSON_BUILD_PAIR_VARIANT("values", vj)));
+ SD_JSON_BUILD_PAIR_INTEGER("pcr", pcr),
+ SD_JSON_BUILD_PAIR_VARIANT("values", vj));
if (r < 0)
return log_error_errno(r, "Failed to append PCR variants to JSON array: %m");
}
@@ -7384,22 +7384,22 @@ int tpm2_make_luks2_json(
* other programming languages. Let's not make things worse though, i.e. future additions to the JSON
* object should use "_" rather than "-" in field names. */
- r = sd_json_build(&v,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-tpm2")),
- SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string))),
- SD_JSON_BUILD_PAIR("tpm2-blob", JSON_BUILD_IOVEC_BASE64(blob)),
- SD_JSON_BUILD_PAIR("tpm2-pcrs", SD_JSON_BUILD_VARIANT(hmj)),
- SD_JSON_BUILD_PAIR_CONDITION(pcr_bank != 0 && tpm2_hash_alg_to_string(pcr_bank), "tpm2-pcr-bank", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(pcr_bank))),
- SD_JSON_BUILD_PAIR_CONDITION(primary_alg != 0 && tpm2_asym_alg_to_string(primary_alg), "tpm2-primary-alg", SD_JSON_BUILD_STRING(tpm2_asym_alg_to_string(primary_alg))),
- SD_JSON_BUILD_PAIR("tpm2-policy-hash", JSON_BUILD_IOVEC_HEX(policy_hash)),
- SD_JSON_BUILD_PAIR_CONDITION(FLAGS_SET(flags, TPM2_FLAGS_USE_PIN), "tpm2-pin", SD_JSON_BUILD_BOOLEAN(true)),
- SD_JSON_BUILD_PAIR_CONDITION(FLAGS_SET(flags, TPM2_FLAGS_USE_PCRLOCK), "tpm2_pcrlock", SD_JSON_BUILD_BOOLEAN(true)),
- SD_JSON_BUILD_PAIR_CONDITION(pubkey_pcr_mask != 0, "tpm2_pubkey_pcrs", SD_JSON_BUILD_VARIANT(pkmj)),
- SD_JSON_BUILD_PAIR_CONDITION(iovec_is_set(pubkey), "tpm2_pubkey", JSON_BUILD_IOVEC_BASE64(pubkey)),
- SD_JSON_BUILD_PAIR_CONDITION(iovec_is_set(salt), "tpm2_salt", JSON_BUILD_IOVEC_BASE64(salt)),
- SD_JSON_BUILD_PAIR_CONDITION(iovec_is_set(srk), "tpm2_srk", JSON_BUILD_IOVEC_BASE64(srk)),
- SD_JSON_BUILD_PAIR_CONDITION(iovec_is_set(pcrlock_nv), "tpm2_pcrlock_nv", JSON_BUILD_IOVEC_BASE64(pcrlock_nv))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-tpm2")),
+ SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string))),
+ SD_JSON_BUILD_PAIR("tpm2-blob", JSON_BUILD_IOVEC_BASE64(blob)),
+ SD_JSON_BUILD_PAIR("tpm2-pcrs", SD_JSON_BUILD_VARIANT(hmj)),
+ SD_JSON_BUILD_PAIR_CONDITION(pcr_bank != 0 && tpm2_hash_alg_to_string(pcr_bank), "tpm2-pcr-bank", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(pcr_bank))),
+ SD_JSON_BUILD_PAIR_CONDITION(primary_alg != 0 && tpm2_asym_alg_to_string(primary_alg), "tpm2-primary-alg", SD_JSON_BUILD_STRING(tpm2_asym_alg_to_string(primary_alg))),
+ SD_JSON_BUILD_PAIR("tpm2-policy-hash", JSON_BUILD_IOVEC_HEX(policy_hash)),
+ SD_JSON_BUILD_PAIR_CONDITION(FLAGS_SET(flags, TPM2_FLAGS_USE_PIN), "tpm2-pin", SD_JSON_BUILD_BOOLEAN(true)),
+ SD_JSON_BUILD_PAIR_CONDITION(FLAGS_SET(flags, TPM2_FLAGS_USE_PCRLOCK), "tpm2_pcrlock", SD_JSON_BUILD_BOOLEAN(true)),
+ SD_JSON_BUILD_PAIR_CONDITION(pubkey_pcr_mask != 0, "tpm2_pubkey_pcrs", SD_JSON_BUILD_VARIANT(pkmj)),
+ SD_JSON_BUILD_PAIR_CONDITION(iovec_is_set(pubkey), "tpm2_pubkey", JSON_BUILD_IOVEC_BASE64(pubkey)),
+ SD_JSON_BUILD_PAIR_CONDITION(iovec_is_set(salt), "tpm2_salt", JSON_BUILD_IOVEC_BASE64(salt)),
+ SD_JSON_BUILD_PAIR_CONDITION(iovec_is_set(srk), "tpm2_srk", JSON_BUILD_IOVEC_BASE64(srk)),
+ SD_JSON_BUILD_PAIR_CONDITION(iovec_is_set(pcrlock_nv), "tpm2_pcrlock_nv", JSON_BUILD_IOVEC_BASE64(pcrlock_nv)));
if (r < 0)
return r;
diff --git a/src/shared/user-record-nss.c b/src/shared/user-record-nss.c
index fa99694ed7..a37957ee96 100644
--- a/src/shared/user-record-nss.c
+++ b/src/shared/user-record-nss.c
@@ -137,23 +137,23 @@ int nss_passwd_to_user_record(
spwd->sp_inact * USEC_PER_DAY, UINT64_MAX);
hr->json = sd_json_variant_unref(hr->json);
- r = sd_json_build(&hr->json, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(hr->user_name)),
- SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(hr->uid)),
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(hr->gid)),
- SD_JSON_BUILD_PAIR_CONDITION(!!hr->real_name, "realName", SD_JSON_BUILD_STRING(hr->real_name)),
- SD_JSON_BUILD_PAIR_CONDITION(!!hr->home_directory, "homeDirectory", SD_JSON_BUILD_STRING(hr->home_directory)),
- SD_JSON_BUILD_PAIR_CONDITION(!!hr->shell, "shell", SD_JSON_BUILD_STRING(hr->shell)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(hr->hashed_password), "privileged", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRV(hr->hashed_password)))),
- SD_JSON_BUILD_PAIR_CONDITION(hr->locked >= 0, "locked", SD_JSON_BUILD_BOOLEAN(hr->locked)),
- SD_JSON_BUILD_PAIR_CONDITION(hr->not_after_usec != UINT64_MAX, "notAfterUSec", SD_JSON_BUILD_UNSIGNED(hr->not_after_usec)),
- SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_now >= 0, "passwordChangeNow", SD_JSON_BUILD_BOOLEAN(hr->password_change_now)),
- SD_JSON_BUILD_PAIR_CONDITION(hr->last_password_change_usec != UINT64_MAX, "lastPasswordChangeUSec", SD_JSON_BUILD_UNSIGNED(hr->last_password_change_usec)),
- SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_min_usec != UINT64_MAX, "passwordChangeMinUSec", SD_JSON_BUILD_UNSIGNED(hr->password_change_min_usec)),
- SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_max_usec != UINT64_MAX, "passwordChangeMaxUSec", SD_JSON_BUILD_UNSIGNED(hr->password_change_max_usec)),
- SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_warn_usec != UINT64_MAX, "passwordChangeWarnUSec", SD_JSON_BUILD_UNSIGNED(hr->password_change_warn_usec)),
- SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_inactive_usec != UINT64_MAX, "passwordChangeInactiveUSec", SD_JSON_BUILD_UNSIGNED(hr->password_change_inactive_usec))));
-
+ r = sd_json_buildo(
+ &hr->json,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(hr->user_name)),
+ SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(hr->uid)),
+ SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(hr->gid)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!hr->real_name, "realName", SD_JSON_BUILD_STRING(hr->real_name)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!hr->home_directory, "homeDirectory", SD_JSON_BUILD_STRING(hr->home_directory)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!hr->shell, "shell", SD_JSON_BUILD_STRING(hr->shell)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(hr->hashed_password), "privileged", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRV(hr->hashed_password)))),
+ SD_JSON_BUILD_PAIR_CONDITION(hr->locked >= 0, "locked", SD_JSON_BUILD_BOOLEAN(hr->locked)),
+ SD_JSON_BUILD_PAIR_CONDITION(hr->not_after_usec != UINT64_MAX, "notAfterUSec", SD_JSON_BUILD_UNSIGNED(hr->not_after_usec)),
+ SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_now >= 0, "passwordChangeNow", SD_JSON_BUILD_BOOLEAN(hr->password_change_now)),
+ SD_JSON_BUILD_PAIR_CONDITION(hr->last_password_change_usec != UINT64_MAX, "lastPasswordChangeUSec", SD_JSON_BUILD_UNSIGNED(hr->last_password_change_usec)),
+ SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_min_usec != UINT64_MAX, "passwordChangeMinUSec", SD_JSON_BUILD_UNSIGNED(hr->password_change_min_usec)),
+ SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_max_usec != UINT64_MAX, "passwordChangeMaxUSec", SD_JSON_BUILD_UNSIGNED(hr->password_change_max_usec)),
+ SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_warn_usec != UINT64_MAX, "passwordChangeWarnUSec", SD_JSON_BUILD_UNSIGNED(hr->password_change_warn_usec)),
+ SD_JSON_BUILD_PAIR_CONDITION(hr->password_change_inactive_usec != UINT64_MAX, "passwordChangeInactiveUSec", SD_JSON_BUILD_UNSIGNED(hr->password_change_inactive_usec)));
if (r < 0)
return r;
@@ -319,12 +319,13 @@ int nss_group_to_group_record(
return r;
}
- r = sd_json_build(&g->json, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(g->group_name)),
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(g->gid)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(g->members), "members", SD_JSON_BUILD_STRV(g->members)),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(g->hashed_password), "privileged", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRV(g->hashed_password)))),
- SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(g->administrators), "administrators", SD_JSON_BUILD_STRV(g->administrators))));
+ r = sd_json_buildo(
+ &g->json,
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(g->group_name)),
+ SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(g->gid)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(g->members), "members", SD_JSON_BUILD_STRV(g->members)),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(g->hashed_password), "privileged", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRV(g->hashed_password)))),
+ SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(g->administrators), "administrators", SD_JSON_BUILD_STRV(g->administrators)));
if (r < 0)
return r;
diff --git a/src/shared/userdb.c b/src/shared/userdb.c
index dca79cc735..2eff470ec9 100644
--- a/src/shared/userdb.c
+++ b/src/shared/userdb.c
@@ -618,8 +618,7 @@ int userdb_by_name(const char *name, UserDBFlags flags, UserRecord **ret) {
if (!valid_user_group_name(name, VALID_USER_RELAX))
return -EINVAL;
- r = sd_json_build(&query, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(name))));
+ r = sd_json_buildo(&query, SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(name)));
if (r < 0)
return r;
@@ -671,8 +670,7 @@ int userdb_by_uid(uid_t uid, UserDBFlags flags, UserRecord **ret) {
if (!uid_is_valid(uid))
return -EINVAL;
- r = sd_json_build(&query, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid))));
+ r = sd_json_buildo(&query, SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)));
if (r < 0)
return r;
@@ -891,8 +889,7 @@ int groupdb_by_name(const char *name, UserDBFlags flags, GroupRecord **ret) {
if (!valid_user_group_name(name, VALID_USER_RELAX))
return -EINVAL;
- r = sd_json_build(&query, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(name))));
+ r = sd_json_buildo(&query, SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(name)));
if (r < 0)
return r;
@@ -942,8 +939,7 @@ int groupdb_by_gid(gid_t gid, UserDBFlags flags, GroupRecord **ret) {
if (!gid_is_valid(gid))
return -EINVAL;
- r = sd_json_build(&query, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid))));
+ r = sd_json_buildo(&query, SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)));
if (r < 0)
return r;
@@ -1150,8 +1146,7 @@ int membershipdb_by_user(const char *name, UserDBFlags flags, UserDBIterator **r
if (!valid_user_group_name(name, VALID_USER_RELAX))
return -EINVAL;
- r = sd_json_build(&query, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(name))));
+ r = sd_json_buildo(&query, SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(name)));
if (r < 0)
return r;
@@ -1196,8 +1191,7 @@ int membershipdb_by_group(const char *name, UserDBFlags flags, UserDBIterator **
if (!valid_user_group_name(name, VALID_USER_RELAX))
return -EINVAL;
- r = sd_json_build(&query, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(name))));
+ r = sd_json_buildo(&query, SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(name)));
if (r < 0)
return r;
diff --git a/src/shared/varlink.c b/src/shared/varlink.c
index 51d2b635ca..8329f39021 100644
--- a/src/shared/varlink.c
+++ b/src/shared/varlink.c
@@ -1308,12 +1308,13 @@ static int generic_method_get_info(
strv_sort(interfaces);
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("vendor", "The systemd Project"),
- SD_JSON_BUILD_PAIR_STRING("product", product),
- SD_JSON_BUILD_PAIR_STRING("version", PROJECT_VERSION_FULL " (" GIT_VERSION ")"),
- SD_JSON_BUILD_PAIR_STRING("url", "https://systemd.io/"),
- SD_JSON_BUILD_PAIR_STRV("interfaces", interfaces)));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR_STRING("vendor", "The systemd Project"),
+ SD_JSON_BUILD_PAIR_STRING("product", product),
+ SD_JSON_BUILD_PAIR_STRING("version", PROJECT_VERSION_FULL " (" GIT_VERSION ")"),
+ SD_JSON_BUILD_PAIR_STRING("url", "https://systemd.io/"),
+ SD_JSON_BUILD_PAIR_STRV("interfaces", interfaces));
}
static int generic_method_get_interface_description(
@@ -1339,17 +1340,18 @@ static int generic_method_get_interface_description(
interface = hashmap_get(ASSERT_PTR(link->server)->interfaces, name);
if (!interface)
- return varlink_errorb(link, VARLINK_ERROR_INTERFACE_NOT_FOUND,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("interface", name)));
+ return varlink_errorbo(
+ link,
+ VARLINK_ERROR_INTERFACE_NOT_FOUND,
+ SD_JSON_BUILD_PAIR_STRING("interface", name));
r = varlink_idl_format(interface, &text);
if (r < 0)
return r;
- return varlink_replyb(link,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("description", text)));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR_STRING("description", text));
}
static int varlink_dispatch_method(Varlink *v) {
@@ -1475,7 +1477,7 @@ static int varlink_dispatch_method(Varlink *v) {
}
}
} else if (IN_SET(v->state, VARLINK_PROCESSING_METHOD, VARLINK_PROCESSING_METHOD_MORE)) {
- r = varlink_errorb(v, VARLINK_ERROR_METHOD_NOT_FOUND, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method))));
+ r = varlink_errorbo(v, VARLINK_ERROR_METHOD_NOT_FOUND, SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)));
if (r < 0)
return r;
}
@@ -2025,10 +2027,11 @@ int varlink_send(Varlink *v, const char *method, sd_json_variant *parameters) {
if (r < 0)
return varlink_log_errno(v, r, "Failed to sanitize parameters: %m");
- r = sd_json_build(&m, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
- SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)),
- SD_JSON_BUILD_PAIR("oneway", SD_JSON_BUILD_BOOLEAN(true))));
+ r = sd_json_buildo(
+ &m,
+ SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
+ SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)),
+ SD_JSON_BUILD_PAIR("oneway", SD_JSON_BUILD_BOOLEAN(true)));
if (r < 0)
return varlink_log_errno(v, r, "Failed to build json message: %m");
@@ -2076,9 +2079,10 @@ int varlink_invoke(Varlink *v, const char *method, sd_json_variant *parameters)
if (r < 0)
return varlink_log_errno(v, r, "Failed to sanitize parameters: %m");
- r = sd_json_build(&m, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
- SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters))));
+ r = sd_json_buildo(
+ &m,
+ SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
+ SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)));
if (r < 0)
return varlink_log_errno(v, r, "Failed to build json message: %m");
@@ -2129,10 +2133,11 @@ int varlink_observe(Varlink *v, const char *method, sd_json_variant *parameters)
if (r < 0)
return varlink_log_errno(v, r, "Failed to sanitize parameters: %m");
- r = sd_json_build(&m, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
- SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)),
- SD_JSON_BUILD_PAIR("more", SD_JSON_BUILD_BOOLEAN(true))));
+ r = sd_json_buildo(
+ &m,
+ SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
+ SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)),
+ SD_JSON_BUILD_PAIR("more", SD_JSON_BUILD_BOOLEAN(true)));
if (r < 0)
return varlink_log_errno(v, r, "Failed to build json message: %m");
@@ -2193,9 +2198,10 @@ int varlink_call_full(
if (r < 0)
return varlink_log_errno(v, r, "Failed to sanitize parameters: %m");
- r = sd_json_build(&m, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
- SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters))));
+ r = sd_json_buildo(
+ &m,
+ SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
+ SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)));
if (r < 0)
return varlink_log_errno(v, r, "Failed to build json message: %m");
@@ -2355,10 +2361,11 @@ int varlink_collect_full(
if (r < 0)
return varlink_log_errno(v, r, "Failed to sanitize parameters: %m");
- r = sd_json_build(&m, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
- SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)),
- SD_JSON_BUILD_PAIR("more", SD_JSON_BUILD_BOOLEAN(true))));
+ r = sd_json_buildo(
+ &m,
+ SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)),
+ SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)),
+ SD_JSON_BUILD_PAIR("more", SD_JSON_BUILD_BOOLEAN(true)));
if (r < 0)
return varlink_log_errno(v, r, "Failed to build json message: %m");
@@ -2492,7 +2499,7 @@ int varlink_reply(Varlink *v, sd_json_variant *parameters) {
if (r < 0)
return varlink_log_errno(v, r, "Failed to sanitize parameters: %m");
- r = sd_json_build(&m, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters))));
+ r = sd_json_buildo(&m, SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)));
if (r < 0)
return varlink_log_errno(v, r, "Failed to build json message: %m");
@@ -2566,9 +2573,10 @@ int varlink_error(Varlink *v, const char *error_id, sd_json_variant *parameters)
if (r < 0)
return varlink_log_errno(v, r, "Failed to sanitize parameters: %m");
- r = sd_json_build(&m, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("error", SD_JSON_BUILD_STRING(error_id)),
- SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters))));
+ r = sd_json_buildo(
+ &m,
+ SD_JSON_BUILD_PAIR("error", SD_JSON_BUILD_STRING(error_id)),
+ SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)));
if (r < 0)
return varlink_log_errno(v, r, "Failed to build json message: %m");
@@ -2633,9 +2641,7 @@ int varlink_error_invalid_parameter(Varlink *v, sd_json_variant *parameters) {
if (sd_json_variant_is_string(parameters)) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *parameters_obj = NULL;
- r = sd_json_build(&parameters_obj,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_VARIANT(parameters))));
+ r = sd_json_buildo(&parameters_obj,SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_VARIANT(parameters)));
if (r < 0)
return r;
@@ -2646,9 +2652,7 @@ int varlink_error_invalid_parameter(Varlink *v, sd_json_variant *parameters) {
sd_json_variant_elements(parameters) > 0) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *parameters_obj = NULL;
- r = sd_json_build(&parameters_obj,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_VARIANT(sd_json_variant_by_index(parameters, 0)))));
+ r = sd_json_buildo(&parameters_obj, SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_VARIANT(sd_json_variant_by_index(parameters, 0))));
if (r < 0)
return r;
@@ -2659,17 +2663,17 @@ int varlink_error_invalid_parameter(Varlink *v, sd_json_variant *parameters) {
}
int varlink_error_invalid_parameter_name(Varlink *v, const char *name) {
- return varlink_errorb(
+ return varlink_errorbo(
v,
VARLINK_ERROR_INVALID_PARAMETER,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_STRING(name))));
+ SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_STRING(name)));
}
int varlink_error_errno(Varlink *v, int error) {
- return varlink_errorb(
+ return varlink_errorbo(
v,
VARLINK_ERROR_SYSTEM,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("errno", SD_JSON_BUILD_INTEGER(abs(error)))));
+ SD_JSON_BUILD_PAIR("errno", SD_JSON_BUILD_INTEGER(abs(error))));
}
int varlink_notify(Varlink *v, sd_json_variant *parameters) {
@@ -2693,9 +2697,10 @@ int varlink_notify(Varlink *v, sd_json_variant *parameters) {
if (r < 0)
return varlink_log_errno(v, r, "Failed to sanitize parameters: %m");
- r = sd_json_build(&m, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)),
- SD_JSON_BUILD_PAIR("continues", SD_JSON_BUILD_BOOLEAN(true))));
+ r = sd_json_buildo(
+ &m,
+ SD_JSON_BUILD_PAIR("parameters", SD_JSON_BUILD_VARIANT(parameters)),
+ SD_JSON_BUILD_PAIR("continues", SD_JSON_BUILD_BOOLEAN(true)));
if (r < 0)
return varlink_log_errno(v, r, "Failed to build json message: %m");
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 1bdb3a5f79..d8491ca7b3 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -98,14 +98,15 @@ static int write_efi_hibernate_location(const HibernationDevice *hibernation_dev
if (r < 0)
log_full_errno(log_level_ignore, r, "Failed to parse os-release, ignoring: %m");
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_UUID("uuid", uuid),
- SD_JSON_BUILD_PAIR_UNSIGNED("offset", hibernation_device->offset),
- SD_JSON_BUILD_PAIR_CONDITION(!isempty(uts.release), "kernelVersion", SD_JSON_BUILD_STRING(uts.release)),
- SD_JSON_BUILD_PAIR_CONDITION(!!id, "osReleaseId", SD_JSON_BUILD_STRING(id)),
- SD_JSON_BUILD_PAIR_CONDITION(!!image_id, "osReleaseImageId", SD_JSON_BUILD_STRING(image_id)),
- SD_JSON_BUILD_PAIR_CONDITION(!!version_id, "osReleaseVersionId", SD_JSON_BUILD_STRING(version_id)),
- SD_JSON_BUILD_PAIR_CONDITION(!!image_version, "osReleaseImageVersion", SD_JSON_BUILD_STRING(image_version))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR_UUID("uuid", uuid),
+ SD_JSON_BUILD_PAIR_UNSIGNED("offset", hibernation_device->offset),
+ SD_JSON_BUILD_PAIR_CONDITION(!isempty(uts.release), "kernelVersion", SD_JSON_BUILD_STRING(uts.release)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!id, "osReleaseId", SD_JSON_BUILD_STRING(id)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!image_id, "osReleaseImageId", SD_JSON_BUILD_STRING(image_id)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!version_id, "osReleaseVersionId", SD_JSON_BUILD_STRING(version_id)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!image_version, "osReleaseImageVersion", SD_JSON_BUILD_STRING(image_version)));
if (r < 0)
return log_full_errno(log_level, r, "Failed to build JSON object: %m");
diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c
index e5aa86c88c..3dc966a61e 100644
--- a/src/sysext/sysext.c
+++ b/src/sysext/sysext.c
@@ -1968,7 +1968,7 @@ static int vl_method_merge(Varlink *link, sd_json_variant *parameters, VarlinkMe
if (r < 0)
return r;
if (r > 0)
- return varlink_errorb(link, "io.systemd.sysext.AlreadyMerged", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_STRING("hierarchy", which)));
+ return varlink_errorbo(link, "io.systemd.sysext.AlreadyMerged", SD_JSON_BUILD_PAIR_STRING("hierarchy", which));
r = merge(image_class,
hierarchies ?: arg_hierarchies,
diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c
index b2013bf80d..9a7aab3857 100644
--- a/src/userdb/userdbctl.c
+++ b/src/userdb/userdbctl.c
@@ -782,9 +782,10 @@ static int show_membership(const char *user, const char *group, Table *table) {
case OUTPUT_JSON: {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
- r = sd_json_build(&v, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("user", SD_JSON_BUILD_STRING(user)),
- SD_JSON_BUILD_PAIR("group", SD_JSON_BUILD_STRING(group))));
+ r = sd_json_buildo(
+ &v,
+ SD_JSON_BUILD_PAIR("user", SD_JSON_BUILD_STRING(user)),
+ SD_JSON_BUILD_PAIR("group", SD_JSON_BUILD_STRING(group)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
diff --git a/src/userdb/userwork.c b/src/userdb/userwork.c
index d8f4e0f634..8257acc473 100644
--- a/src/userdb/userwork.c
+++ b/src/userdb/userwork.c
@@ -108,9 +108,10 @@ static int build_user_json(Varlink *link, UserRecord *ur, sd_json_variant **ret)
if (r < 0)
return r;
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)),
- SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(stripped->incomplete))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)),
+ SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(stripped->incomplete)));
}
static int userdb_flags_from_service(Varlink *link, const char *service, UserDBFlags *ret) {
@@ -260,9 +261,10 @@ static int build_group_json(Varlink *link, GroupRecord *gr, sd_json_variant **re
if (r < 0)
return r;
- return sd_json_build(ret, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)),
- SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(stripped->incomplete))));
+ return sd_json_buildo(
+ ret,
+ SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v)),
+ SD_JSON_BUILD_PAIR("incomplete", SD_JSON_BUILD_BOOLEAN(stripped->incomplete)));
}
static int vl_method_get_group_record(Varlink *link, sd_json_variant *parameters, VarlinkMethodFlags flags, void *userdata) {
@@ -402,9 +404,10 @@ static int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters,
if (last_user_name) {
assert(last_group_name);
- r = varlink_notifyb(link, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name))));
+ r = varlink_notifybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name)));
if (r < 0)
return r;
}
@@ -420,9 +423,10 @@ static int vl_method_get_memberships(Varlink *link, sd_json_variant *parameters,
assert(last_group_name);
- return varlink_replyb(link, SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
- SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name))));
+ return varlink_replybo(
+ link,
+ SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last_user_name)),
+ SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last_group_name)));
}
static int process_connection(VarlinkServer *server, int _fd) {
diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c
index fe5080dd43..02caf218e7 100644
--- a/src/varlinkctl/varlinkctl.c
+++ b/src/varlinkctl/varlinkctl.c
@@ -347,11 +347,11 @@ static int verb_introspect(int argc, char *argv[], void *userdata) {
STRV_FOREACH(i, interfaces) {
sd_json_variant *reply = NULL;
- r = varlink_callb_and_log(
+ r = varlink_callbo_and_log(
vl,
"org.varlink.service.GetInterfaceDescription",
&reply,
- SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_STRING("interface", *i)));
+ SD_JSON_BUILD_PAIR_STRING("interface", *i));
if (r < 0)
return r;
diff --git a/src/vmspawn/vmspawn-register.c b/src/vmspawn/vmspawn-register.c
index b0b1c60a44..2140bba9cd 100644
--- a/src/vmspawn/vmspawn-register.c
+++ b/src/vmspawn/vmspawn-register.c
@@ -59,18 +59,18 @@ int register_machine(
if (r < 0)
return log_error_errno(r, "Failed to connect to machined on /run/systemd/machine/io.systemd.Machine: %m");
- return varlink_callb_and_log(vl,
+ return varlink_callbo_and_log(
+ vl,
"io.systemd.Machine.Register",
- NULL,
- SD_JSON_BUILD_OBJECT(
- SD_JSON_BUILD_PAIR_STRING("name", machine_name),
- SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(uuid), "id", SD_JSON_BUILD_ID128(uuid)),
- SD_JSON_BUILD_PAIR_STRING("service", service),
- SD_JSON_BUILD_PAIR_STRING("class", "vm"),
- SD_JSON_BUILD_PAIR_CONDITION(VSOCK_CID_IS_REGULAR(cid), "vSockCid", SD_JSON_BUILD_UNSIGNED(cid)),
- SD_JSON_BUILD_PAIR_CONDITION(!!directory, "rootDirectory", SD_JSON_BUILD_STRING(directory)),
- SD_JSON_BUILD_PAIR_CONDITION(!!address, "sshAddress", SD_JSON_BUILD_STRING(address)),
- SD_JSON_BUILD_PAIR_CONDITION(!!key_path, "sshPrivateKeyPath", SD_JSON_BUILD_STRING(key_path))));
+ /* ret_reply= */ NULL,
+ SD_JSON_BUILD_PAIR_STRING("name", machine_name),
+ SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(uuid), "id", SD_JSON_BUILD_ID128(uuid)),
+ SD_JSON_BUILD_PAIR_STRING("service", service),
+ SD_JSON_BUILD_PAIR_STRING("class", "vm"),
+ SD_JSON_BUILD_PAIR_CONDITION(VSOCK_CID_IS_REGULAR(cid), "vSockCid", SD_JSON_BUILD_UNSIGNED(cid)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!directory, "rootDirectory", SD_JSON_BUILD_STRING(directory)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!address, "sshAddress", SD_JSON_BUILD_STRING(address)),
+ SD_JSON_BUILD_PAIR_CONDITION(!!key_path, "sshPrivateKeyPath", SD_JSON_BUILD_STRING(key_path)));
}
int unregister_machine(sd_bus *bus, const char *machine_name) {