From f905fa626c7d11cb7d27bc1c4bf2c0c5b801865b Mon Sep 17 00:00:00 2001 From: Son NK Date: Sun, 8 Mar 2020 11:54:59 +0100 Subject: [PATCH] add GNUPGHOME config --- app/config.py | 14 ++++++++++++++ example.env | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/config.py b/app/config.py index a015df45..8161e9db 100644 --- a/app/config.py +++ b/app/config.py @@ -1,5 +1,8 @@ import os +import random +import string import subprocess +import tempfile from uuid import uuid4 from dotenv import load_dotenv @@ -154,6 +157,17 @@ WORDS_FILE_PATH = get_abs_path( os.environ.get("WORDS_FILE_PATH", "local_data/words_alpha.txt") ) +# Used to generate random email +if os.environ.get("GNUPGHOME"): + GNUPGHOME = get_abs_path(os.environ.get("GNUPGHOME")) +else: + letters = string.ascii_lowercase + random_dir_name = "".join(random.choice(letters) for _ in range(20)) + GNUPGHOME = f"/tmp/{random_dir_name}" + if not os.path.exists(GNUPGHOME): + os.mkdir(GNUPGHOME, mode=0o700) + + print("WARNING: Use a temp directory for GNUPGHOME", GNUPGHOME) # Github, Google, Facebook client id and secrets GITHUB_CLIENT_ID = os.environ.get("GITHUB_CLIENT_ID") diff --git a/example.env b/example.env index ce0b5eb9..410fdc9d 100644 --- a/example.env +++ b/example.env @@ -108,4 +108,7 @@ FACEBOOK_CLIENT_SECRET=to_fill # Flask profiler # FLASK_PROFILER_PATH=/tmp/flask-profiler.sql -# FLASK_PROFILER_PASSWORD=password \ No newline at end of file +# FLASK_PROFILER_PASSWORD=password + +# Where to store GPG Keyring +# GNUPGHOME=/tmp/gnupg