From: Glenn Strauss Date: Thu, 2 Mar 2017 22:53:09 +0000 (-0500) Subject: libopkg: specify "/bin/sh" instead of "sh" X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=commitdiff_plain;h=5dc3e3363159939fcfb429a959bc91296541dc09 libopkg: specify "/bin/sh" instead of "sh" avoid strange behavior with execvp() when PATH is not set in environment (in which case confstr(_CS_PATH) should return something reasonable) reproducable running openwrt 15.05 and 15.05.1 and attempting to install a software package (e.g. libuuid) via LuCI (prior to openwrt/luci#1048). (https://github.com/openwrt/luci/pull/1048) libuuid.postinst fails with status 255 on 15.05 and opkg segfaults in 15.05.1. This probably merits further exploration. Originally reported in https://github.com/openwrt/packages/issues/1922 Signed-off-by: Glenn Strauss --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d022e0..30a5d44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ PROJECT(opkg C) SET(HOST_CPU "" CACHE STRING "Override Host CPU") SET(BUILD_CPU "" CACHE STRING "Override Host CPU") SET(LOCK_FILE "/var/lock/opkg.lock" CACHE STRING "Override lock file path") +SET(PATH_SPEC "/usr/sbin:/usr/bin:/sbin:/bin" CACHE STRING "Override default PATH value") SET(VERSION "" CACHE STRING "Override version") OPTION(STATIC_UBOX "Statically link libubox" OFF) @@ -37,6 +38,7 @@ ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -Wmissing-declarations -DOPKGLIBDIR="/usr/lib" -DHOST_CPU_STR="${HOST_CPU}" -DBUILD_CPU=${BUILD_CPU} + -DPATH_SPEC="${PATH_SPEC}" -DVERSION="${VERSION}" ) diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index 543eef4..d52bcb1 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -254,7 +254,7 @@ static int opkg_finalize_intercepts(opkg_intercept_t ctx) sprintf_alloc(&path, "%s/%s", ctx->statedir, de->d_name); if (access(path, X_OK) == 0) { - const char *argv[] = { "sh", "-c", path, NULL }; + const char *argv[] = { "/bin/sh", "-c", path, NULL }; xsystem(argv); } free(path); diff --git a/libopkg/pkg.c b/libopkg/pkg.c index 5370cf9..313e691 100644 --- a/libopkg/pkg.c +++ b/libopkg/pkg.c @@ -1401,7 +1401,7 @@ int pkg_run_script(pkg_t * pkg, const char *script, const char *args) sprintf_alloc(&cmd, "%s %s", path, args); free(path); { - const char *argv[] = { "sh", "-c", cmd, NULL }; + const char *argv[] = { "/bin/sh", "-c", cmd, NULL }; err = xsystem(argv); } free(cmd);