CodethinkLabs / sandboxlib

Sandboxing library
8 stars 4 forks source link

sandboxlib: Allow `None` stdout/stderr to retain forwarding #13

Open fishface60 opened 8 years ago

fishface60 commented 8 years ago

I couldn't work out a way to make sandboxlib let me keep my stdout/stderr otherwise. I'm not a fan of changing the default behaviour of this, especially without a documented way to preserve it.

ssssam commented 8 years ago

There is a documented way to do this already, see: https://github.com/CodethinkLabs/sandboxlib/blob/master/sandboxlib/__init__.py#L100. It's hard to find because there's no documentation generated from this source yet.

I think it's bad design to make the user 'opt out' of inheriting the parent file descriptions -- it should be 'opt in' if we are trying to sandbox things. I know it's different from how subprocess.Popen() works and that needs to be clear.

richardmaw-codethink commented 8 years ago

On Wed, Nov 25, 2015 at 02:52:34AM -0800, Sam Thursfield wrote:

There is a documented way to do this already, see: https://github.com/CodethinkLabs/sandboxlib/blob/master/sandboxlib/__init__.py#L100. It's hard to find because there's no documentation generated from this source yet.

I think it's bad design to make the user 'opt out' of inheriting the parent file descriptions -- it should be 'opt in' if we are trying to sandbox things. I know it's different from how subprocess.Popen() works and that needs to be clear.

You already need to opt-into not inheriting file descriptors by virtue of the fact that you have changed the default value to CAPTURE.

By forcing None to mean devnull this makes subprocess.Popen have to do a lot more work to shuffle file descriptors, and makes it more difficult to allow file descriptor inheritance for reasons I don't find compelling.