Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is r+b permission needed in _open_mmap? #8

Open
vEnhance opened this issue Jan 25, 2025 · 0 comments
Open

Is r+b permission needed in _open_mmap? #8

vEnhance opened this issue Jan 25, 2025 · 0 comments

Comments

@vEnhance
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant