On Sat, Aug 26, 2017 at 04:00:11PM -0700, PƔdraig Brady wrote:
> If we were to provide this I think chdir is a fine name.
> It's a pity we have to have this heavy weight chaining of execs like this
> to set each process attribute. This is more general though, than adding
> --chdir to other "context" type programs like chroot etc.
> Note GNU chroot has a --skip-chdir which nearly does what you want.
> I.E. you could os.chdir("/chroot/build") before calling "chroot --skip-dir
> ...",
> however that's currently restricted for greater protection to when
> you're not actually changing the root directory. I suppose we could relax
> the check to verify that getcwd() was _below_ the specified chroot path.
> Of course none of this helps with jexec, lxc etc.
Indeed; I really want something composable rather than playing
whack-a-mole with every possible wrapper command.
> Another option to consider is to add --chdir to env(1) since they
> would often be used together and could be done more efficiently with a single
> exec?
That's a good idea, and I agree they're often used together. I'd
already slipped and implemented chdir(1), but I think that suggestion
may be better: it results in a much shorter patch, and it avoids the
problem with some shells (e.g. zsh) implementing their own "chdir"
built-ins with different semantics.
I've attached both patches; my preference following PƔdraig's suggestion
is the second one ("env: add --chdir option"), but I'd be happy either
way.
If either of these requires a copyright assignment and I don't have one
on file for coreutils, then I'd appreciate it if a maintainer could get
the ball rolling on the necessary paperwork.
Thanks,
--
Colin Watson [address@hidden]