uid-range: add new uid_range_load_userns_by_fd() helper

This is similar to uid_range_load_userns() but instead of reading the
uid_map off a process it reads it off a userns fd.

(Of course the kernel has no API for this right now, hence we fork off a
throw-away process which joins the user namespace, and then read off the
data from there.)
This commit is contained in:
Lennart Poettering
2024-04-06 16:08:23 +02:00
parent 6ebb53d945
commit 20ba086e77
2 changed files with 62 additions and 0 deletions
+1
View File
@@ -43,5 +43,6 @@ typedef enum UIDRangeUsernsMode {
} UIDRangeUsernsMode;
int uid_range_load_userns(UIDRange **ret, const char *path, UIDRangeUsernsMode mode);
int uid_range_load_userns_by_fd(int userns_fd, UIDRangeUsernsMode mode, UIDRange **ret);
bool uid_range_overlaps(const UIDRange *range, uid_t start, uid_t nr);