Beispiel #1
0
 def setUp(self):
     super(JailMixin, self).setUp()
     if not jail.is_configured("python"):
         if not self._codejail_venv:
             self._codejail_venv = self._autoconfigure_codejail_venv()
         if not self._codejail_user:
             # User explicitly requested no su user via environment variable
             self._codejail_user = None
         bin_path = os.path.join(self._codejail_venv, 'bin/python2')
         jail.configure("python", bin_path, user=self._codejail_user, lang=languages.python2)
Beispiel #2
0
 def setUp(self):
     super(JailMixin, self).setUp()
     if not jail.is_configured("python"):
         if not self._codejail_venv:
             self._codejail_venv = self._autoconfigure_codejail_venv()
         if not self._codejail_user:
             # User explicitly requested no su user via environment variable
             self._codejail_user = None
         bin_path = os.path.join(self._codejail_venv, 'bin/python2')
         jail.configure("python",
                        bin_path,
                        user=self._codejail_user,
                        lang=languages.python2)
Beispiel #3
0
 def setUp(self):
     super(Python3Mixin, self).setUp()
     for path in ['/usr/bin/python3', '/usr/local/bin/python3']:
         if os.path.exists(path):
             self.python3_jail = jail.configure('python3', path, lang=languages.python3)
             break
     else:  # nobreak
         self.fail("No Python 3 executable found")
Beispiel #4
0
 def setUp(self):
     super(Python3Mixin, self).setUp()
     for path in ['/usr/bin/python3', '/usr/local/bin/python3']:
         if os.path.exists(path):
             self.python3_jail = jail.configure('python3',
                                                path,
                                                lang=languages.python3)
             break
     else:  # nobreak
         self.fail("No Python 3 executable found")
Beispiel #5
0
def override_configuration(command, bin_path=SAME, user=SAME, lang=SAME):
    """
    Context manager to temporarily alter the configuration of a codejail
    command.
    """
    old = jail.COMMANDS.get(command)
    if bin_path is SAME:
        bin_path = old.bin_path
    if user is SAME:
        user = old.user
    if lang is SAME:
        lang = old.lang
    try:
        jail.configure(command, bin_path, user, lang)
        yield
    finally:
        if old is None:
            del jail.COMMANDS[command]
        else:
            jail.COMMANDS[command] = old
Beispiel #6
0
def override_configuration(command, bin_path=SAME, user=SAME, lang=SAME):
    """
    Context manager to temporarily alter the configuration of a codejail
    command.
    """
    old = jail.COMMANDS.get(command)
    if bin_path is SAME:
        bin_path = old.bin_path
    if user is SAME:
        user = old.user
    if lang is SAME:
        lang = old.lang
    try:
        jail.configure(command, bin_path, user, lang)
        yield
    finally:
        if old is None:
            del jail.COMMANDS[command]
        else:
            jail.COMMANDS[command] = old