mirror of
https://github.com/systemd/systemd.git
synced 2025-05-27 21:05:55 +03:00
user-util: move homed/nspawn map UID_MIN/UID_MAX define into user-util.h
Let's have them at a common place, so that we have the ranges altogether at a minimal set of places.
This commit is contained in:
parent
fc03e80c6b
commit
76ef5d0493
@ -12,6 +12,14 @@
|
||||
#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) {
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user