util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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: Thu, 4 Oct 2018 12:11:12 +0200	[thread overview]
Message-ID: <20181004101112.2542qy4di4sykelp@ws.net.home> (raw)
In-Reply-To: <20180928124512.13979-2-laurent@vivier.eu>

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

 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

  reply	other threads:[~2018-10-04 17:03 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 [this message]
2018-10-04 10:15     ` Laurent Vivier
2018-10-05  9:54       ` Karel Zak
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=20181004101112.2542qy4di4sykelp@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).