[pacman-dev] [PATCH 1/3] Use execvp for running programs in chroot
This makes us more robust to utilities changing paths. There is no functional change when a full path is specified. Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index c2b5d44..bdb9e56 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -549,9 +549,9 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[]) exit(1); } umask(0022); - execv(cmd, argv); - /* execv only returns if there was an error */ - fprintf(stderr, _("call to execv failed (%s)\n"), strerror(errno)); + execvp(cmd, argv); + /* execvp only returns if there was an error */ + fprintf(stderr, _("call to execvp failed (%s)\n"), strerror(errno)); exit(1); } else { /* this code runs for the parent only (wait on the child) */ -- 1.7.11.2
The ldconfig binary is not guaranteed to be in /sbin. Change to calling just "ldconfig" rather than using the full path. This removed the check that the ldconfig binary exists. However, it is a reasonable assumption that it will exist if its configuration file does. Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/util.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index bdb9e56..0db9e87 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -621,13 +621,10 @@ int _alpm_ldconfig(alpm_handle_t *handle) snprintf(line, PATH_MAX, "%setc/ld.so.conf", handle->root); if(access(line, F_OK) == 0) { - snprintf(line, PATH_MAX, "%ssbin/ldconfig", handle->root); - if(access(line, X_OK) == 0) { - char arg0[32]; - char *argv[] = { arg0, NULL }; - strcpy(arg0, "ldconfig"); - return _alpm_run_chroot(handle, "/sbin/ldconfig", argv); - } + char arg0[32]; + char *argv[] = { arg0, NULL }; + strcpy(arg0, "ldconfig"); + return _alpm_run_chroot(handle, "ldconfig", argv); } return 0; -- 1.7.11.2
This increases robustness to the shell location changing paths. Signed-off-by: Allan McRae <allan@archlinux.org> --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5483ee1..6f53c72 100644 --- a/configure.ac +++ b/configure.ac @@ -95,8 +95,8 @@ AC_ARG_WITH(buildscript, # Help line for changing shell used to run install scriptlets AC_ARG_WITH(scriptlet-shell, AS_HELP_STRING([--with-scriptlet-shell=shell], - [set the full path to the shell used to run install scriptlets]), - [SCRIPTLET_SHELL=$withval], [SCRIPTLET_SHELL=/bin/sh]) + [set the shell used to run install scriptlets]), + [SCRIPTLET_SHELL=$withval], [SCRIPTLET_SHELL=sh]) # Help line for using OpenSSL AC_ARG_WITH(openssl, @@ -447,7 +447,7 @@ AC_SUBST(BUILDSCRIPT) AC_DEFINE_UNQUOTED([BUILDSCRIPT], "$BUILDSCRIPT", [The build script name used by makepkg]) # Set shell used by install scriptlets AC_SUBST(SCRIPTLET_SHELL) -AC_DEFINE_UNQUOTED([SCRIPTLET_SHELL], "$SCRIPTLET_SHELL", [The full path of the shell used to run install scriptlets]) +AC_DEFINE_UNQUOTED([SCRIPTLET_SHELL], "$SCRIPTLET_SHELL", [The shell used to run install scriptlets]) # Configuration files AC_CONFIG_FILES([ -- 1.7.11.2
participants (1)
-
Allan McRae