Skip to content

Commit

Permalink
When creating top-level export directory, make accessible only by use…
Browse files Browse the repository at this point in the history
…r, for privacy.
  • Loading branch information
huyz committed Aug 25, 2020
1 parent 19277ad commit 5517e93
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name="wayslack2",
version="0.4.0",
version="0.4.1",
url="https://github.com/huyz/wayslack",
author="Huy Z",
author_email="[email protected]",
Expand Down
8 changes: 8 additions & 0 deletions wayslack.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import hashlib
import argparse
import codecs
import stat
from Queue import Queue
from random import random
from threading import Thread
Expand Down Expand Up @@ -1218,6 +1219,13 @@ def __init__(self, slack, opts):
self.dir = opts["dir"]
self.download_files = opts.get("download_files", True)
self.slack = slack
# For privacy, the top-level directory should be accessible by only the
# system user. But if the directory already exists, we assume the user
# has already set the mode as they like it.
if not os.path.exists(self.dir):
os.mkdir(self.dir)
mode = stat.S_IMODE(os.stat(self.dir).st_mode)
os.chmod(self.dir, mode & ~stat.S_IRWXG & ~stat.S_IRWXO)
self.path = pathlib.Path(self.dir)
self.emoji = ArchiveEmoji(self, self.path / "_emoji")
self.files = ArchiveFiles(self, self.path / "_files")
Expand Down

0 comments on commit 5517e93

Please sign in to comment.