Skip to content

Instantly share code, notes, and snippets.

View ig0rmin's full-sized avatar

Igor Minin ig0rmin

View GitHub Profile
@ig0rmin
ig0rmin / mount_namespace_sudo.c
Created January 30, 2024 20:49
Clone a process into a new mount namespace and pivot root to a given directory
// This example demonstrates creating mount namespace and using pivot_root()
// It doesn't create a user namespace, so to run it we need sudo
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <sched.h>
#include <limits.h>
#include <errno.h>
#include <unistd.h>
@ig0rmin
ig0rmin / user_namespace.c
Created January 30, 2024 20:31
Clone a process into a new user namespace
#define _GNU_SOURCE
#include <sched.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <sched.h>
@ig0rmin
ig0rmin / clone_vm.c
Last active January 30, 2024 19:54
Create a child and parent process that share the same virtual memory
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sched.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#!/usr/bin/python
import sys
import re
import os.path
def print_help():
print "Usage: %s time.txt source.mvk" % (sys.argv[0])
#include <condition_variable>
#include <future>
#include <iostream>
#include <string>
#include <mutex>
#include <thread>
#include <vector>
using namespace std;