File: mod_webdav-log-trace-for-EACCES-on-PUT.patch

package info (click to toggle)
lighttpd 1.4.79-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 7,492 kB
  • sloc: ansic: 99,486; perl: 2,607; sh: 783; yacc: 726; makefile: 705
file content (58 lines) | stat: -rw-r--r-- 2,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 85e4a9937dc870e4907d15f301a00deea4c950ab Mon Sep 17 00:00:00 2001
From: Glenn Strauss <gstrauss@gluelogic.com>
Date: Tue, 6 May 2025 23:47:41 -0400
Subject: [PATCH] [mod_webdav] log trace for EACCES on PUT
Origin: upstream, https://git.lighttpd.net/lighttpd/lighttpd1.4/commit/85e4a9937dc870e4907d15f301a00deea4c950ab
Forwarded: not-needed

output trace, e.g. for hardenend systemd lighttpd.service with
  ProtectHome=yes
where pre-existing configs might now fail PUT requests to
mod_webdav if writing files to home directories

x-ref:
  "lighttpd-mod-webdav: Regression 1.4.79-1 webdav PUT gives HTTP 500, 1.4.77-1 works"
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1103710
---
 src/mod_webdav.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/mod_webdav.c b/src/mod_webdav.c
index ee7990ce..e43bf3bb 100644
--- a/src/mod_webdav.c
+++ b/src/mod_webdav.c
@@ -4627,6 +4627,16 @@ mod_webdav_put_0 (request_st * const r, const plugin_config * const pconf)
         return HANDLER_FINISHED;
     }
 
+    /*if (errno == EACCES || errno == EPERM || errno == EROFS)*/
+    {
+        log_perror(r->conf.errh, __FILE__, __LINE__,
+          "open(%s, O_WRONLY|...)", r->physical.path.ptr);
+      #ifdef __linux__
+        log_error(r->conf.errh, __FILE__, __LINE__,
+          "check systemd lighttpd.service; e.g. ProtectHome=yes");
+      #endif
+    }
+
     http_status_set_error(r, 500); /* Internal Server Error */
     return HANDLER_FINISHED;
 }
@@ -4688,7 +4698,14 @@ mod_webdav_put_prep (request_st * const r, const plugin_config * const pconf)
           case ENOTDIR:
             http_status_set_error(r, 409); /* Conflict */
             break;
+          /*case EACCES: case EPERM: case EROFS:*/
           default:
+            log_perror(r->conf.errh, __FILE__, __LINE__,
+              "open() tmpfile for %s", r->physical.path.ptr);
+           #ifdef __linux__
+            log_error(r->conf.errh, __FILE__, __LINE__,
+              "check systemd lighttpd.service; e.g. ProtectHome=yes");
+           #endif
             http_status_set_error(r, 500); /* Internal Server Error */
             break;
         }
-- 
2.49.0