https://bugs.openldap.org/show_bug.cgi?id=9861

          Issue ID: 9861
           Summary: Read-only databases can't be opened - regression
                    introduced with da0527ac
           Product: LMDB
           Version: unspecified
          Hardware: aarch64
                OS: Mac OS
            Status: UNCONFIRMED
          Keywords: needs_review
          Severity: normal
          Priority: ---
         Component: liblmdb
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Created attachment 905
  --> https://bugs.openldap.org/attachment.cgi?id=905&action=edit
Reduced simple test to open the environment that fails

The ability to open an environment in read-only mode when the file permissions
is 'read only' for the user is no longer possible after the commit
da0527ac75b811419b7007202799f96b2edb5aef. 

It is simply reproduced by creating a database with e.g. mtest.c, then changing
the permissions to read-only, then running another trivial program trying to
open the environment in read-only mode / no-lock mode fails.

Specifically, after some investigation it seems that the check on line 5516 "if
(!(flags & (MDB_RDONLY|MDB_WRITEMAP))) {" was removed in the above commit such
that mdb_fopen() is called (presumably incorrectly?).

Returning that guard check seems to restore functionality, but I'm not familiar
enough with the code base to say that is a valid fix - but seems likely.

I applied that single change here:
https://github.com/hassila/swift-lmdb/tree/hassila-mdb-merge-patch
with this commit:
https://github.com/hassila/swift-lmdb/commit/c940b4c807c278cea43d2e3858dc22f7c0a2b5ca

To reproduce with a clean checkout:
1. make 
2. mkdir tested
3. ./mtest
4. chmod -wx testdb/data.mdb
5. run the attached program (reduced from real code base)

-- 
You are receiving this mail because:
You are on the CC list for the issue.

Reply via email to