From 26e36775157a53ee68eff33b4863bb0e8f60f5c8 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 18 Sep 2009 11:51:21 +0300 Subject: [PATCH] Per-dbi root and home dont make sense, always use rpmdb paths --- lib/backend/db3.c | 10 +++++----- lib/backend/dbconfig.c | 6 ------ lib/backend/sqlite.c | 13 ++++++------- lib/rpmdb_internal.h | 2 -- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/backend/db3.c b/lib/backend/db3.c index 92573a0..1e786ba 100644 --- a/lib/backend/db3.c +++ b/lib/backend/db3.c @@ -192,7 +192,7 @@ static int db_init(dbiIndex dbi, const char * dbhome, DB_ENV ** dbenvp) const char * root; char * tmpdir; - root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root); + root = rpmdb->db_root; if (rstreq(root, "/") || rpmdb->db_chrootDone) root = NULL; tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL); @@ -461,10 +461,10 @@ static int db3close(dbiIndex dbi, unsigned int flags) /* * Get the prefix/root component and directory path. */ - root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root); + root = rpmdb->db_root; if (rstreq(root, "/") || rpmdb->db_chrootDone) root = NULL; - home = (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home); + home = rpmdb->db_home; dbhome = rpmGenPath(root, home, NULL); if (dbi->dbi_temporary) { @@ -593,10 +593,10 @@ static int db3open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip) /* * Get the prefix/root component and directory path. */ - root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root); + root = rpmdb->db_root; if (rstreq(root, "/") || rpmdb->db_chrootDone) root = NULL; - home = (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home); + home = rpmdb->db_home; dbhome = rpmGenPath(root, home, NULL); if (dbi->dbi_temporary) { diff --git a/lib/backend/dbconfig.c b/lib/backend/dbconfig.c index 210a2e3..49ef2e6 100644 --- a/lib/backend/dbconfig.c +++ b/lib/backend/dbconfig.c @@ -106,10 +106,6 @@ struct poptOption rdbOptions[] = { { "unknown", 0,POPT_ARG_VAL, &db3dbi.dbi_type, DB_UNKNOWN, NULL, NULL }, - { "root", 0,POPT_ARG_STRING, &db3dbi.dbi_root, 0, - NULL, NULL }, - { "home", 0,POPT_ARG_STRING, &db3dbi.dbi_home, 0, - NULL, NULL }, { "file", 0,POPT_ARG_STRING, &db3dbi.dbi_file, 0, NULL, NULL }, { "subfile", 0,POPT_ARG_STRING, &db3dbi.dbi_subfile, 0, @@ -248,8 +244,6 @@ struct poptOption rdbOptions[] = { dbiIndex db3Free(dbiIndex dbi) { if (dbi) { - dbi->dbi_root = _free(dbi->dbi_root); - dbi->dbi_home = _free(dbi->dbi_home); dbi->dbi_file = _free(dbi->dbi_file); dbi->dbi_subfile = _free(dbi->dbi_subfile); dbi->dbi_tmpdir = _free(dbi->dbi_tmpdir); diff --git a/lib/backend/sqlite.c b/lib/backend/sqlite.c index d5af844..b28b1f1 100644 --- a/lib/backend/sqlite.c +++ b/lib/backend/sqlite.c @@ -101,17 +101,18 @@ static int sqlInRoot = 0; static void enterChroot(dbiIndex dbi) { int xx; + rpmdb db = dbi->dbi_rpmdb; - if (rstreq(dbi->dbi_root, "/") || dbi->dbi_rpmdb->db_chrootDone || sqlInRoot) + if (rstreq(db->db_root, "/") || db->db_chrootDone || sqlInRoot) /* Nothing to do, was not already in chroot */ return; if (_debug) -fprintf(stderr, "sql:chroot(%s)\n", dbi->dbi_root); +fprintf(stderr, "sql:chroot(%s)\n", db->db_root); sqlCwd = rpmGetCwd(); xx = chdir("/"); - xx = chroot(dbi->dbi_root); + xx = chroot(db->db_root); assert(xx == 0); sqlInRoot=1; } @@ -119,8 +120,9 @@ assert(xx == 0); static void leaveChroot(dbiIndex dbi) { int xx; + rpmdb db = dbi->dbi_rpmdb; - if (rstreq(dbi->dbi_root, "/") || dbi->dbi_rpmdb->db_chrootDone || !sqlInRoot) + if (rstreq(db->db_root, "/") || db->db_chrootDone || !sqlInRoot) /* Nothing to do, not in chroot */ return; @@ -820,9 +822,6 @@ static int sql_open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip) root = rpmdb->db_root; home = rpmdb->db_home; - dbi->dbi_root = root; - dbi->dbi_home = home; - dbfile = rpmTagGetName(dbi->dbi_rpmtag); enterChroot(dbi); diff --git a/lib/rpmdb_internal.h b/lib/rpmdb_internal.h index 009b5a0..1318303 100644 --- a/lib/rpmdb_internal.h +++ b/lib/rpmdb_internal.h @@ -161,8 +161,6 @@ struct _dbiVec { * Describes an index database (implemented on Berkeley db3 functionality). */ struct _dbiIndex { - char * dbi_root; /*!< chroot(2) component of path */ - char * dbi_home; /*!< directory component of path */ char * dbi_file; /*!< file component of path */ char * dbi_subfile; char * dbi_tmpdir; /*!< temporary directory */ -- 2.7.4