Re: [PATCH 1/2] unshare: allow to set a new root

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le 04/10/2018 à 12:11, Karel Zak a écrit :
> On Fri, Sep 28, 2018 at 02:45:11PM +0200, Laurent Vivier wrote:
>> +	if (newroot) {
>> +		if (chroot(newroot) != 0)
>> +			err(EXIT_FAILURE,
>> +			    _("cannot change root directory to '%s'"), newroot);
>> +		if (chdir(newdir))
>> +			err(EXIT_FAILURE, _("cannot chdir to '%s'"), newdir);
>> +	}
> 
> It means that --wd is usable only when --root is specified. Is it
> expected? Would be better to use

Yes, the idea was to switch to a working directory in the chroot case.

But if you think it can be useful to switch to another directory on the
non-chroot case, I can upgrade the patch as you say.

Thanks,
Laurent
>  char *newdir = NULL;
> 
>  while ((c = getopt_long(....))) {
>     ...
>     case 'w':
>         newdir = optarg;
>         break;
>  }
>  ...
> 
>  if (newroot) {
>     if (chroot(newroot))
>         ... error ...
>     if (chdir(newdir ? newdir : "/"))
>         ... error ...
> 
>  } else if (newdir && chdir(newdir))
>     ... error ...
> 
> 
>     Karel
> 




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux