Skip to content

Instantly share code, notes, and snippets.

@cgwalters
Created April 7, 2015 14:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cgwalters/1aa68b1b9642496f30f8 to your computer and use it in GitHub Desktop.
Save cgwalters/1aa68b1b9642496f30f8 to your computer and use it in GitHub Desktop.
python setns
#!/usr/bin/env python
import ctypes
import sys
import os
import subprocess
f = None
libc = ctypes.CDLL('libc.so.6')
myfd = os.open('/proc/1/ns/mnt', os.O_RDONLY)
libc.setns(myfd, 0)
subprocess.Popen(['ls', '/home'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment