rpm/luaroot.diff
OBS User autobuild 25f00b6cb5 Accepting request 18841 from Base:System
Copy from Base:System/rpm based on submit request 18841 from user mlschroe

OBS-URL: https://build.opensuse.org/request/show/18841
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpm?expand=0&rev=84
2009-08-28 13:54:03 +00:00

64 lines
1.8 KiB
Diff

Index: lib/psm.c
===================================================================
--- lib/psm.c.orig
+++ lib/psm.c
@@ -441,6 +441,8 @@ static rpmRC runLuaScript(rpmpsm psm, He
#ifdef WITH_LUA
char *sname = NULL;
int rootFd = -1;
+ int chroot_done;
+ const char *rootDir;
int xx;
rpmlua lua = NULL; /* Global state. */
rpmluav var;
@@ -449,16 +451,21 @@ static rpmRC runLuaScript(rpmpsm psm, He
rpmlog(RPMLOG_DEBUG, "%s: %s running <lua> scriptlet.\n",
psm->stepName, sname);
- if (!rpmtsChrootDone(ts)) {
- const char *rootDir = rpmtsRootDir(ts);
- xx = chdir("/");
- rootFd = open(".", O_RDONLY, 0);
- if (rootFd >= 0) {
- if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/')
+ 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) {
xx = chroot(rootDir);
- xx = rpmtsSetChrootDone(ts, 1);
+ xx = rpmtsSetChrootDone(ts, 1);
+ }
}
+ } else {
+ rootFd = open(".", O_RDONLY, 0);
}
+ xx = chdir("/");
/* Create arg variable */
rpmluaPushTable(lua, "arg");
@@ -491,12 +498,17 @@ static rpmRC runLuaScript(rpmpsm psm, He
rpmluaDelVar(lua, "arg");
if (rootFd >= 0) {
- const char *rootDir = rpmtsRootDir(ts);
xx = fchdir(rootFd);
xx = close(rootFd);
- if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/')
+ 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);
}
free(sname);
#else