From 0f9b3a5ac5f75113fbcd614bf2d615d00714c410 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 11 Jul 2024 20:25:25 -0500 Subject: [PATCH] secretsocket: Respect SECRET_SOCKET_PATH The `secretsocket` server will now create its IPC soket at the location specified by the `SECRET_SOCKET_PATH` environment variable, if set. This way, both `secretsocket` and `xactfetch` can be pointed to the same location with this single variable. --- secretsocket.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/secretsocket.py b/secretsocket.py index 01950d3..711fde9 100644 --- a/secretsocket.py +++ b/secretsocket.py @@ -15,7 +15,8 @@ log = logging.getLogger('secretsocket') ALLOW_UNKNOWN_PEER = os.environ.get('ALLOW_UNKNOWN_PEER') == '1' -XDG_RUNTIME_DIR = Path(os.environ['XDG_RUNTIME_DIR']) +SECRET_SOCKET_PATH = os.environ.get('SECRET_SOCKET_PATH') +XDG_RUNTIME_DIR = os.environ.get('XDG_RUNTIME_DIR') class Secret: @@ -176,7 +177,12 @@ def shutdown(signum, server): async def main(): logging.basicConfig(level=logging.DEBUG) - sock_path = XDG_RUNTIME_DIR / 'secretsocket/.ss' + if SECRET_SOCKET_PATH: + sock_path = Path(SECRET_SOCKET_PATH) + elif XDG_RUNTIME_DIR: + sock_path = Path(XDG_RUNTIME_DIR) / 'secretsocket/.ss' + else: + sock_path = Path('/tmp/.secretsocket') if not sock_path.parent.exists(): sock_path.parent.mkdir()