Re: RFC: avoid chroot() call if not changing root dir
From:
Pádraig Brady
Subject:
Re: RFC: avoid chroot() call if not changing root dir
Date:
Sun, 18 May 2014 17:27:51 +0100
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2
On 05/17/2014 10:40 AM, Pádraig Brady wrote:
> On 05/17/2014 01:03 AM, Bernhard Voelker wrote:
>> On 05/16/2014 11:02 PM, Pádraig Brady wrote:
>>> Pushed.
>>
>> Sorry, a bit late ...
>>
>>> + /* Only do chroot specific actions if actually changing root.
>>> + The main difference here is that we don't change working dir. */
>>> + if (! STREQ (argv[optind], "/"))
>>
>> What about canonicalizing argv[optind] ?
>> Or do we want the ability to force chroot(2) like this:
>>
>> $ src/chroot / env pwd
>> /home/berny/git/coreutils
>>
>> $ src/chroot /. env pwd
>> src/chroot: cannot change root directory to /.: Operation not permitted
>>
>> Probably this might be bit confusing - while some other guys
>> might use this difference to check for superuser privileges ...
>> ... and fall over once we'll fix this.
>
> Yes I wasn't sure about that.
> Better to canonicalize for consistency I suppose.
> If one does want to chdir("/") that can be done externally and inherited.
I'll push the attached later.
thanks,
Pádraig.