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

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

 



On Thu, Oct 04, 2018 at 12:15:15PM +0200, Laurent Vivier wrote:
> 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.

In the nsenter we use --wd as generic and independent on --root. It
would be probably better to keep the semantic the same (although in
this case it has probably minimal sense for end-users).

So yes, upgrade the patch to call chdir() always when --wd specified.
Thanks.

    Karel

> 
> 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
> > 
> 

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com



[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