nsenter: respect --exec no matter where it appears
Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
08e86f4c2c
commit
57dbcf94d8
|
@ -175,7 +175,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
struct namespace_file *nsfile;
|
struct namespace_file *nsfile;
|
||||||
int c, namespaces = 0;
|
int c, namespaces = 0;
|
||||||
bool do_rd = false, do_wd = false, do_fork = false;
|
bool do_rd = false, do_wd = false;
|
||||||
|
int do_fork = -1; /* unknown yet */
|
||||||
|
|
||||||
setlocale(LC_MESSAGES, "");
|
setlocale(LC_MESSAGES, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
|
@ -220,7 +221,6 @@ int main(int argc, char *argv[])
|
||||||
namespaces |= CLONE_NEWNET;
|
namespaces |= CLONE_NEWNET;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
do_fork = true;
|
|
||||||
if (optarg)
|
if (optarg)
|
||||||
open_namespace_fd(CLONE_NEWPID, optarg);
|
open_namespace_fd(CLONE_NEWPID, optarg);
|
||||||
else
|
else
|
||||||
|
@ -233,7 +233,7 @@ int main(int argc, char *argv[])
|
||||||
namespaces |= CLONE_NEWUSER;
|
namespaces |= CLONE_NEWUSER;
|
||||||
break;
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
do_fork = false;
|
do_fork = 0;
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
|
@ -272,6 +272,8 @@ int main(int argc, char *argv[])
|
||||||
for (nsfile = namespace_files; nsfile->nstype; nsfile++) {
|
for (nsfile = namespace_files; nsfile->nstype; nsfile++) {
|
||||||
if (nsfile->fd < 0)
|
if (nsfile->fd < 0)
|
||||||
continue;
|
continue;
|
||||||
|
if (nsfile->nstype == CLONE_NEWPID && do_fork == -1)
|
||||||
|
do_fork = 1;
|
||||||
if (setns(nsfile->fd, nsfile->nstype))
|
if (setns(nsfile->fd, nsfile->nstype))
|
||||||
err(EXIT_FAILURE,
|
err(EXIT_FAILURE,
|
||||||
_("reassociate to namespace '%s' failed"),
|
_("reassociate to namespace '%s' failed"),
|
||||||
|
@ -311,7 +313,7 @@ int main(int argc, char *argv[])
|
||||||
wd_fd = -1;
|
wd_fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_fork)
|
if (do_fork == 1)
|
||||||
continue_as_child();
|
continue_as_child();
|
||||||
|
|
||||||
execvp(argv[optind], argv + optind);
|
execvp(argv[optind], argv + optind);
|
||||||
|
|
Loading…
Reference in New Issue