Created
March 10, 2020 20:14
-
-
Save mkenigs/e92e5942182b984ff1fdec95eccfbf9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
#include <sched.h> | |
#include <signal.h> | |
#include <sys/wait.h> | |
#include <sys/types.h> | |
static int childFunc(void *arg) | |
{ | |
printf("UID inside the namespace is %ld\n", (long)geteuid()); | |
printf("GID inside the namespace is %ld\n", (long)getegid()); | |
return 0; | |
} | |
static char child_stack[1024*1024]; | |
int main(int argc, char *argv[]) | |
{ | |
pid_t child_pid; | |
child_pid = clone(&childFunc, child_stack + (1024*1024), CLONE_NEWUSER, 0); | |
printf("UID outside the namespace is %ld\n", (long)geteuid()); | |
printf("GID outside the namespace is %ld\n", (long)getegid()); | |
waitpid(child_pid, NULL, 0); | |
exit(EXIT_SUCCESS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment