Skip to content

Instantly share code, notes, and snippets.

@KillerGoldFisch
Created January 4, 2015 19:26
Show Gist options
  • Select an option

  • Save KillerGoldFisch/e176b703e8fc68f75493 to your computer and use it in GitHub Desktop.

Select an option

Save KillerGoldFisch/e176b703e8fc68f75493 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# This Module is a wrapper for the gentoo sandbox tool.
# For Debian based systems take a look at https://wiki.debian.org/Sandbox
import subprocess, os
def addto(varname, value):
tmpval = ""
#if varname in os.environ:
# tmpval += os.environ + ":"
tmpval += ":".join(value)
os.environ[varname] = tmpval
def startsandbox(cmd, deny=[], write=[], read=[], predict=[]):
addto("SANDBOX_DENY", deny)
addto("SANDBOX_WRITE", write)
addto("SANDBOX_READ", read)
addto("SANDBOX_PREDICT", predict)
cmd = "sandbox \"" + " ".join(cmd) + "\""
print "Run in Sandbox: " + cmd
subprocess.call(cmd , shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment