return r;
uid_t uid;
- r = uid_map_search_root(pid, "uid_map", &uid);
+ r = uid_map_search_root(pid, UID_RANGE_USERNS_OUTSIDE, &uid);
if (r < 0)
return r;
gid_t gid;
- r = uid_map_search_root(pid, "gid_map", &gid);
+ r = uid_map_search_root(pid, GID_RANGE_USERNS_OUTSIDE, &gid);
if (r < 0)
return r;
return true;
}
-int uid_map_search_root(pid_t pid, const char *filename, uid_t *ret) {
+int uid_map_search_root(pid_t pid, UIDRangeUsernsMode mode, uid_t *ret) {
int r;
assert(pid_is_valid(pid));
- assert(filename);
+ assert(IN_SET(mode, UID_RANGE_USERNS_OUTSIDE, GID_RANGE_USERNS_OUTSIDE));
- const char *p = procfs_file_alloca(pid, filename);
+ const char *p = procfs_file_alloca(pid, mode == UID_RANGE_USERNS_OUTSIDE ? "uid_map" : "gid_map");
_cleanup_fclose_ FILE *f = fopen(p, "re");
if (!f) {
if (errno != ENOENT)
size_t n_entries;
} UIDRange;
-UIDRange *uid_range_free(UIDRange *range);
+UIDRange* uid_range_free(UIDRange *range);
DEFINE_TRIVIAL_CLEANUP_FUNC(UIDRange*, uid_range_free);
int uid_range_add_internal(UIDRange **range, uid_t start, uid_t nr, bool coalesce);
bool uid_range_overlaps(const UIDRange *range, uid_t start, uid_t nr);
-int uid_map_search_root(pid_t pid, const char *filename, uid_t *ret);
+int uid_map_search_root(pid_t pid, UIDRangeUsernsMode mode, uid_t *ret);