poldek -r broken again?

Przemyslaw Iskra sparky at pld-linux.org
Sun May 2 20:45:01 CEST 2010


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'm in /tmp directory and I'm going to install something in /tmp/chroot:
[sparky at quad /tmp]$ rpm --root=/tmp/chroot/ -Uhv rpm/*

[...]

getcwd("/tmp", 4096)                    = 5

  -- so we are in /tmp yet

[...] no chdir or anything in those calls

open(".", O_RDONLY)                     = 7
  -- opens dir handle to /tmp, it should chdir("/") before making this
     call !

chroot("/tmp/chroot/")                  = 0
chdir("/")                              = 0
  -- entered chroot correctly

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.

close(7)                                = 0



To make it work it should open current directory (/tmp),
chdir to / and open that directory. Then enter chroot.

To exit chroot it should fchdir to old /, chroot there, and
fchdir to old working directory.

-- 
 ____  Sparky{PI] -- Przemyslaw _  ___  _  _  ........... LANG...Pl..Ca..Es..En
/____) ___  ___  _ _ || Iskra  |  | _ \| |  | : WWW........ppcrcd.pld-linux.org
\____\| -_)'___| ||^'||//\\// <   |  _/| |  | : JID......sparky<at>jabberes.org
(____/||   (_-_|_||  ||\\ ||   |_ |_|  |_| _| : Mail....sparky<at>pld-linux.org


More information about the pld-devel-en mailing list