From 01e993a49ac30b400940fc031cc94ef893fc7200 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Mon, 2 May 2022 22:39:08 +0200 Subject: [PATCH] set umask for group-writable unix domain sockets --- gps303/collector.py | 5 ++++- gps303/lookaside.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gps303/collector.py b/gps303/collector.py index 8bcca30..9f305e5 100644 --- a/gps303/collector.py +++ b/gps303/collector.py @@ -1,6 +1,7 @@ """ TCP server that communicates with terminals """ from logging import getLogger +from os import umask from socket import socket, AF_INET6, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR from time import time from struct import pack @@ -140,9 +141,11 @@ class Clients: def runserver(conf): zctx = zmq.Context() zpub = zctx.socket(zmq.PUB) - zpub.bind(conf.get("collector", "publishurl")) zpull = zctx.socket(zmq.PULL) + oldmask = umask(0o117) + zpub.bind(conf.get("collector", "publishurl")) zpull.bind(conf.get("collector", "listenurl")) + umask(oldmask) tcpl = socket(AF_INET6, SOCK_STREAM) tcpl.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) tcpl.bind(("", conf.getint("collector", "port"))) diff --git a/gps303/lookaside.py b/gps303/lookaside.py index 085cbe9..60dcea7 100644 --- a/gps303/lookaside.py +++ b/gps303/lookaside.py @@ -2,6 +2,7 @@ from datetime import datetime, timezone from logging import getLogger +from os import umask from struct import pack import zmq @@ -16,7 +17,9 @@ log = getLogger("gps303/lookaside") def runserver(conf): zctx = zmq.Context() zpub = zctx.socket(zmq.PUB) + oldmask = umask(0o117) zpub.bind(conf.get("lookaside", "publishurl")) + umask(oldmask) zsub = zctx.socket(zmq.SUB) zsub.connect(conf.get("collector", "publishurl")) for protoname in ( -- 2.39.2