diff --git a/larigira/config.py b/larigira/config.py index 08a155d..f4288b8 100644 --- a/larigira/config.py +++ b/larigira/config.py @@ -16,6 +16,7 @@ def get_conf(prefix="LARIGIRA_"): conf["CONTINOUS_AUDIOSPEC"] = dict(kind="mpd", howmany=1) conf["MPD_HOST"] = os.getenv("MPD_HOST", "localhost") conf["MPD_PORT"] = int(os.getenv("MPD_PORT", "6600")) + conf["UMASK"] = None conf["CACHING_TIME"] = 10 conf["DB_URI"] = os.path.join(conf_dir, "db.json") conf["SCRIPTS_PATH"] = os.path.join(conf_dir, "scripts") diff --git a/larigira/main.py b/larigira/main.py index d82b878..fba9de6 100644 --- a/larigira/main.py +++ b/larigira/main.py @@ -60,12 +60,6 @@ def sd_notify(ready=False, status=None): def main(): - tempfile.tempdir = os.environ["TMPDIR"] = os.path.join( - os.getenv("TMPDIR", "/tmp"), "larigira.%d" % os.getuid() - ) - if not os.path.isdir(os.environ["TMPDIR"]): - os.makedirs(os.environ["TMPDIR"]) - if get_conf()["LOG_CONFIG"]: logging.config.fileConfig( get_conf()["LOG_CONFIG"], disable_existing_loggers=True @@ -91,6 +85,20 @@ def main(): "Starting larigira with this conf:\n%s", json.dumps(get_conf(), indent=2), ) + + if get_conf()["UMASK"]: + umask = int(get_conf()["UMASK"], base=8) + logging.debug( + "Setting umask %s (decimal: %d)", get_conf()["UMASK"], umask + ) + os.umask(umask) + + tempfile.tempdir = os.environ["TMPDIR"] = os.path.join( + os.getenv("TMPDIR", "/tmp"), "larigira.%d" % os.getuid() + ) + if not os.path.isdir(os.environ["TMPDIR"]): + os.makedirs(os.environ["TMPDIR"]) + if get_conf()["MPD_WAIT_START"]: while True: