[prev in list] [next in list] [prev in thread] [next in thread]
List: rpmorg-maint
Subject: [Rpm-maint] [Suse patch] Lua-script cwd issues
From: pmatilai () redhat ! com (Panu Matilainen)
Date: 2007-05-22 7:43:15
Message-ID: Pine.LNX.4.64.0705221038060.3804 () dhcp115 ! koti ! laiskiainen ! org
[Download RAW message or body]
Cwd isn't consistently set for Lua-scripts, this patch fixes it. For full
details see
https://lists.dulug.duke.edu/pipermail/rpm-devel/2006-August/001475.html
Already applied.
- Panu -
Index: lib/psm.c
===================================================================
--- lib/psm.c.orig
+++ lib/psm.c
@@ -502,6 +502,8 @@ static rpmRC runLuaScript(rpmpsm psm, He
{
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;
@@ -511,20 +513,27 @@ static rpmRC runLuaScript(rpmpsm psm, He
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");
@@ -561,14 +570,19 @@ static rpmRC runLuaScript(rpmpsm psm, He
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;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic