Skip to content

Commit

Permalink
Merge pull request #177 from nextjournal/master
Browse files Browse the repository at this point in the history
Ignore sticky bit when validating permissions.
  • Loading branch information
takluyver authored Nov 16, 2019
2 parents 4101ed1 + 5ca11a7 commit b129001
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions jupyter_core/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,10 @@ def get_file_mode(fname):
"""
# Some filesystems (e.g., CIFS) auto-enable the execute bit on files. As a result, we
# should tolerate the execute bit on the file's owner when validating permissions - thus
# the missing one's bit on the third octet.
return stat.S_IMODE(os.stat(fname).st_mode) & 0o7677 # Use 4 octets since S_IMODE does the same
# should tolerate the execute bit on the file's owner when validating permissions - thus
# the missing least significant bit on the third octal digit. In addition, we also tolerate
# the sticky bit being set, so the lsb from the fourth octal digit is also removed.
return stat.S_IMODE(os.stat(fname).st_mode) & 0o6677 # Use 4 octal digits since S_IMODE does the same


@contextmanager
Expand Down Expand Up @@ -429,6 +430,6 @@ def secure_write(fname, binary=False):
file_mode = get_file_mode(fname)
if 0o0600 != file_mode:
raise RuntimeError("Permissions assignment failed for secure file: '{file}'."
"Got '{permissions}' instead of '0o0600'"
" Got '{permissions}' instead of '0o0600'."
.format(file=fname, permissions=oct(file_mode)))
yield f

0 comments on commit b129001

Please sign in to comment.