From beb5255cb2839b7b7030c1343d5d17c88e7f6b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 28 Jul 2021 20:39:52 +0200 Subject: [PATCH] Ensure omemo folder is created with mode 0700 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- poezio_omemo/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/poezio_omemo/__init__.py b/poezio_omemo/__init__.py index e862c3e..d6b4b77 100644 --- a/poezio_omemo/__init__.py +++ b/poezio_omemo/__init__.py @@ -74,7 +74,12 @@ class Plugin(E2EEPlugin): digest = hashlib.sha256(jid_str).digest() hashed_jid = base64.b32encode(digest).decode('US-ASCII') data_dir = os.path.join(DATA_HOME, 'omemo', hashed_jid) - os.makedirs(data_dir, exist_ok=True) + + try: + # Raise exception if folder exists so that we don't chmod again. + os.makedirs(data_dir, mode=0o700, exist_ok=False) + except OSError: # Folder already exists + pass try: self.core.xmpp.register_plugin(