1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include <stdbool.h>
5 #include <sys/types.h>
6 
7 bool uid_is_system(uid_t uid);
8 bool gid_is_system(gid_t gid);
9 
uid_is_dynamic(uid_t uid)10 static inline bool uid_is_dynamic(uid_t uid) {
11         return DYNAMIC_UID_MIN <= uid && uid <= DYNAMIC_UID_MAX;
12 }
13 
gid_is_dynamic(gid_t gid)14 static inline bool gid_is_dynamic(gid_t gid) {
15         return uid_is_dynamic((uid_t) gid);
16 }
17 
uid_is_container(uid_t uid)18 static inline bool uid_is_container(uid_t uid) {
19         return CONTAINER_UID_BASE_MIN <= uid && uid <= CONTAINER_UID_BASE_MAX;
20 }
21 
gid_is_container(gid_t gid)22 static inline bool gid_is_container(gid_t gid) {
23         return uid_is_container((uid_t) gid);
24 }
25 
26 typedef struct UGIDAllocationRange {
27         uid_t system_alloc_uid_min;
28         uid_t system_uid_max;
29         gid_t system_alloc_gid_min;
30         gid_t system_gid_max;
31 } UGIDAllocationRange;
32 
33 int read_login_defs(UGIDAllocationRange *ret_defs, const char *path, const char *root);
34 const UGIDAllocationRange *acquire_ugid_allocation_range(void);
35