Mop up leftover root/home foobar
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 18 Sep 2009 08:56:05 +0000 (11:56 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 21 Sep 2009 06:38:56 +0000 (09:38 +0300)
lib/backend/db3.c
lib/backend/sqlite.c

index 1e786ba..d4e29da 100644 (file)
@@ -189,13 +189,8 @@ static int db_init(dbiIndex dbi, const char * dbhome, DB_ENV ** dbenvp)
            xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
        }
        if (dbi->dbi_tmpdir) {
-           const char * root;
-           char * tmpdir;
-
-           root = rpmdb->db_root;
-           if (rstreq(root, "/") || rpmdb->db_chrootDone)
-               root = NULL;
-           tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL);
+           const char * root = rpmdb->db_chrootDone ? NULL : rpmdb->db_root;
+           char * tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL);
            xx = dbenv->set_tmp_dir(dbenv, tmpdir);
            xx = cvtdberr(dbi, "dbenv->set_tmp_dir", xx, _debug);
            tmpdir = _free(tmpdir);
@@ -448,8 +443,7 @@ static int db3stat(dbiIndex dbi, unsigned int flags)
 static int db3close(dbiIndex dbi, unsigned int flags)
 {
     rpmdb rpmdb = dbi->dbi_rpmdb;
-    const char * root;
-    const char * home;
+    const char * root = rpmdb->db_chrootDone ? NULL : rpmdb->db_root;
     char * dbhome;
     const char * dbfile;
     DB * db = dbi->dbi_db;
@@ -461,12 +455,7 @@ static int db3close(dbiIndex dbi, unsigned int flags)
     /*
      * Get the prefix/root component and directory path.
      */
-    root = rpmdb->db_root;
-    if (rstreq(root, "/") || rpmdb->db_chrootDone)
-       root = NULL;
-    home = rpmdb->db_home;
-
-    dbhome = rpmGenPath(root, home, NULL);
+    dbhome = rpmGenPath(root, rpmdb->db_home, NULL);
     if (dbi->dbi_temporary) {
        dbfile = NULL;
     } else {
@@ -566,8 +555,7 @@ exit:
 static int db3open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip)
 {
     extern const struct _dbiVec db3vec;
-    const char * root;
-    const char * home;
+    const char * root = rpmdb->db_chrootDone ? NULL : rpmdb->db_root;
     char * dbhome;
     const char * dbfile;
     dbiIndex dbi = NULL;
@@ -593,12 +581,7 @@ static int db3open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip)
     /*
      * Get the prefix/root component and directory path.
      */
-    root = rpmdb->db_root;
-    if (rstreq(root, "/") || rpmdb->db_chrootDone)
-       root = NULL;
-    home = rpmdb->db_home;
-
-    dbhome = rpmGenPath(root, home, NULL);
+    dbhome = rpmGenPath(root, rpmdb->db_home, NULL);
     if (dbi->dbi_temporary) {
        dbfile = NULL;
     } else {
index b28b1f1..cf0d397 100644 (file)
@@ -796,8 +796,6 @@ static int sql_open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip)
 {
     extern const struct _dbiVec sqlitevec;
    
-    char * root;
-    char * home;
     char * dbhome;
     const char * dbfile;  
     char * dbfname;
@@ -816,12 +814,6 @@ static int sql_open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip)
     if ((dbi = db3New(rpmdb, rpmtag)) == NULL)
        return 1;
 
-   /*
-     * Get the prefix/root component and directory path
-     */
-    root = rpmdb->db_root;
-    home = rpmdb->db_home;
-    
     dbfile = rpmTagGetName(dbi->dbi_rpmtag);
 
 enterChroot(dbi);
@@ -835,7 +827,7 @@ enterChroot(dbi);
 
     dbi->dbi_mode=O_RDWR;
        
-    dbhome = rpmGenPath(NULL, home, NULL);
+    dbhome = rpmGenPath(NULL, rpmdb->db_home, NULL);
 
     /* 
      * Create the /var/lib/rpm directory if it doesn't exist (root only).