Skip to content

Instantly share code, notes, and snippets.

@wanzixyz
wanzixyz / enter-namespace.py
Created March 4, 2017 07:06
enter namespace
#!/usr/bin/env python
#coding=utf-8
import argparse
import ctypes
import os
CLONE_NEWNS = 0x00020000 # /* New mount namespace group */
CLONE_NEWCGROUP = 0x02000000 # /* New cgroup namespace */
@wanzixyz
wanzixyz / list-namespace.py
Last active November 21, 2019 06:28
list namespace
#!/usr/bin/env python
#coding=utf-8
import os
import re
#format: pid, [namespaces], cmdline
def _get_namespace(pid):
path = '/proc/{0}/ns/'.format(pid)
namespaces = []