Bug 117997 - rpm 4.3 does not close its database properly with --root opt
Summary: rpm 4.3 does not close its database properly with --root opt
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Paul Nasrat
QA Contact: Mike McLean
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-03-10 21:31 UTC by Pawel A. Gajda
Modified: 2007-11-30 22:10 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-04-19 18:38:39 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Pawel A. Gajda 2004-03-10 21:31:32 UTC
Description of problem:
rpm 4.3 (at least 2004-01-07 cvs snapshot) does not close 
its database properly with --root option. 

Seems that all database files except Packages and Name
are opened after rpm calls chroot(), but the database 
is closing by one (AFAIK) function dbenv->close() 
(called from db_fini()) after rpm leaves "chroot jail". 

How reproducible:
Every time

Steps to Reproduce:
# mv /var/lib/rpm /var/lib/rpm-
# mkdir /tmp/foo
# rpm --root=/tmp/foo --initdb 
# rpm --root=/tmp/foo -i foo.rpm    
rpmdb: /var/lib/rpm/Filemd5s: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Sha1header: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Sigmd5: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Installtid: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Provideversion: unable to flush: No such file or
directory
rpmdb: /var/lib/rpm/Requireversion: unable to flush: No such file or
directory
rpmdb: /var/lib/rpm/Dirnames: unable to flush: No such file or
directory    
rpmdb: /var/lib/rpm/Triggername: unable to flush: No such file or
directory
rpmdb: /var/lib/rpm/Providename: unable to flush: No such file or
directory
rpmdb: /var/lib/rpm/Requirename: unable to flush: No such file or
directory
rpmdb: /var/lib/rpm/Group: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Basenames: unable to flush: No such file or directory
error: db4 error(2) from dbenv->close: No such file or directory

Comment 1 Jeff Johnson 2004-03-10 21:56:27 UTC
FYI: --initdb is mostly hysterical legacy these days.

This script does not reproduce your problem:

#!/bin/sh

mv /var/lib/rpm /var/lib/rpm-
rm -rf /tmp/foo
mkdir /tmp/foo
rpm --root=/tmp/foo --initdb
rpm --root=/tmp/foo -i --nodeps --noscripts /X/time/time*.i386.rpm
mv /var/lib/rpm- /var/lib/rpm


Comment 2 Pawel A. Gajda 2004-03-10 22:52:19 UTC
Well, I reproduced it on PLD; I'll try to check if our package 
is broken. Anyway, under Fedora C1 this script gives similar results:

rpmdb: /var/lib/rpm/Filemd5s: No such file or directory
rpmdb: /var/lib/rpm/Filemd5s: cannot sync: No such file or directory
error: db4 error(2) from dbenv->close: No such file or directory

Maybe this problem depends on db? 
$ rpm -q rpm db4
rpm-4.2.1-0.30
db4-4.1.25-14

Thanks for quick reply. 


Comment 3 Jeff Johnson 2004-03-11 04:09:26 UTC
I was using rpm-4.3. Many bugs fixed in rpm-4.2.2 and later.

Comment 4 Pawel A. Gajda 2004-03-11 13:00:01 UTC
I've just made tests under Fedora-test 
(packages from http://download.fedora.us/fedora/fedora/1.90/i386/RPMS.updates) 

Both rpm-4.3-0.19 (built Mar 9 13:44:46 2004) and 
today CVS snapshot screaming as I mentioned in bug report. 
Have no idea why you cannot reproduce this, I'll try do debug. 

Comment 5 Jeff Johnson 2004-03-11 22:03:09 UTC
Hmmm, I'm not sure either.

What is different? I'm running fc2 devel w selinux. The only other
platform that I have routinely available is fc2 devel on G5 w/o
selinux. I'll try to run the script on a few more distro releases
w other versions of rpm/glibc/kernel as time permits.

Comment 6 Arkadiusz Miskiewicz 2004-03-15 09:44:04 UTC
rpm taken from HEAD sometime ago - rpm-4.3-0.20040107.9, kernel 2.6.
4, glibc 2.3.3 from glibc cvs from january

[root@arm RPMS]# rm -rf /tmp/foo
[root@arm RPMS]# mkdir /tmp/foo
[root@arm RPMS]# rpm --root=/tmp/foo --initdb
[root@arm RPMS]# rpm -vvv --root=/tmp/foo -i tunelp-2.12-10.athlon.
rpm --nodeps
D: ============== tunelp-2.12-10.athlon.rpm
D: Expected size:        24074 = lead(96)+sigs(180)+pad(4)
+data(23794)
D:   Actual size:        24074
D: tunelp-2.12-10.athlon.rpm: MD5 digest: OK 
(7ebbce32cfd257570a01d992ed545097)
D:      added binary package [0]
D: found 0 source and 1 binary packages
D: ========== recording tsort relations
D: ========== tsorting packages (order, #predecessors, #succesors, 
tree, depth)
D:     0    0    0    0    0 +tunelp-2.12-10
D: installing binary packages
D: unshared posix mutexes found(38), adding DB_PRIVATE, using fcntl 
lock
D: opening  db environment /tmp/foo/var/lib/rpm/Packages create:cdb:
mpool:private
D: opening  db index       /tmp/foo/var/lib/rpm/Packages create 
mode=0x42
D: locked   db index       /tmp/foo/var/lib/rpm/Packages
D: mounted filesystems:
D:     i    dev bsize       bavail       iavail mount point
D:     0 0x2103  4096        21397        81239 /
D:     1 0x0003  4096            0           -1 /proc
D:     2 0x000b  4096            0           -1 /dev
D:     3 0x0000  4096            0           -1 /sys
D:     4 0x2101  4096       334573            8 /mnt/ntfs
D:     5 0x2106  4096        93367      1557878 /home
D:     6 0x2105  4096       606343      7553165 /usr
D:     7 0x2240  4096       800223     12846353 /mnt/storage1
D:     8 0x1640  4096      9918954     58477205 /mnt/storage2
D:     9 0x0700  4096      6216607     99497348 /mnt/storage3
D:    10 0x0009  4096            0           -1 /dev/pts
D:    11 0x000e  4096        72636        72635 /dev/shm
D:    12 0x0700  4096      6216607     99497348 
/home/services/oftp/openftpd-site
D:    13 0x2240  4096       800223     12846353 
/home/services/oftp/openftpd-site/MP3/Varia
D:    14 0x1640  4096      9918954     58477205 
/home/services/oftp/openftpd-site/Video/!TORRENT
D:    15 0x000f  4096            0           -1 
/proc/sys/fs/binfmt_misc
D:    16 0x2103  4096        21397        81239 
/mnt/storage1/MOBRARM/tmp
D:    17 0x1640  4096      9918954     58477205 /home/ftp/ld
D: sanity checking 1 elements
D: opening  db index       /tmp/foo/var/lib/rpm/Name create mode=0x42
D: computing 5 file fingerprints
Preparing packages for installation...
D: computing file dispositions
D: opening  db index       /var/lib/rpm/Basenames create mode=0x42
D: ========== +++ tunelp-2.12-10 athlon-linux 0x1
D: Expected size:        24074 = lead(96)+sigs(180)+pad(4)
+data(23794)
D:   Actual size:        24074
D:   install: tunelp-2.12-10 has 5 files, test = 0
tunelp-2.12-10
D: ========== Directories not explicitly included in package:
D:          0 /usr/sbin/
D:          1 /usr/share/man/es/man8/
D:          2 /usr/share/man/ja/man8/
D:          3 /usr/share/man/man8/
D:          4 /usr/share/man/pl/man8/
D: ==========
D: /usr directory created with perms 0755.
D: /usr/sbin directory created with perms 0755.
D: /usr/share directory created with perms 0755.
D: /usr/share/man directory created with perms 0755.
D: /usr/share/man/es directory created with perms 0755.
D: /usr/share/man/es/man8 directory created with perms 0755.
D: /usr/share/man/ja directory created with perms 0755.
D: /usr/share/man/ja/man8 directory created with perms 0755.
D: /usr/share/man/man8 directory created with perms 0755.
D: /usr/share/man/pl directory created with perms 0755.
D: /usr/share/man/pl/man8 directory created with perms 0755.
D: fini      100755  1 (   0,   0)      6520 /usr/sbin/tunelp;
40557baf
D: fini      100644  1 (   0,   0)      2466 
/usr/share/man/es/man8/tunelp.8.gz;40557baf
D: fini      100644  1 (   0,   0)      3242 
/usr/share/man/ja/man8/tunelp.8.gz;40557baf
D: fini      100644  1 (   0,   0)      2747 
/usr/share/man/man8/tunelp.8.gz;40557baf
D: fini      100644  1 (   0,   0)      3157 
/usr/share/man/pl/man8/tunelp.8.gz;40557baf
BZDIO:       3 reads,    18980 total bytes in 0.005070 secs
D:   +++ h#       1 Header SHA1 digest: OK 
(6b986353cce7b4780899267f186f3a0c4a6caef9)
D: adding "tunelp" to Name index.
D: adding 5 entries to Basenames index.
D: opening  db index       /var/lib/rpm/Group create mode=0x42
D: adding "Applications/System" to Group index.
D: opening  db index       /var/lib/rpm/Requirename create mode=0x42
D: adding 8 entries to Requirename index.
D: opening  db index       /var/lib/rpm/Providename create mode=0x42
D: adding "tunelp" to Providename index.
D: opening  db index       /var/lib/rpm/Dirnames create mode=0x42
D: adding 5 entries to Dirnames index.
D: opening  db index       /var/lib/rpm/Requireversion create 
mode=0x42
D: adding 8 entries to Requireversion index.
D: opening  db index       /var/lib/rpm/Provideversion create 
mode=0x42
D: adding "2.12-10" to Provideversion index.
D: opening  db index       /var/lib/rpm/Installtid create mode=0x42
D: adding 1 entries to Installtid index.
D: opening  db index       /var/lib/rpm/Sigmd5 create mode=0x42
D: adding 1 entries to Sigmd5 index.
D: opening  db index       /var/lib/rpm/Sha1header create mode=0x42
D: adding "6b986353cce7b4780899267f186f3a0c4a6caef9" to Sha1header 
index.
D: opening  db index       /var/lib/rpm/Filemd5s create mode=0x42
D: adding 5 entries to Filemd5s index.
D: opening  db index       /var/lib/rpm/Triggername create mode=0x42
D: closed   db index       /tmp/foo/var/lib/rpm/Filemd5s
D: closed   db index       /tmp/foo/var/lib/rpm/Sha1header
D: closed   db index       /tmp/foo/var/lib/rpm/Sigmd5
D: closed   db index       /tmp/foo/var/lib/rpm/Installtid
D: closed   db index       /tmp/foo/var/lib/rpm/Provideversion
D: closed   db index       /tmp/foo/var/lib/rpm/Requireversion
D: closed   db index       /tmp/foo/var/lib/rpm/Dirnames
D: closed   db index       /tmp/foo/var/lib/rpm/Triggername
D: closed   db index       /tmp/foo/var/lib/rpm/Providename
D: closed   db index       /tmp/foo/var/lib/rpm/Requirename
D: closed   db index       /tmp/foo/var/lib/rpm/Group
D: closed   db index       /tmp/foo/var/lib/rpm/Basenames
D: closed   db index       /tmp/foo/var/lib/rpm/Name
D: closed   db index       /tmp/foo/var/lib/rpm/Packages
rpmdb: /var/lib/rpm/Triggername: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Filemd5s: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Sha1header: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Sigmd5: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Installtid: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Provideversion: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Requireversion: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Dirnames: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Providename: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Requirename: unable to flush: No such file or 
directory
rpmdb: /var/lib/rpm/Group: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Basenames: unable to flush: No such file or 
directory
error: db4 error(2) from dbenv->close: No such file or directory
D: closed   db environment /tmp/foo/var/lib/rpm/Packages
[root@arm RPMS]#

Comment 7 Pawel A. Gajda 2004-03-15 15:05:10 UTC
Seems that db uses remebered index's path on close, 
so if one is opened under chroot environment, then cannot
be closed (flushed) outside chroot jail. With attached patch,
rpm's output looks as follows (notice that Packages and Name
are closing properly): 

dbopen /tmp/foo/var/lib/rpm/Packages chrooted=0
dbopen /tmp/foo/var/lib/rpm/Name chrooted=0
dbopen /var/lib/rpm/Basenames chrooted=1
dbopen /var/lib/rpm/Group chrooted=1
dbopen /var/lib/rpm/Requirename chrooted=1
dbopen /var/lib/rpm/Providename chrooted=1
dbopen /var/lib/rpm/Dirnames chrooted=1
dbopen /var/lib/rpm/Requireversion chrooted=1
dbopen /var/lib/rpm/Provideversion chrooted=1
dbopen /var/lib/rpm/Installtid chrooted=1
dbopen /var/lib/rpm/Sigmd5 chrooted=1
dbopen /var/lib/rpm/Sha1header chrooted=1
dbopen /var/lib/rpm/Filemd5s chrooted=1
dbclose /tmp/foo/var/lib/rpm/Filemd5s chrooted=0
dbclose /tmp/foo/var/lib/rpm/Sha1header chrooted=0
dbclose /tmp/foo/var/lib/rpm/Sigmd5 chrooted=0
dbclose /tmp/foo/var/lib/rpm/Installtid chrooted=0
dbclose /tmp/foo/var/lib/rpm/Provideversion chrooted=0
dbclose /tmp/foo/var/lib/rpm/Requireversion chrooted=0
dbclose /tmp/foo/var/lib/rpm/Dirnames chrooted=0
dbclose /tmp/foo/var/lib/rpm/Providename chrooted=0
dbclose /tmp/foo/var/lib/rpm/Requirename chrooted=0
dbclose /tmp/foo/var/lib/rpm/Group chrooted=0
dbclose /tmp/foo/var/lib/rpm/Basenames chrooted=0
dbclose /tmp/foo/var/lib/rpm/Name chrooted=0
dbclose /tmp/foo/var/lib/rpm/Packages chrooted=0
rpmdb: /var/lib/rpm/Filemd5s: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Sha1header: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Sigmd5: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Installtid: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Provideversion: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Requireversion: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Dirnames: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Providename: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Requirename: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Group: unable to flush: No such file or directory
rpmdb: /var/lib/rpm/Basenames: unable to flush: No such file or directory
error: db4 error(2) from dbenv->close: No such file or directory  



 

And here that patch
--- db3.c       Mon Mar 15 16:06:40 2004
+++ db3.c.verbose       Mon Mar 15 15:55:15 2004
@@ -783,2 +783,4 @@
                dbhome, (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)));
+       printf("dbclose %s/%s chrooted=%d\n", dbhome, (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)), 
+                       rpmdb->db_chrootDone);
 
@@ -1095,2 +1097,4 @@
                prDbiOpenFlags(oflags, 0), dbi->dbi_mode);
+    printf("dbopen %s/%s chrooted=%d\n", dbhome, (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)), 
+           rpmdb->db_chrootDone);
 



Comment 8 Jeff Johnson 2004-03-16 14:50:14 UTC
Yes, there is a reopen by path during close that does not
take into account the chroot prefix. The conditions that
trigger the reopen during close are what need to be addressed,
not teaching the reopen the new path.

Comment 9 Johnray Fuller 2004-07-30 16:15:51 UTC
When installing RPMs using a postinstallation script and using the
--nochoot option. The relevant bit of the script is:

               # echo "Installing $pkg ..."
               # echo "Installing $pkg ..." 1>&2
               $SYSROOT/bin/rpm --root $SYSROOT -Uvh --force --nodeps
$PKG_TO_INS 2>&1 | tee /tmp/rpmout
               cat /tmp/rpmout 1>&2
               if [ $? -ne 0 ]
               then
                       echo "Installation of $pkg failed or partially
failed"
                       echo "Installation of $pkg failed or partially
failed" 1>&2
                       echo $pkg >> $TMPLOG
               fi

So the script is using the *installed* rpm (/mnt/sysimage/bin/rpm) with
the --root flag and nodeps. I am able to easily reproduce this without
any nodeps or force flags.

At anyrate, the following are the errors they get:

Preparing...               
##################################################
TLSsend                  
##################################################
rpmdb: /var/lib/rpm/Triggername: No such file or directory
rpmdb: /var/lib/rpm/Triggername: cannot sync: No such file or directory
error: db4 error(2) from dbenv->close: No such file or directory

So in my testing it seems that any RPM will return this error, but the
RPMs *do* seem to install correctly (according to rpm -V <package name>
post installation).

So this leads to the following questions:

1> Is this behavior expected? (This same method worked with RHEL 2.1
AFAIKT, though I have not yet tested myself)

2> It appears that generic RPMs install, but would an RPM which uses
trigger actually installed correctly?

Thanks in advance for any help. 

Comment 10 Jeremy Katz 2005-04-19 18:38:39 UTC
Closing due to inactivity.  If this issue still occurs with current releases,
please reopen and set the release in which you've encountered the problem.


Note You need to log in before you can comment on or make changes to this bug.