summaryrefslogtreecommitdiffstats
path: root/libopkg/pkg.c
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-04 22:09:44 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-04 22:09:44 (EST)
commitacd905996191df6ab59050bd179a5ed11e6f72a4 (patch)
treeb0d6d24cb2d07f0b94584dbbc824e04ff1bb8724 /libopkg/pkg.c
parentf0c41b4e0e096698a7e2eae1ab99d9af1a74d5bd (diff)
Don't set PATH="/dev/null". Shuffle things around while here.
git-svn-id: http://opkg.googlecode.com/svn/trunk@258 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/pkg.c')
-rw-r--r--libopkg/pkg.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index 237db44..33d0d68 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -1142,6 +1142,33 @@ int pkg_run_script(opkg_conf_t *conf, pkg_t *pkg,
char *path;
char *cmd;
+ if (conf->noaction)
+ return 0;
+
+ /* XXX: CLEANUP: There must be a better way to handle maintainer
+ scripts when running with offline_root mode and/or a dest other
+ than '/'. I've been playing around with some clever chroot
+ tricks and I might come up with something workable. */
+ /*
+ * Attempt to provide a restricted environment for offline operation
+ * Need the following set as a minimum:
+ * OPKG_OFFLINE_ROOT = absolute path to root dir
+ * D = absolute path to root dir (for OE generated postinst)
+ * PATH = something safe (a restricted set of utilities)
+ */
+
+ if (conf->offline_root) {
+ if (conf->offline_root_path) {
+ setenv("PATH", conf->offline_root_path, 1);
+ } else {
+ opkg_message(conf, OPKG_NOTICE,
+ "(offline root mode: not running %s.%s)\n", pkg->name, script);
+ return 0;
+ }
+ setenv("OPKG_OFFLINE_ROOT", conf->offline_root, 1);
+ setenv("D", conf->offline_root, 1);
+ }
+
/* XXX: FEATURE: When conf->offline_root is set, we should run the
maintainer script within a chroot environment. */
@@ -1164,31 +1191,6 @@ int pkg_run_script(opkg_conf_t *conf, pkg_t *pkg,
}
opkg_message(conf, OPKG_INFO, "Running script %s\n", path);
- if (conf->noaction) return 0;
-
- /* XXX: CLEANUP: There must be a better way to handle maintainer
- scripts when running with offline_root mode and/or a dest other
- than '/'. I've been playing around with some clever chroot
- tricks and I might come up with something workable. */
- /*
- * Attempt to provide a restricted environment for offline operation
- * Need the following set as a minimum:
- * OPKG_OFFLINE_ROOT = absolute path to root dir
- * D = absolute path to root dir (for OE generated postinst)
- * PATH = something safe (a restricted set of utilities)
- */
-
- bool AllowOfflineMode = false;
- if (conf->offline_root) {
- setenv("OPKG_OFFLINE_ROOT", conf->offline_root, 1);
- setenv("D", conf->offline_root, 1);
- if (NULL == conf->offline_root_path || '\0' == conf->offline_root_path[0]) {
- setenv("PATH", "/dev/null", 1);
- } else {
- setenv("PATH", conf->offline_root_path, 1);
- AllowOfflineMode = true;
- }
- }
setenv("PKG_ROOT",
pkg->dest ? pkg->dest->root_dir : conf->default_dest->root_dir, 1);
@@ -1198,12 +1200,6 @@ int pkg_run_script(opkg_conf_t *conf, pkg_t *pkg,
return 0;
}
- if (conf->offline_root && !AllowOfflineMode) {
- fprintf(stderr, "(offline root mode: not running %s.%s)\n", pkg->name, script);
- free(path);
- return 0;
- }
-
sprintf_alloc(&cmd, "%s %s", path, args);
free(path);