[projects/pld-builder.new] acl, blacklist: read the files on first use, not on import

arekm arekm at pld-linux.org
Mon Oct 26 17:18:32 CET 2026


commit c6b2ccc3b932b7a5037def3161fe0b0935d612de
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sun Oct 25 02:02:56 2026 +0200

    acl, blacklist: read the files on first use, not on import
    
    Importing acl read acl.conf, so --help of six entry points failed with
    FileNotFoundError on a builder without configuration. Both files are now
    read when first needed; a missing or broken file still fails there, and
    try_reload() still picks up changes. request_handler_server reads them
    at start, as before: its forked children inherit them instead of each
    reading them again, and a missing file still stops the start.

 PLD_Builder/acl.py                    | 9 ++++++++-
 PLD_Builder/blacklist.py              | 8 ++++++--
 PLD_Builder/request_handler_server.py | 5 +++++
 3 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/PLD_Builder/acl.py b/PLD_Builder/acl.py
index 4033307..486c4e2 100644
--- a/PLD_Builder/acl.py
+++ b/PLD_Builder/acl.py
@@ -91,7 +91,14 @@ class User:
 
 class ACL_Conf:
     def __init__(self):
-        self.reload()
+        self.current_user = None
+
+    # acl.conf is read on first use, not on import, so --help works without it
+    def __getattr__(self, name):
+        if name in ("users", "acl_conf_mtime"):
+            self.reload()
+            return getattr(self, name)
+        raise AttributeError(name)
 
     def try_reload(self):
         mtime = os.stat(path.acl_conf)[stat.ST_MTIME]
diff --git a/PLD_Builder/blacklist.py b/PLD_Builder/blacklist.py
index b3bcd1f..ef80984 100644
--- a/PLD_Builder/blacklist.py
+++ b/PLD_Builder/blacklist.py
@@ -10,8 +10,12 @@ import status
 
 
 class Blacklist_File:
-    def __init__(self):
-        self.reload()
+    # the file is read on first use, not on import, so --help works without it
+    def __getattr__(self, name):
+        if name in ("blacklist", "blacklist_file_mtime"):
+            self.reload()
+            return getattr(self, name)
+        raise AttributeError(name)
 
     def try_reload(self):
         mtime = os.stat(path.blacklist_file)[stat.ST_MTIME]
diff --git a/PLD_Builder/request_handler_server.py b/PLD_Builder/request_handler_server.py
index 30a2109..d700456 100644
--- a/PLD_Builder/request_handler_server.py
+++ b/PLD_Builder/request_handler_server.py
@@ -13,6 +13,8 @@ from socketserver import ForkingMixIn
 import log
 import path
 import request_handler
+from acl import acl
+from blacklist import blacklist
 from config import config, init_conf
 
 _shutdown_signum = None
@@ -136,6 +138,9 @@ def main(srv_ssl=False):
     signal.signal(signal.SIGHUP, _on_shutdown_signal)
     signal.signal(signal.SIGINT, _on_shutdown_signal)
     init_conf()
+    # read once here: the forked children inherit them, and a missing file stops the start
+    acl.try_reload()
+    blacklist.try_reload()
     host = ""
     port = config.request_handler_server_port
     if srv_ssl:
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/ce9feb3c796ed049b6dd260a50d94d80feb1656d



More information about the pld-cvs-commit mailing list