]> www.average.org Git - loctrkd.git/commitdiff
set umask for group-writable unix domain sockets
authorEugene Crosser <crosser@average.org>
Mon, 2 May 2022 20:39:08 +0000 (22:39 +0200)
committerEugene Crosser <crosser@average.org>
Mon, 2 May 2022 20:44:14 +0000 (22:44 +0200)
gps303/collector.py
gps303/lookaside.py

index 8bcca303a627e75b9220fa89d0cdf5f81f761357..9f305e55f60197f38d84e820a793192bb93abbc2 100644 (file)
@@ -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")))
index 085cbe9a31b65c65057d6fa150158560658ef4f4..60dcea73f54b5ad1fe52128976b8d532cce95203 100644 (file)
@@ -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 (