Skip to content

Commit

Permalink
[omnibus] Don't create RPM database if it doesn't exist already (#17398)
Browse files Browse the repository at this point in the history
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
0intro authored Jun 1, 2023
1 parent f2d17a3 commit 31be8f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions omnibus/config/patches/rpm/rpmdb-no-create.patch
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;
1 change: 1 addition & 0 deletions omnibus/config/software/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
env["CFLAGS"] << " -fPIC"

patch source: "0001-Include-fcntl.patch", env: env # fix build
patch source: "rpmdb-no-create.patch", env: env # don't create db if it doesn't exist already

update_config_guess

Expand Down

0 comments on commit 31be8f5

Please sign in to comment.