I've reported this upstream as I couldn't find the problem fixed even
in git master of today.

upstream bug report is at https://redmine.lighttpd.net/issues/3211

I'm attaching my trivial patch fixing the problem.  Given this is a regression
during distribution upgrade, it would be good to get the package updated with
this fix - before other Debian users fall into the same trap during their 
upgrade.

-- 
- Harald Welte <lafo...@gnumonks.org>          https://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)
>From 40d2ec1a65fe4d6621ee28d8250380846adced57 Mon Sep 17 00:00:00 2001
From: Harald Welte <lafo...@osmocom.org>
Date: Sun, 11 Jun 2023 18:27:56 +0200
Subject: [PATCH] [mod_dirindex] fix unreliable rendering of readme/header
 (closes: #3211)

If the stat_cache keeps the file open after we render a readme/header
file for the first time, we must re-wind the file cursor back to the
start.

This fixes a bug where only the first rendering of the readme/header
works, and subsequent HTTP responses are lacking it as long as the
stat_cache entry lives.
---
 src/mod_dirlisting.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c
index fdfdcdd5..7b152aba 100644
--- a/src/mod_dirlisting.c
+++ b/src/mod_dirlisting.c
@@ -644,6 +644,9 @@ static void http_list_directory_include_file(request_st * const r, const handler
                 buffer_clear(out);
             }
         }
+        /* rewind the file pointer, as the stat_cache may keep the fd open, resulting
+         * in this function trying to read again */
+        lseek(fd, 0, SEEK_SET);
         if (out != tb)
             chunkqueue_append_buffer_commit(cq);
 
-- 
2.40.1

Reply via email to