solvertools icon indicating copy to clipboard operation
solvertools copied to clipboard

Is r+b permission needed in _open_mmap?

Open vEnhance opened this issue 1 year ago • 0 comments

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.

vEnhance avatar Jan 25 '25 18:01 vEnhance