Skip to content

Instantly share code, notes, and snippets.

@aishek
Created February 27, 2018 08:36
Show Gist options
  • Save aishek/1ce9e002f4ef5148e2de4451357231b5 to your computer and use it in GitHub Desktop.
Save aishek/1ce9e002f4ef5148e2de4451357231b5 to your computer and use it in GitHub Desktop.
#define _GNU_SOURCE
#include <sched.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/wait.h>
int main() {
unshare(CLONE_NEWIPC | CLONE_NEWNS | CLONE_NEWNET | CLONE_NEWPID | CLONE_NEWUTS);
if(fork()) {
wait(NULL);
return 0;
}
umount("/proc");
mount("proc", "/proc", "proc", 0, 0);
execl("/bin/bash", "/bin/bash", NULL);
}
// gcc unshare.c -o unshare
// ./unshare
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment