2010-03-26 11:56:28 +01:00
|
|
|
--- ./lib/psm.c.orig 2009-12-07 14:36:49.000000000 +0000
|
|
|
|
+++ ./lib/psm.c 2010-03-25 14:42:52.000000000 +0000
|
|
|
|
@@ -455,6 +455,8 @@ static rpmRC runLuaScript(rpmpsm psm, He
|
2009-08-28 15:54:03 +02:00
|
|
|
#ifdef WITH_LUA
|
|
|
|
char *sname = NULL;
|
2006-12-19 00:17:44 +01:00
|
|
|
int rootFd = -1;
|
|
|
|
+ int chroot_done;
|
|
|
|
+ const char *rootDir;
|
2009-08-28 15:54:03 +02:00
|
|
|
int xx;
|
|
|
|
rpmlua lua = NULL; /* Global state. */
|
|
|
|
rpmluav var;
|
2010-03-26 11:56:28 +01:00
|
|
|
@@ -463,6 +465,22 @@ static rpmRC runLuaScript(rpmpsm psm, He
|
2006-12-19 00:17:44 +01:00
|
|
|
|
2009-08-28 15:54:03 +02:00
|
|
|
rpmlog(RPMLOG_DEBUG, "%s: %s running <lua> scriptlet.\n",
|
|
|
|
psm->stepName, sname);
|
2006-12-19 00:17:44 +01:00
|
|
|
+ chroot_done = rpmtsChrootDone(ts);
|
|
|
|
+ rootDir = rpmtsRootDir(ts);
|
|
|
|
+ if (!chroot_done) {
|
|
|
|
+ if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') {
|
|
|
|
+ xx = chdir("/");
|
|
|
|
+ rootFd = open(".", O_RDONLY, 0);
|
|
|
|
+ if (rootFd >= 0) {
|
2010-03-26 11:56:28 +01:00
|
|
|
+ xx = chroot(rootDir);
|
2006-12-19 00:17:44 +01:00
|
|
|
+ xx = rpmtsSetChrootDone(ts, 1);
|
|
|
|
+ }
|
2010-03-26 11:56:28 +01:00
|
|
|
+ }
|
2006-12-19 00:17:44 +01:00
|
|
|
+ } else {
|
|
|
|
+ rootFd = open(".", O_RDONLY, 0);
|
2010-03-26 11:56:28 +01:00
|
|
|
+ }
|
2006-12-19 00:17:44 +01:00
|
|
|
+ xx = chdir("/");
|
2010-03-26 11:56:28 +01:00
|
|
|
+
|
|
|
|
if (!rpmtsChrootDone(ts)) {
|
|
|
|
const char *rootDir = rpmtsRootDir(ts);
|
|
|
|
xx = chdir("/");
|
|
|
|
@@ -505,12 +523,17 @@ static rpmRC runLuaScript(rpmpsm psm, He
|
2006-12-19 00:17:44 +01:00
|
|
|
rpmluaDelVar(lua, "arg");
|
|
|
|
|
|
|
|
if (rootFd >= 0) {
|
|
|
|
- const char *rootDir = rpmtsRootDir(ts);
|
|
|
|
xx = fchdir(rootFd);
|
|
|
|
xx = close(rootFd);
|
2010-03-26 11:56:28 +01:00
|
|
|
- if (rootDir != NULL && !rstreq(rootDir, "/") && *rootDir == '/')
|
2006-12-19 00:17:44 +01:00
|
|
|
+ if (!chroot_done) {
|
|
|
|
xx = chroot(".");
|
|
|
|
- xx = rpmtsSetChrootDone(ts, 0);
|
|
|
|
+ xx = rpmtsSetChrootDone(ts, 0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!chroot_done) {
|
|
|
|
+ const char *currDir = rpmtsCurrDir(ts);
|
|
|
|
+ if (currDir != NULL)
|
|
|
|
+ xx = chdir(currDir);
|
|
|
|
}
|
2009-08-28 15:54:03 +02:00
|
|
|
free(sname);
|
|
|
|
#else
|