From b3ed4ec1b1943ffc74a5877cc6f8cb85c37da885 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 18 Sep 2009 11:56:05 +0300 Subject: [PATCH] Mop up leftover root/home foobar --- lib/backend/db3.c | 29 ++++++----------------------- lib/backend/sqlite.c | 10 +--------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/lib/backend/db3.c b/lib/backend/db3.c index 1e786ba..d4e29da 100644 --- a/lib/backend/db3.c +++ b/lib/backend/db3.c @@ -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 { diff --git a/lib/backend/sqlite.c b/lib/backend/sqlite.c index b28b1f1..cf0d397 100644 --- a/lib/backend/sqlite.c +++ b/lib/backend/sqlite.c @@ -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). -- 2.7.4