From be53538738cd43ecfa12aedcecf0596ef1bb7020 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 16 Mar 2024 18:04:19 +0100 Subject: [PATCH] improve/extend mkcol logging --- radicale/app/mkcol.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/radicale/app/mkcol.py b/radicale/app/mkcol.py index 94207e32b..5bccc50c8 100644 --- a/radicale/app/mkcol.py +++ b/radicale/app/mkcol.py @@ -52,8 +52,12 @@ def do_MKCOL(self, environ: types.WSGIEnviron, base_prefix: str, logger.warning( "Bad MKCOL request on %r: %s", path, e, exc_info=True) return httputils.BAD_REQUEST - if (props.get("tag") and "w" not in permissions or - not props.get("tag") and "W" not in permissions): + collection_type = props.get("tag") or "UNKNOWN" + if props.get("tag") and "w" not in permissions: + logger.warning("MKCOL request %r (type:%s): %s", path, collection_type, "rejected because of missing rights 'w'") + return httputils.NOT_ALLOWED + if not props.get("tag") and "W" not in permissions: + logger.warning("MKCOL request %r (type:%s): %s", path, collection_type, "rejected because of missing rights 'W'") return httputils.NOT_ALLOWED with self._storage.acquire_lock("w", user): item = next(iter(self._storage.discover(path)), None) @@ -71,6 +75,7 @@ def do_MKCOL(self, environ: types.WSGIEnviron, base_prefix: str, self._storage.create_collection(path, props=props) except ValueError as e: logger.warning( - "Bad MKCOL request on %r: %s", path, e, exc_info=True) + "Bad MKCOL request on %r (type:%s): %s", path, collection_type, e, exc_info=True) return httputils.BAD_REQUEST + logger.info("MKCOL request %r (type:%s): %s", path, collection_type, "successful") return client.CREATED, {}, None