Skip to content

Is r+b permission needed in _open_mmap? #8

@vEnhance

Description

@vEnhance

I was wondering whether the following change would cause any issues:

diff --git a/solvertools/wordlist.py b/solvertools/wordlist.py
index 757abc7..f4e34b7 100644
--- a/solvertools/wordlist.py
+++ b/solvertools/wordlist.py
@@ -423,7 +423,7 @@ class Wordlist:
         return "Wordlist(%r)" % self.name
 
     def _open_mmap(self, path):
-        openfile = open(path, "r+b")
+        openfile = open(path, "rb")
         mm = mmap.mmap(openfile.fileno(), 0, access=mmap.ACCESS_READ)
         return mm

I noticed the addition of + causes permission issues if solvertools was installed with sudo or similar, since in that case an ordinary user doesn't expect to have write permissions to the wordlist file.

So far on my system changing the r+b to rb doesn't seem to have caused any issues as far as I can tell, but I figured I should double check if I'm missing anything. If not, I would be happy to open a one-line PR to change this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions