From b020fd4ad20ce63eeb5a5c9f454191f87de07509 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 2 Feb 2025 23:02:54 +0000 Subject: [PATCH] make some 403s less ambiguous in logs --- copyparty/httpcli.py | 8 ++++---- copyparty/metrics.py | 2 +- copyparty/multicast.py | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 2fcb66ca..697521f8 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -4825,7 +4825,7 @@ class HttpCli(object): def scanvol(self) -> bool: if not self.can_admin: - raise Pebkac(403, "not allowed for user " + self.uname) + raise Pebkac(403, "'scanvol' not allowed for user " + self.uname) if self.args.no_rescan: raise Pebkac(403, "the rescan feature is disabled in server config") @@ -4848,7 +4848,7 @@ class HttpCli(object): raise Pebkac(400, "only config files ('cfg') can be reloaded rn") if not self.avol: - raise Pebkac(403, "not allowed for user " + self.uname) + raise Pebkac(403, "'reload' not allowed for user " + self.uname) if self.args.no_reload: raise Pebkac(403, "the reload feature is disabled in server config") @@ -4858,7 +4858,7 @@ class HttpCli(object): def tx_stack(self) -> bool: if not self.avol and not [x for x in self.wvol if x in self.rvol]: - raise Pebkac(403, "not allowed for user " + self.uname) + raise Pebkac(403, "'stack' not allowed for user " + self.uname) if self.args.no_stack: raise Pebkac(403, "the stackdump feature is disabled in server config") @@ -5421,7 +5421,7 @@ class HttpCli(object): def handle_rm(self, req: list[str]) -> bool: if not req and not self.can_delete: - raise Pebkac(403, "not allowed for user " + self.uname) + raise Pebkac(403, "'delete' not allowed for user " + self.uname) if self.args.no_del: raise Pebkac(403, "the delete feature is disabled in server config") diff --git a/copyparty/metrics.py b/copyparty/metrics.py index 26413147..0ad65abe 100644 --- a/copyparty/metrics.py +++ b/copyparty/metrics.py @@ -18,7 +18,7 @@ class Metrics(object): def tx(self, cli: "HttpCli") -> bool: if not cli.avol: - raise Pebkac(403, "not allowed for user " + cli.uname) + raise Pebkac(403, "'stats' not allowed for user " + cli.uname) args = cli.args if not args.stats: diff --git a/copyparty/multicast.py b/copyparty/multicast.py index 3f51d97d..6d6507f8 100644 --- a/copyparty/multicast.py +++ b/copyparty/multicast.py @@ -163,6 +163,7 @@ class MCast(object): sck.settimeout(None) sck.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: + # safe for this purpose; https://lwn.net/Articles/853637/ sck.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) except: pass