On May 2, 2010, at 2:45 PM, Przemyslaw Iskra wrote: > On Sun, May 02, 2010 at 02:22:03PM -0400, Jeff Johnson wrote: >> >> On May 2, 2010, at 2:11 PM, Przemyslaw Iskra wrote: >> >>> >>> Makes rpm lose track of current root directory. That is, it is unnable >>> to exit the chroot correctly before continuing instalation. >>> >> >> Well the actual details aren't quite that simple even if the >> flaw is (demonstrably and de facto) associated with using embedded >> lua in %posttrans in the fhs package. >> >> RPM for quite some years now (patch originally was from SuSE) >> opens's the root directory, runs embedded lua, and then does fchdir(2) >> to restore the root directory after lua is through doing whatever. >> >> I haven't looked at rpm-4.5 for some years, but there's only a >> single instance where fchdir(2) is used in RPM code so it should >> not be hard to find. > > If anyone is going to fix that, here goes strace with my comments: >
I'd fix if I thought there was a flaw. So far I don't see the flaw. Please note that I'm not arguing or disagreeing, just I don't see the flaw. > I'm in /tmp directory and I'm going to install something in /tmp/chroot: > [spa...@quad /tmp]$ rpm --root=/tmp/chroot/ -Uhv rpm/* > > [...] > > getcwd("/tmp", 4096) = 5 > This is the current working directory for your invocation. > -- so we are in /tmp yet > > [...] no chdir or anything in those calls > Yes. RPM attempts to _NEVER_ do chdir(2) (but it gets trickier running opaque embedded lua scripts because the scripts can change RPM's current working directory. > open(".", O_RDONLY) = 7 > -- opens dir handle to /tmp, it should chdir("/") before making this > call ! > Why should chdir("/") be done. Its the current working directory that RPM is trying to preserve. > chroot("/tmp/chroot/") = 0 > chdir("/") = 0 > -- entered chroot correctly > OK. > lstat("/usr/include/X11", 0x7fffc481e990) = -1 ENOENT (No such file or > directory) > -- executes lua > > fchdir(7) = 0 > -- changes dir to saved dir handle (prepares to exit chroot) > > chroot(".") = 0 > -- chroots back to /tmp ! > This way /tmp becomes new root. > ... which re-establishes the cwd before embedded lua was run. > close(7) = 0 > > > > To make it work it should open current directory (/tmp), > chdir to / and open that directory. Then enter chroot. > Perfectly willing to do that if you explain your expectations more completely. My guess is that you want a deterministic chdir("/") when running opaque embedded lua scripts. You certainly can do chdir("/") within the lua script if you wish. The disagreement seems largely to be what you expect RPM to do vs. what should be done in embedded scriptlets. And there's truly so few embedded scripts in *.rpm that noone (certainly not me) has ever tried to pin down the execution environment precisely. > To exit chroot it should fchdir to old /, chroot there, and > fchdir to old working directory. > And your old working directory is (in fact) /tmp which was restored by fchdir(2). 73 de jeff _______________________________________________ pld-devel-en mailing list pld-devel-en@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-devel-en