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 <noreply@anthropic.com>
This commit is contained in:
marcandClaude Sonnet 4.6 committed 2026-06-20 09:24:36 +02:00
1 parent 9db51ca927
commit 559954b222
1 file changed
+3
+3
View File
@@ -306,6 +306,9 @@ def _write_webdav_conf(shares):
] ]
with open(WEBDAV_CONF, 'w') as f: with open(WEBDAV_CONF, 'w') as f:
f.writelines(lines) 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(['a2enconf', 'micronas-webdav'], capture_output=True)
subprocess.run(['systemctl', 'reload', 'apache2'], capture_output=True) subprocess.run(['systemctl', 'reload', 'apache2'], capture_output=True)