]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
user-util: move homed/nspawn map UID_MIN/UID_MAX define into user-util.h
authorLennart Poettering <lennart@poettering.net>
Wed, 16 Feb 2022 13:53:57 +0000 (14:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 16 Feb 2022 21:40:06 +0000 (22:40 +0100)
Let's have them at a common place, so that we have the ranges altogether
at a minimal set of places.

src/basic/user-util.h
src/home/home-util.h
src/nspawn/nspawn-bind-user.c

index bc76de6b4110303eaf397d529d2a40d9a10b8c16..40979d10801cf82282252752ff14ddf53fc636e8 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
+/* Users managed by systemd-homed. See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
+#define HOME_UID_MIN 60001
+#define HOME_UID_MAX 60513
+
+/* Users mapped from host into a container */
+#define MAP_UID_MIN 60514
+#define MAP_UID_MAX 60577
+
 bool uid_is_valid(uid_t uid);
 
 static inline bool gid_is_valid(gid_t gid) {
index 69a88000f8456f26dba3c97752ab80b7f3ebf8f0..36b301d236031c17c7875463ff5831e5d84f4f16 100644 (file)
@@ -8,10 +8,6 @@
 #include "time-util.h"
 #include "user-record.h"
 
-/* See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
-#define HOME_UID_MIN 60001
-#define HOME_UID_MAX 60513
-
 /* Put some limits on disk sizes: not less than 5M, not more than 5T */
 #define USER_DISK_SIZE_MIN (UINT64_C(5)*1024*1024)
 #define USER_DISK_SIZE_MAX (UINT64_C(5)*1024*1024*1024*1024)
index d3113c303e63c28fb20455f480eec4495d963f00..97761cb6f0b913045be5d453da22d1bbbc975c3c 100644 (file)
@@ -10,9 +10,6 @@
 #include "user-util.h"
 #include "userdb.h"
 
-#define MAP_UID_START 60514
-#define MAP_UID_END 60577
-
 static int check_etc_passwd_collisions(
                 const char *directory,
                 const char *name,
@@ -157,11 +154,11 @@ static int find_free_uid(const char *directory, uid_t max_uid, uid_t *current_ui
         assert(current_uid);
 
         for (;; (*current_uid) ++) {
-                if (*current_uid > MAP_UID_END || *current_uid > max_uid)
+                if (*current_uid > MAP_UID_MAX || *current_uid > max_uid)
                         return log_error_errno(
                                         SYNTHETIC_ERRNO(EBUSY),
                                         "No suitable available UID in range " UID_FMT "…" UID_FMT " in container detected, can't map user.",
-                                        MAP_UID_START, MAP_UID_END);
+                                        MAP_UID_MIN, MAP_UID_MAX);
 
                 r = check_etc_passwd_collisions(directory, NULL, *current_uid);
                 if (r < 0)
@@ -202,7 +199,7 @@ int bind_user_prepare(
                 BindUserContext **ret) {
 
         _cleanup_(bind_user_context_freep) BindUserContext *c = NULL;
-        uid_t current_uid = MAP_UID_START;
+        uid_t current_uid = MAP_UID_MIN;
         char **n;
         int r;