packages (rpm-4_5): rpm/rpm-chroot-hack.patch - adopted by patch from jbj: ...

glen glen at pld-linux.org
Fri Oct 16 01:20:10 CEST 2009


Author: glen                         Date: Thu Oct 15 23:20:10 2009 GMT
Module: packages                      Tag: rpm-4_5
---- Log message:
- adopted by patch from jbj:
This patch is a brutally simple solution to
illustrate the logic needed in Open(2) to
solve the
        chroot /root/temp rpm -q foo
issue.
also worth to note:
01:17:46  jbj> note that all of the rpmdb code is changing to support transactionally protected system calls and rpmdb
               access.
01:18:30  jbj> which adds Yet More State, called Log Sequence Numbers, and /var/lib/rpm/log.00000000n files, which have
               to managed as well.
01:18:56  jbj> chroot & dbenv expectations simply will not matter.

---- Files affected:
packages/rpm:
   rpm-chroot-hack.patch (1.1.2.1.2.1 -> 1.1.2.1.2.2) 

---- Diffs:

================================================================
Index: packages/rpm/rpm-chroot-hack.patch
diff -u packages/rpm/rpm-chroot-hack.patch:1.1.2.1.2.1 packages/rpm/rpm-chroot-hack.patch:1.1.2.1.2.2
--- packages/rpm/rpm-chroot-hack.patch:1.1.2.1.2.1	Sat Jun  6 16:58:29 2009
+++ packages/rpm/rpm-chroot-hack.patch	Fri Oct 16 01:20:05 2009
@@ -1,26 +1,28 @@
---- rpm-4.5/rpmdb/db3.c~	2009-06-06 17:54:26.000000000 +0300
-+++ rpm-4.5/rpmdb/db3.c	2009-06-06 17:55:36.050580710 +0300
-@@ -1329,6 +1329,8 @@
- 	} else {
- assert(rpmdb && rpmdb->db_dbenv);
- 	    dbenv = rpmdb->db_dbenv;
-+	    if (rpmdb->db_chrootDone)
-+		    dbenv->set_data_dir(dbenv, dbhome);
- 	    rpmdb->db_opens++;
- 	}
- 	/*@=mods@*/
-@@ -1511,13 +1511,7 @@
- 		if (dbfile)
- 		    t = stpcpy( stpcpy( t, "/"), dbfile);
- /*@=boundswrite@*/
--#ifdef	HACK	/* XXX necessary to support dbsubfile */
--		dbpath = (!dbi->dbi_use_dbenv && !dbi->dbi_temporary)
--			? dbfullpath : dbfile;
--#else
--		dbpath = (!dbi->dbi_temporary)
--			? dbfullpath : dbfile;
--#endif
-+		dbpath = (!dbi->dbi_temporary) ? dbfullpath : dbfile;
+--- rpm-4.5/rpmio/rpmrpc.c~	2009-10-16 01:18:18.566743349 +0300
++++ rpm-4.5/rpmio/rpmrpc.c	2009-10-16 01:18:21.863999841 +0300
+@@ -179,5 +179,6 @@
+ {
+     const char * lpath;
+     int ut = urlPath(path, &lpath);
++    int fdno;
  
- #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
- 		rc = (db->open)(db, txnid, dbpath, dbsubfile,
+ if (_rpmio_debug)
+@@ -212,7 +213,17 @@
+     if (mode == 0)
+ 	mode = 0644;
+ #endif
+-    return open(path, flags, mode);
++    fdno = open(path, flags, mode);
++    /* XXX if the open(2) fails, try to strip a possible chroot(2) prefix. */
++    if (fdno < 0 && errno == ENOENT) {
++        const char *dbpath = rpmExpand("%{_dbpath}", "/", NULL);
++        const char *fn = strstr(path + 1, dbpath);
++        if (fn)
++            fdno = open(fn, flags, mode);
++        if (dbpath)
++        	 dbpath = _free(dbpath);
++    }
++    return fdno;
+ }
+ 
+ /* XXX rpmdb.c: analogue to rename(2). */
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/rpm/rpm-chroot-hack.patch?r1=1.1.2.1.2.1&r2=1.1.2.1.2.2&f=u



More information about the pld-cvs-commit mailing list