[libglnx] libcontainer: Search $PATH for exec() if argv[0] is not absolute
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libglnx] libcontainer: Search $PATH for exec() if argv[0] is not absolute
- Date: Mon, 15 Jun 2015 17:38:55 +0000 (UTC)
commit 91875459cdc9e61c2ea8c5831c7593ec7641fd2b
Author: Colin Walters <walters verbum org>
Date: Mon Jun 15 12:27:30 2015 -0400
libcontainer: Search $PATH for exec() if argv[0] is not absolute
In Fedora rawhide, dracut switched from `/usr/sbin` to `/usr/bin`,
which broke rpm-ostree's hardcoding of the path.
There was no real reason to hardcode it (assume our `$PATH` is sane
and secure), so in order to help support that, this change in libglnx
will automatically search $PATH if the input is not absolute.
(This is a sane default for a process spawning library IMO)
glnx-libcontainer.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/glnx-libcontainer.c b/glnx-libcontainer.c
index dafd8ad..49fa095 100644
--- a/glnx-libcontainer.c
+++ b/glnx-libcontainer.c
@@ -242,8 +242,16 @@ glnx_libcontainer_run_in_root (const char *dest,
if (chdir ("/") != 0)
_perror_fatal ("chdir: ");
- if (execv (binary, argv) != 0)
- _perror_fatal ("execl: ");
+ if (binary[0] == '/')
+ {
+ if (execv (binary, argv) != 0)
+ _perror_fatal ("execv: ");
+ }
+ else
+ {
+ if (execvp (binary, argv) != 0)
+ _perror_fatal ("execvp: ");
+ }
g_assert_not_reached ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]