2006-12-19 00:17:44 +01:00
|
|
|
Index: lib/psm.c
|
|
|
|
===================================================================
|
|
|
|
--- lib/psm.c.orig
|
|
|
|
+++ lib/psm.c
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -506,6 +506,8 @@ static rpmRC runLuaScript(rpmpsm psm, He
|
2006-12-19 00:17:44 +01:00
|
|
|
{
|
|
|
|
const rpmts ts = psm->ts;
|
|
|
|
int rootFd = -1;
|
|
|
|
+ int chroot_done;
|
|
|
|
+ const char *rootDir;
|
|
|
|
const char *n, *v, *r;
|
|
|
|
rpmRC rc = RPMRC_OK;
|
|
|
|
int i;
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -515,20 +517,27 @@ static rpmRC runLuaScript(rpmpsm psm, He
|
2006-12-19 00:17:44 +01:00
|
|
|
|
|
|
|
xx = headerNVR(h, &n, &v, &r);
|
|
|
|
|
|
|
|
- if (!rpmtsChrootDone(ts)) {
|
|
|
|
- const char *rootDir = rpmtsRootDir(ts);
|
|
|
|
- xx = chdir("/");
|
|
|
|
+ chroot_done = rpmtsChrootDone(ts);
|
|
|
|
+ rootDir = rpmtsRootDir(ts);
|
|
|
|
+ if (!chroot_done) {
|
|
|
|
+ if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/') {
|
|
|
|
+ xx = chdir("/");
|
|
|
|
/*@-nullpass@*/
|
|
|
|
- rootFd = open(".", O_RDONLY, 0);
|
|
|
|
+ rootFd = open(".", O_RDONLY, 0);
|
|
|
|
/*@=nullpass@*/
|
|
|
|
- if (rootFd >= 0) {
|
|
|
|
- /*@-superuser -noeffect @*/
|
|
|
|
- if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/')
|
|
|
|
+ if (rootFd >= 0) {
|
|
|
|
+ /*@-superuser -noeffect @*/
|
|
|
|
xx = chroot(rootDir);
|
|
|
|
- /*@=superuser =noeffect @*/
|
|
|
|
- xx = rpmtsSetChrootDone(ts, 1);
|
|
|
|
+ /*@=superuser =noeffect @*/
|
|
|
|
+ xx = rpmtsSetChrootDone(ts, 1);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ } else {
|
|
|
|
+/*@-nullpass@*/
|
|
|
|
+ rootFd = open(".", O_RDONLY, 0);
|
|
|
|
+/*@=nullpass@*/
|
|
|
|
}
|
|
|
|
+ xx = chdir("/");
|
|
|
|
|
|
|
|
/* Create arg variable */
|
|
|
|
rpmluaPushTable(lua, "arg");
|
2008-09-12 20:37:28 +02:00
|
|
|
@@ -565,14 +574,19 @@ 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);
|
|
|
|
- /*@-superuser -noeffect @*/
|
|
|
|
- if (rootDir != NULL && strcmp(rootDir, "/") && *rootDir == '/')
|
|
|
|
+ if (!chroot_done) {
|
|
|
|
+ /*@-superuser -noeffect @*/
|
|
|
|
xx = chroot(".");
|
|
|
|
- /*@=superuser =noeffect @*/
|
|
|
|
- xx = rpmtsSetChrootDone(ts, 0);
|
|
|
|
+ /*@=superuser =noeffect @*/
|
|
|
|
+ xx = rpmtsSetChrootDone(ts, 0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!chroot_done) {
|
|
|
|
+ const char *currDir = rpmtsCurrDir(ts);
|
|
|
|
+ if (currDir != NULL)
|
|
|
|
+ xx = chdir(currDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|