1 --- rpm-5.2.0/lib/psm.c 2009-07-07 23:12:33.000000000 +0200
2 +++ rpm-5.2.0/lib/psm.c 2010-05-08 15:17:24.063904813 +0200
6 #if defined(WITH_LUA) || defined(WITH_FICL) || defined(WITH_JS) || defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || defined(WITH_RUBYEMBED) || defined(WITH_TCL)
7 -static int enterChroot(rpmpsm psm, int * fdnop)
8 +static int enterChroot(rpmpsm psm, int * pwdFdnop, int * rootFdnop)
9 /*@globals fileSystem, internalState @*/
10 - /*@modifies *fdnop, fileSystem, internalState @*/
11 + /*@modifies *pwdFdnop, *rootFdnop, fileSystem, internalState @*/
13 const rpmts ts = psm->ts;
17 /* Save the current working directory. */
19 - (*fdnop) = open(".", O_RDONLY, 0);
21 + (*pwdFdnop) = open(".", O_RDONLY, 0);
23 + /* Save the current root directory. */
25 + (*rootFdnop) = open("/", O_RDONLY, 0);
27 /* Get into the chroot. */
28 if (!rpmtsChrootDone(ts)) {
33 -static int exitChroot(rpmpsm psm, int inChroot, int rootFdno)
34 +static int exitChroot(rpmpsm psm, int inChroot, int pwdFdno, int rootFdno)
35 /*@globals fileSystem, internalState @*/
36 /*@modifies fileSystem, internalState @*/
40 xx = rpmtsSetChrootDone(ts, 0);
42 + xx = fchdir(pwdFdno);
44 - xx = fchdir(rootFdno);
45 + xx = fchdir(pwdFdno);
48 + xx = close(pwdFdno);
53 /*@modifies psm, fileSystem, internalState @*/
55 char * av[] = { NULL, NULL, NULL, NULL };
61 - int inChroot = enterChroot(psm, &rootFdno);
62 + int inChroot = enterChroot(psm, &pwdFdno, &rootFdno);
64 if (psm->sstates != NULL)
65 ssp = psm->sstates + tag2slx(psm->scriptTag);
67 *ssp |= RPMSCRIPT_STATE_REAPED;
70 - xx = exitChroot(psm, inChroot, rootFdno);
71 + xx = exitChroot(psm, inChroot, pwdFdno, rootFdno);