-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[omnibus] Don't create RPM database if it doesn't exist already
On Linux distributions not using the RPM package manager (Debian, Ubuntu, etc.), the rpm probe of OpenSCAP could initialize the sqlite RPM database into the /var/lib/rpm, directory, as a side effect. This change adds a new patch "rpmdb-no-create" to the RPM package. This patch changes the openDatabase function to prevent creation of the RPM database when it doesn't exist already.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- a/lib/rpmdb.c | ||
+++ b/lib/rpmdb.c | ||
@@ -463,6 +463,11 @@ static int openDatabase(const char * prefix, | ||
if (db == NULL) | ||
return 1; | ||
|
||
+ /* Don't create db if it doesn't exist already */ | ||
+ struct stat st; | ||
+ if (stat(rpmdbHome(db), &st) < 0) | ||
+ return 1; | ||
+ | ||
/* Try to ensure db home exists, error out if we can't even create */ | ||
rc = rpmioMkpath(rpmdbHome(db), 0755, getuid(), getgid()); | ||
if (rc == 0) { | ||
diff --git a/lib/rpmts.c b/lib/rpmts.c | ||
index 7a717b87d..21a2d3bec 100644 | ||
--- a/lib/rpmts.c | ||
+++ b/lib/rpmts.c | ||
@@ -91,8 +91,6 @@ int rpmtsCloseDB(rpmts ts) | ||
|
||
int rpmtsOpenDB(rpmts ts, int dbmode) | ||
{ | ||
- int rc = 0; | ||
- | ||
if (ts->rdb != NULL && ts->dbmode == dbmode) | ||
return 0; | ||
|
||
@@ -101,13 +99,7 @@ int rpmtsOpenDB(rpmts ts, int dbmode) | ||
/* XXX there's a potential db lock race here. */ | ||
|
||
ts->dbmode = dbmode; | ||
- rc = rpmdbOpen(ts->rootDir, &ts->rdb, ts->dbmode, 0644); | ||
- if (rc) { | ||
- char * dn = rpmGetPath(ts->rootDir, "%{_dbpath}", NULL); | ||
- rpmlog(RPMLOG_ERR, _("cannot open Packages database in %s\n"), dn); | ||
- free(dn); | ||
- } | ||
- return rc; | ||
+ return rpmdbOpen(ts->rootDir, &ts->rdb, ts->dbmode, 0644); | ||
} | ||
|
||
int rpmtsInitDB(rpmts ts, int perms) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters