-
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 (#17398)
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
26 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,25 @@ | ||
--- 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) { | ||
--- a/lib/rpmts.c | ||
+++ b/lib/rpmts.c | ||
@@ -104,7 +104,7 @@ int rpmtsOpenDB(rpmts ts, int 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); | ||
+ rpmlog(RPMLOG_DEBUG, _("cannot open Packages database in %s\n"), dn); | ||
free(dn); | ||
} | ||
return rc; |
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