From 559954b22257d30f5dad440f42d4b549c90c6794 Mon Sep 17 00:00:00 2001 From: marc Date: Sat, 20 Jun 2026 09:24:36 +0200 Subject: [PATCH] Fix WebDAV 500 when htpasswd file doesn't exist yet Create an empty /etc/micronas-webdav.passwd on first webdav config write so Apache returns 401 instead of 500 before any user password is set Co-Authored-By: Claude Sonnet 4.6 --- app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app.py b/app.py index 7f00f5a..c3dd293 100644 --- a/app.py +++ b/app.py @@ -306,6 +306,9 @@ def _write_webdav_conf(shares): ] with open(WEBDAV_CONF, 'w') as f: f.writelines(lines) + # Ensure the passwd file exists so Apache doesn't 500 before any user has logged in + if not os.path.exists(WEBDAV_PASSWD): + Path(WEBDAV_PASSWD).touch(mode=0o640) subprocess.run(['a2enconf', 'micronas-webdav'], capture_output=True) subprocess.run(['systemctl', 'reload', 'apache2'], capture_output=True)