]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
userdb: add support for printing the UUID from user and group records 37024/head
authorErin Shepherd <erin.shepherd@e43.eu>
Tue, 8 Apr 2025 12:07:46 +0000 (12:07 +0000)
committerErin Shepherd <erin.shepherd@e43.eu>
Tue, 8 Apr 2025 12:07:46 +0000 (12:07 +0000)
src/shared/group-record.c
src/shared/group-record.h
src/shared/user-record-show.c
src/shared/user-record.c
src/shared/user-record.h

index d4acc1a2620cb4f3f0631e1c72cd9e1bd723a53f..db3b96d3ec1fe20395cb257bee6f6834dda4687a 100644 (file)
@@ -174,6 +174,7 @@ int group_record_load(
         static const sd_json_dispatch_field group_dispatch_table[] = {
                 { "groupName",      SD_JSON_VARIANT_STRING,        json_dispatch_user_group_name,  offsetof(GroupRecord, group_name),       SD_JSON_RELAX  },
                 { "realm",          SD_JSON_VARIANT_STRING,        json_dispatch_realm,            offsetof(GroupRecord, realm),            0              },
+                { "uuid",           SD_JSON_VARIANT_STRING,        sd_json_dispatch_id128,         offsetof(GroupRecord, uuid),             0              },
                 { "description",    SD_JSON_VARIANT_STRING,        json_dispatch_gecos,            offsetof(GroupRecord, description),      0              },
                 { "disposition",    SD_JSON_VARIANT_STRING,        json_dispatch_user_disposition, offsetof(GroupRecord, disposition),      0              },
                 { "service",        SD_JSON_VARIANT_STRING,        sd_json_dispatch_string,        offsetof(GroupRecord, service),          SD_JSON_STRICT },
index 95e70cf2694fcb43f2605a7913d0d22e5fff4923..54a08f99eadb7ecedf300dd0915dede3ce042ecb 100644 (file)
@@ -13,6 +13,7 @@ typedef struct GroupRecord {
         char *group_name;
         char *realm;
         char *group_name_and_realm_auto;
+        sd_id128_t uuid;
 
         char *description;
 
index ad0c345bd970356960be734db8dc78648cd01e4c..4f0678bed49622cd00015bda0b8f625228b92b63 100644 (file)
@@ -259,6 +259,9 @@ void user_record_show(UserRecord *hr, bool show_full_group_info) {
                 }
         }
 
+        if (!sd_id128_is_null(hr->uuid))
+                printf("        UUID: " SD_ID128_UUID_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(hr->uuid));
+
         if (hr->real_name && !streq(hr->real_name, hr->user_name))
                 printf("   Real Name: %s\n", hr->real_name);
 
@@ -670,6 +673,9 @@ void group_record_show(GroupRecord *gr, bool show_full_user_info) {
         if (gid_is_valid(gr->gid))
                 printf("         GID: " GID_FMT "\n", gr->gid);
 
+        if (!sd_id128_is_null(gr->uuid))
+                printf("        UUID: " SD_ID128_UUID_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(gr->uuid));
+
         if (show_full_user_info) {
                 _cleanup_(userdb_iterator_freep) UserDBIterator *iterator = NULL;
 
index 63d47ec9b1bc4c37989e0cbbd1cbc9560ab0257f..d99da34654cae8f128b78e41d293fe220bf09cb3 100644 (file)
@@ -1611,6 +1611,7 @@ int user_record_load(UserRecord *h, sd_json_variant *v, UserRecordLoadFlags load
                 { "userName",                   SD_JSON_VARIANT_STRING,        json_dispatch_user_group_name,        offsetof(UserRecord, user_name),                     SD_JSON_RELAX  },
                 { "aliases",                    SD_JSON_VARIANT_ARRAY,         json_dispatch_user_group_list,        offsetof(UserRecord, aliases),                       SD_JSON_RELAX  },
                 { "realm",                      SD_JSON_VARIANT_STRING,        json_dispatch_realm,                  offsetof(UserRecord, realm),                         0              },
+                { "uuid",                       SD_JSON_VARIANT_STRING,        sd_json_dispatch_id128,               offsetof(UserRecord, uuid),                          0              },
                 { "blobDirectory",              SD_JSON_VARIANT_STRING,        json_dispatch_path,                   offsetof(UserRecord, blob_directory),                SD_JSON_STRICT },
                 { "blobManifest",               SD_JSON_VARIANT_OBJECT,        dispatch_blob_manifest,               offsetof(UserRecord, blob_manifest),                 0              },
                 { "realName",                   SD_JSON_VARIANT_STRING,        json_dispatch_gecos,                  offsetof(UserRecord, real_name),                     0              },
index 75f50ae347ea45db371ef0539dbf5baf635788ba..725feba699bcab91758d67567d8450d77ec8f7b9 100644 (file)
@@ -269,6 +269,7 @@ typedef struct UserRecord {
         char *realm;
         char *user_name_and_realm_auto; /* the user_name field concatenated with '@' and the realm, if the latter is defined */
         char **aliases;
+        sd_id128_t uuid;
         char *real_name;
         char *email_address;
         char *password_hint;