[Rpm-maint] RPM NDB and chroot failure

Michael Schroeder mls at suse.de
Wed Jul 19 09:39:11 UTC 2017


On Tue, Jul 18, 2017 at 10:59:03AM -0700, Darren Hart wrote:
> While testing my previous patches to allow for an NDB only build of RPM, I ran
> across an issue using the --root argument.
> 
> When passing --root, the strace log shows that after the chroot call, a stat()
> of the Packages.db absolute path fails, which triggers a reopen, which fails as
> it attempts open() using the absolute path.
> 
> This manifests in lib/backend/ndb/rpmpkg.c:
> 
> rpmpkgLock
> 	rpmpkgGetLock
> 		is_correct_db
> 			reopen_db
> 				open(pkgdb->filename, ...)
> 
> The pkgdb->filename is not being updated after chroot.
> 
> I'm looking into how to fix this, but I'm still a bit green on the RPM DB
> abstractions.
> 
> Should the ndb implementation be using the rpmbd_internal API? For example,
> rather than accessing pkgdb->filename directly, should the ndb implementation
> have a call which provides it with the chroot adjusted path to the RPM DB?
> Something using rpmdbHome() for example?

I see three possibilities:

1) just remove the is_correct_db() code. It's just there to catch somebody
   doing 'rpm --rebuildb', but I don't think it makes much sense. The
   rpmxdb code is missing reopen functionality anyway.

2) open the directory and to fstatat and openat. But this seems somewhat
   linux centric.

3) add support for chroot to ndb and let the glue code update the
   chroot if it was changed. Much code for little gain, IMHO.

I suggest to go with 1), code removal is always good ;) Plus, Berkeley db
also doesn't check for database switches, so it is no regression.

Cheers,
  Michael.

-- 
Michael Schroeder                                   mls at suse.de
SUSE LINUX GmbH,           GF Jeff Hawn, HRB 16746 AG Nuernberg
main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);}


More information about the Rpm-maint mailing list