]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nsresourced: clear up some type confusion
authorLennart Poettering <lennart@poettering.net>
Sun, 9 Mar 2025 07:09:40 +0000 (08:09 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 10 Mar 2025 15:41:38 +0000 (16:41 +0100)
We settle on the types the backend implementation in
userns-registry.[ch] uses too. i.e. uid_t/gid_t for the bases, and
uint32_t for the uid range sizes.

src/nsresourced/nsresourcework.c

index 36deba7b9c3983400a7b9af045e41076652dfd0e..5d1608a13f2f2aa3dc50c5a901fb25ae8d50fb37 100644 (file)
@@ -713,7 +713,7 @@ static int validate_name(sd_varlink *link, const char *name, bool mangle, char *
         return 0;
 }
 
-static int validate_target_and_size(sd_varlink *link, unsigned target, unsigned size) {
+static int validate_target_and_size(sd_varlink *link, uid_t target, uint32_t size) {
         assert(link);
 
         if (!IN_SET(size, 1U, 0x10000))
@@ -794,8 +794,8 @@ static int validate_userns_is_empty(sd_varlink *link, int userns_fd) {
 
 typedef struct AllocateParameters {
         const char *name;
-        unsigned size;
-        unsigned target;
+        uint32_t size;
+        uid_t target;
         unsigned userns_fd_idx;
         bool mangle_name;
 } AllocateParameters;
@@ -804,8 +804,8 @@ static int vl_method_allocate_user_range(sd_varlink *link, sd_json_variant *para
 
         static const sd_json_dispatch_field dispatch_table[] = {
                 { "name",                        SD_JSON_VARIANT_STRING,        sd_json_dispatch_const_string, offsetof(AllocateParameters, name),          SD_JSON_MANDATORY },
-                { "size",                        _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint,         offsetof(AllocateParameters, size),          SD_JSON_MANDATORY },
-                { "target",                      _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint,         offsetof(AllocateParameters, target),        0                 },
+                { "size",                        _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint32,       offsetof(AllocateParameters, size),          SD_JSON_MANDATORY },
+                { "target",                      _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uid_gid,      offsetof(AllocateParameters, target),        0                 },
                 { "userNamespaceFileDescriptor", _SD_JSON_VARIANT_TYPE_INVALID, sd_json_dispatch_uint,         offsetof(AllocateParameters, userns_fd_idx), SD_JSON_MANDATORY },
                 { "mangleName",                  SD_JSON_VARIANT_BOOLEAN,       sd_json_dispatch_stdbool,      offsetof(AllocateParameters, mangle_name),   0                 },
                 {}
@@ -817,7 +817,7 @@ static int vl_method_allocate_user_range(sd_varlink *link, sd_json_variant *para
         uid_t peer_uid;
         struct stat userns_st;
         AllocateParameters p = {
-                .size = UINT_MAX,
+                .size = UINT32_MAX,
                 .userns_fd_idx = UINT_MAX,
         };
         int r;