diff options
author | Lennart Poettering <lennart@poettering.net> | 2024-06-18 17:08:49 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2024-06-19 22:50:02 +0200 |
commit | be5bee2a132d2d3b45d79bb3f27b05bbc767cd0a (patch) | |
tree | 7bf23c1e6ecb5289bbbb44e6e7492f764a4340bb /src/home | |
parent | sd-json: add sd_json_build() wrapper macro that implies SD_JSON_BUILD_OBJECT() (diff) | |
download | systemd-be5bee2a132d2d3b45d79bb3f27b05bbc767cd0a.tar.xz systemd-be5bee2a132d2d3b45d79bb3f27b05bbc767cd0a.zip |
tree-wide: port over to new builder apis
Diffstat (limited to 'src/home')
-rw-r--r-- | src/home/homectl-fido2.c | 14 | ||||
-rw-r--r-- | src/home/homectl-pkcs11.c | 8 | ||||
-rw-r--r-- | src/home/homectl-recovery-key.c | 5 | ||||
-rw-r--r-- | src/home/homectl.c | 7 | ||||
-rw-r--r-- | src/home/homed-bus.c | 2 | ||||
-rw-r--r-- | src/home/homed-home.c | 30 | ||||
-rw-r--r-- | src/home/homed-varlink.c | 52 | ||||
-rw-r--r-- | src/home/homework-luks.c | 12 | ||||
-rw-r--r-- | src/home/user-record-util.c | 78 |
9 files changed, 108 insertions, 100 deletions
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; |