From 2d63d5ee78963a8f90dcdf93c461f89d326a5a18 Mon Sep 17 00:00:00 2001
From: Michael Schroeder <mls@suse.de>
Date: Mon, 3 Feb 2020 11:37:30 +0100
Subject: [PATCH] Permit ndb database queries on read-only media

See also commit a429c99e13fbe9926243f29b78df8d64222c4469 for db3.

URL:https://github.com/rpm-software-management/rpm/commit/2d63d5ee78963a8f90dcdf93c461f89d326a5a18
---
 lib/backend/ndb/glue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/backend/ndb/glue.c b/lib/backend/ndb/glue.c
index 90c10f8..d19da7c 100644
--- a/lib/backend/ndb/glue.c
+++ b/lib/backend/ndb/glue.c
@@ -161,7 +161,7 @@ static int ndb_Open(rpmdb rdb, rpmDbiTagVal rpmtag, dbiIndex * dbip, int flags)
 	    /* Open indexes readwrite if possible */
 	    ioflags = O_RDWR;
 	    rc = rpmxdbOpen(&ndbenv->xdb, rdb->db_pkgs->dbi_db, path, ioflags, 0666);
-	    if (rc && errno == EACCES) {
+	    if (rc && (errno == EACCES || errno == EROFS)) {
 		/* If it is not asked for rw explicitly, try to open ro */
 		if (!(oflags & O_RDWR)) {
 		    ioflags = O_RDONLY;
-- 
1.8.3.1

