+++ /dev/null
---- rpm-5.2.0/lib/psm.c 2009-07-07 23:12:33.000000000 +0200
-+++ rpm-5.2.0/lib/psm.c 2010-05-08 15:17:24.063904813 +0200
-@@ -576,17 +576,21 @@
- #endif /* WITH_LUA */
-
- #if defined(WITH_LUA) || defined(WITH_FICL) || defined(WITH_JS) || defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || defined(WITH_RUBYEMBED) || defined(WITH_TCL)
--static int enterChroot(rpmpsm psm, int * fdnop)
-+static int enterChroot(rpmpsm psm, int * pwdFdnop, int * rootFdnop)
- /*@globals fileSystem, internalState @*/
-- /*@modifies *fdnop, fileSystem, internalState @*/
-+ /*@modifies *pwdFdnop, *rootFdnop, fileSystem, internalState @*/
- {
- const rpmts ts = psm->ts;
- int inChroot;
- int xx;
-
- /* Save the current working directory. */
-- if (fdnop)
-- (*fdnop) = open(".", O_RDONLY, 0);
-+ if (pwdFdnop)
-+ (*pwdFdnop) = open(".", O_RDONLY, 0);
-+
-+ /* Save the current root directory. */
-+ if (rootFdnop)
-+ (*rootFdnop) = open("/", O_RDONLY, 0);
-
- /* Get into the chroot. */
- if (!rpmtsChrootDone(ts)) {
-@@ -607,7 +611,7 @@
- return inChroot;
- }
-
--static int exitChroot(rpmpsm psm, int inChroot, int rootFdno)
-+static int exitChroot(rpmpsm psm, int inChroot, int pwdFdno, int rootFdno)
- /*@globals fileSystem, internalState @*/
- /*@modifies fileSystem, internalState @*/
- {
-@@ -623,10 +627,12 @@
- /*@=modobserver@*/
- xx = rpmtsSetChrootDone(ts, 0);
- }
-+ xx = fchdir(pwdFdno);
- } else
-- xx = fchdir(rootFdno);
-+ xx = fchdir(pwdFdno);
-
- xx = close(rootFdno);
-+ xx = close(pwdFdno);
-
- return 0;
- }
-@@ -648,11 +654,12 @@
- /*@modifies psm, fileSystem, internalState @*/
- {
- char * av[] = { NULL, NULL, NULL, NULL };
-+ int pwdFdno = -1;
- int rootFdno = -1;
- rpmRC rc = RPMRC_OK;
- int xx = 0;
- int * ssp = NULL;
-- int inChroot = enterChroot(psm, &rootFdno);
-+ int inChroot = enterChroot(psm, &pwdFdno, &rootFdno);
-
- if (psm->sstates != NULL)
- ssp = psm->sstates + tag2slx(psm->scriptTag);
-@@ -726,7 +733,7 @@
- *ssp |= RPMSCRIPT_STATE_REAPED;
- }
-
-- xx = exitChroot(psm, inChroot, rootFdno);
-+ xx = exitChroot(psm, inChroot, pwdFdno, rootFdno);
-
- return rc;
- }