char path[PATH_MAX];
int r;
- // XXX hard-coded values
- const uid_t mapped_uid = 100000;
- const size_t length = 64536;
+ uid_t mapped_uid = 0;
+ const size_t length = 1;
+
+ // Fetch the UID of the calling process
+ uid_t uid = getuid();
+
+ // Have we been called by root?
+ if (uid == 0) {
+ mapped_uid = 0;
+
+ // Have we been called by an unprivileged user?
+ } else {
+ // XXX fetch SUBUID
+ mapped_uid = uid;
+ }
// Make path
r = pakfire_string_format(path, "/proc/%d/uid_map", pid);
char path[PATH_MAX];
int r;
- // XXX hard-coded values
- const uid_t mapped_gid = 100000;
- const size_t length = 64536;
+ gid_t mapped_gid = 0;
+ const size_t length = 1;
+
+ // Fetch the GID of the calling process
+ gid_t gid = getgid();
+
+ // Have we been called from the root group?
+ if (gid == 0) {
+ mapped_gid = 0;
+
+ // Have we been called by an unprivileged group?
+ } else {
+ // XXX fetch SUBGID
+ mapped_gid = gid;
+ }
// Make path
r = pakfire_string_format(path, "/proc/%d/gid_map", pid);