From: Karel Zak <kzak@redhat.com>
To: Laurent Vivier <laurent@vivier.eu>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 1/2] unshare: allow to set a new root
Date: Fri, 5 Oct 2018 11:54:41 +0200 [thread overview]
Message-ID: <20181005095441.feybdayxrom62qz3@ws.net.home> (raw)
In-Reply-To: <fd5c5d6d-8e65-ddfd-f07f-832c9baab53f@vivier.eu>
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@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2018-10-05 16:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-28 12:45 [PATCH 0/2] unshare: add some chroot magic Laurent Vivier
2018-09-28 12:45 ` [PATCH 1/2] unshare: allow to set a new root Laurent Vivier
2018-10-04 10:11 ` Karel Zak
2018-10-04 10:15 ` Laurent Vivier
2018-10-05 9:54 ` Karel Zak [this message]
2018-09-28 12:45 ` [PATCH 2/2] unshare: allows to set user ID and group ID Laurent Vivier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181005095441.feybdayxrom62qz3@ws.net.home \
--to=kzak@redhat.com \
--cc=laurent@vivier.eu \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).