diff options
author | lns <matzeton@googlemail.com> | 2018-05-15 19:11:00 +0200 |
---|---|---|
committer | lns <matzeton@googlemail.com> | 2018-05-15 19:11:00 +0200 |
commit | 813b4e3e5fc16a69c35bfcd1c4eba248c11f3e7c (patch) | |
tree | 0a5589ebe5c44d4d0487d0b338e8baeac2819cd7 /src/utils.c | |
parent | 58d2689b9b43dfd4341b2eb227c51d89d873b35e (diff) |
POTD skeleton #55.
Signed-off-by: lns <matzeton@googlemail.com>
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c index bcca9c3..69fcb0e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -386,3 +386,21 @@ int create_device_files(const char *mount_path) return s; } + +int update_uid_map(pid_t pid, unsigned int uid_map[3]) +{ + int s; + const char *const path_pid = "/proc/%d/uid_map"; + const char *const path_self = "/proc/self/uid_map"; + char path[32]; + + if (pid < 0) { + s = snprintf(path, sizeof path, "%s", path_self); + } else { + s = snprintf(path, sizeof path, path_pid, pid); + } + if (s <= 0) + return 1; + + return 0; +} |