]> snippets.scripts.mit.edu Git - Scripts/git/.git/commit - django/mit/__init__.py
Wrappers for safely calling commands in a new PAG
authorAlex Dehnert <adehnert@mit.edu>
Sun, 16 Sep 2012 01:53:40 +0000 (21:53 -0400)
committerAlex Dehnert <adehnert@mit.edu>
Sun, 16 Sep 2012 01:53:40 +0000 (21:53 -0400)
commit20e2c5bc19c19624fc906a06cca82b4e5ef8c5a3
treefa3d51fbfdf6005b3fb78f9272120e43c66565db
parent6650ee780daad6ce2a35cf8ca8d308b7411b08d8
Wrappers for safely calling commands in a new PAG

The usual mechanism for starting a new PAG is pagsh(1). Unfortunately, because
it basically just execvp(3) /bin/sh passing the appropriate arguments, it isn't
immediately obvious how to safely pass arguments that may contain shell
metacharacters. By using the shell's exec and taking advantage of the fact that
later arguments to /bin/sh end up in $@ we can safely avoid shell
metacharacters. We wrap subprocess.check_{call,output} in
pag_check_{call,output}, which perform appropriate contortions to establish the
PAG before safely executing the passed commands without evaluating any
metacharacters.
__init__.py