Skip to content

Commit 28510c9

Browse files
committed
Set mod of history file to 0600 (fixes bpython#489)
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at> (cherry picked from commit d4d9616)
1 parent 87470ef commit 28510c9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bpython/history.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from __future__ import unicode_literals
2727
import io
2828
import os
29+
import stat
2930
from itertools import islice
3031
from six.moves import range
3132

@@ -187,6 +188,8 @@ def load_from(self, fd):
187188
return entries
188189

189190
def save(self, filename, encoding, lines=0):
191+
fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.TRUNC,
192+
stat.S_IRUSR | stat.S_IWUSR)
190193
with io.open(filename, 'w', encoding=encoding,
191194
errors='ignore') as hfile:
192195
with FileLock(hfile):
@@ -204,7 +207,9 @@ def append_reload_and_write(self, s, filename, encoding):
204207
return self.append(s)
205208

206209
try:
207-
with io.open(filename, 'a+', encoding=encoding,
210+
fd = os.open(filename, os.O_APPEND | os.O_RDWR | os.O_CREAT,
211+
stat.S_IRUSR | stat.S_IWUSR)
212+
with io.open(fd, 'a+', encoding=encoding,
208213
errors='ignore') as hfile:
209214
with FileLock(hfile):
210215
# read entries

0 commit comments

Comments
 (0)