From sbanya at fastmail.com Tue Mar 9 02:57:00 2021 From: sbanya at fastmail.com (Samuel Banya) Date: Mon, 08 Mar 2021 21:57:00 -0500 Subject: =?UTF-8?Q?Question_Regarding_How_To_Get_A_"Downloads"_Section_On_My_'cgi?= =?UTF-8?Q?t'_Instance?= Message-ID: Hey there, I've been tweaking my cgit instance a bit, and added a dark theme via the CSS sheet. I would like to add a similar section on how you have a releases section on the main cgit instance, aka the Downloads section that allows you to download an entire zip of a given project: - https://git.zx2c4.com/cgit/ Would love to have this for a utility I made on my public cgit repo. Thanks, Sam From pwr at bydasein.com Tue Mar 9 03:01:59 2021 From: pwr at bydasein.com (Paul W. Rankin) Date: Tue, 9 Mar 2021 13:01:59 +1000 Subject: Question Regarding How To Get A "Downloads" Section On My 'cgit' Instance In-Reply-To: References: Message-ID: <7BF7C4A3-F71F-417C-940C-AA8219229151@bydasein.com> > On 9 Mar 2021, at 12:57 pm, Samuel Banya wrote: > > I would like to add a similar section on how you have a releases section on the main cgit instance, aka the Downloads section that allows you to download an entire zip of a given project: > - https://git.zx2c4.com/cgit/ Add snapshots to your cgitrc, e.g. snapshots=tar.gz zip See: https://git.zx2c4.com/cgit/tree/cgitrc.5.txt#n407 From unit193 at unit193.net Fri Mar 12 06:41:47 2021 From: unit193 at unit193.net (Unit 193) Date: Fri, 12 Mar 2021 01:41:47 -0500 Subject: [PATCH] Allow use of lua5.4 or lua5.3 too. Message-ID: <20210312064147.8877-1-unit193@unit193.net> --- cgit.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgit.mk b/cgit.mk index 3fcc1ca..c173703 100644 --- a/cgit.mk +++ b/cgit.mk @@ -32,7 +32,7 @@ ifdef NO_LUA CGIT_CFLAGS += -DNO_LUA else ifeq ($(LUA_PKGCONFIG),) - LUA_PKGCONFIG := $(shell for pc in luajit lua lua5.2 lua5.1; do \ + LUA_PKGCONFIG := $(shell for pc in luajit lua lua5.4 lua5.3 lua5.2 lua5.1; do \ $(PKG_CONFIG) --exists $$pc 2>/dev/null && echo $$pc && break; \ done) LUA_MODE := autodetected -- 2.20.1 From list at eworm.de Tue Mar 16 10:31:55 2021 From: list at eworm.de (Christian Hesse) Date: Tue, 16 Mar 2021 11:31:55 +0100 Subject: [PATCH 1/1] git: update to v2.31.0 Message-ID: <20210316103155.48855-1-list@eworm.de> From: Christian Hesse Update to git version v2.31.0, this requires changes for these upstream commits: * 36a317929b8f0c67d77d54235f2d20751c576cbb refs: switch peel_ref() to peel_iterated_oid() Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- ui-log.c | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index a4e597b..11b437b 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.30.1 +GIT_VER = 2.31.0 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.xz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index 773e25a..a5828ae 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 773e25afc41b1b6533fa9ae2cd825d0b4a697fad +Subproject commit a5828ae6b52137b913b978e16cd2334482eb4c1f diff --git a/ui-log.c b/ui-log.c index 6914f75..20774bf 100644 --- a/ui-log.c +++ b/ui-log.c @@ -65,8 +65,9 @@ void show_commit_decorations(struct commit *commit) return; html(""); while (deco) { - struct object_id peeled; + struct object_id oid_tag, peeled; int is_annotated = 0; + strlcpy(buf, prettify_refname(deco->name), sizeof(buf)); switch(deco->type) { case DECORATION_NONE: @@ -79,8 +80,8 @@ void show_commit_decorations(struct commit *commit) ctx.qry.showmsg, 0); break; case DECORATION_REF_TAG: - if (!peel_ref(deco->name, &peeled)) - is_annotated = !oidcmp(&commit->object.oid, &peeled); + if (!read_ref(deco->name, &oid_tag) && !peel_iterated_oid(&oid_tag, &peeled)) + is_annotated = !oideq(&oid_tag, &peeled); cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf); break; case DECORATION_REF_REMOTE: From e at 80x24.org Fri Mar 19 20:19:31 2021 From: e at 80x24.org (Eric Wong) Date: Fri, 19 Mar 2021 20:19:31 +0000 Subject: [PATCH (resend)] ui-stats.c: fix warning on 32-bit Message-ID: <20210319201931.GA17268@dcvr> gcc 6.3.0-18 on Debian oldstable emits the following warning, despite uintptr_t and "unsigned long" having the same size: > ../ui-stats.c: In function ?print_authors?: > ../ui-stats.c:340:18: warning: format ?%lu? expects argument of type ?long unsigned int?, but argument 2 has type ?unsigned int? [-Wformat=] > htmlf("%lu", (uintptr_t)date->util); > ^ Signed-off-by: Eric Wong --- ui-stats.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui-stats.c b/ui-stats.c index 09b3625..ad22dae 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -337,8 +337,10 @@ static void print_authors(struct string_list *authors, int top, if (!date) html("0"); else { - htmlf("%lu", (uintptr_t)date->util); - total += (uintptr_t)date->util; + uintptr_t util = (uintptr_t)date->util; + + htmlf("%"PRIuPTR"", util); + total += util; } } htmlf("%ld", total); From e at 80x24.org Fri Mar 19 20:23:37 2021 From: e at 80x24.org (Eric Wong) Date: Fri, 19 Mar 2021 20:23:37 +0000 Subject: [PATCH 5/5] ui-{tree, repolist}: improve button spacing for browsers w/o CSS In-Reply-To: <20210319202337.21676-1-e@80x24.org> References: <20210319202337.21676-1-e@80x24.org> Message-ID: <20210319202337.21676-6-e@80x24.org> For browsers on low-end machines running browsers without CSS support, the default tree view displayed "logplain" when it should be "log plain". Stop relying on CSS and add a space in between elements to improve accessibility. Signed-off-by: Eric Wong --- cgit.css | 1 - ui-repolist.c | 2 ++ ui-tree.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cgit.css b/cgit.css index 6ab28a1..4ccd5ad 100644 --- a/cgit.css +++ b/cgit.css @@ -575,7 +575,6 @@ div#cgit table.list td.reposection { div#cgit a.button { font-size: 80%; - padding: 0em 0.5em; } div#cgit a.primary { diff --git a/ui-repolist.c b/ui-repolist.c index 529a203..591929b 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -353,8 +353,10 @@ void cgit_print_repolist(void) if (ctx.cfg.enable_index_links) { html(""); cgit_summary_link("summary", NULL, "button", NULL); + html(" "); cgit_log_link("log", NULL, "button", NULL, NULL, NULL, 0, NULL, NULL, ctx.qry.showmsg, 0); + html(" "); cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL); html(""); } diff --git a/ui-tree.c b/ui-tree.c index 1e4efb2..f561d8b 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -245,15 +245,21 @@ static int ls_item(const struct object_id *oid, struct strbuf *base, cgit_log_link("log", NULL, "button", ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf, 0, NULL, NULL, ctx.qry.showmsg, 0); - if (ctx.repo->max_stats) + if (ctx.repo->max_stats) { + html(" "); cgit_stats_link("stats", NULL, "button", ctx.qry.head, fullpath.buf); - if (!S_ISGITLINK(mode)) + } + if (!S_ISGITLINK(mode)) { + html(" "); cgit_plain_link("plain", NULL, "button", ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf); - if (!S_ISDIR(mode) && ctx.repo->enable_blame) + } + if (!S_ISDIR(mode) && ctx.repo->enable_blame) { + html(" "); cgit_blame_link("blame", NULL, "button", ctx.qry.head, walk_tree_ctx->curr_rev, fullpath.buf); + } html("\n"); free(name); strbuf_release(&fullpath); From e at 80x24.org Fri Mar 19 20:23:36 2021 From: e at 80x24.org (Eric Wong) Date: Fri, 19 Mar 2021 20:23:36 +0000 Subject: [PATCH 4/5] ui-diff: preserve spaces w/o CSS on context lines In-Reply-To: <20210319202337.21676-1-e@80x24.org> References: <20210319202337.21676-1-e@80x24.org> Message-ID: <20210319202337.21676-5-e@80x24.org> We need to use a non-breaking space entity to preserve spacing for browsers without CSS support. Signed-off-by: Eric Wong --- html.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ html.h | 1 + ui-diff.c | 5 +---- 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/html.c b/html.c index 7f81965..138c649 100644 --- a/html.c +++ b/html.c @@ -156,6 +156,52 @@ ssize_t html_ntxt(const char *txt, size_t len) return slen; } +ssize_t html_ntxt_pre(const char *txt, size_t len) +{ + const char *t = txt; + ssize_t slen; + int prev = 0; + + if (len > SSIZE_MAX) + return -1; + + slen = (ssize_t) len; + while (t && *t && slen--) { + int c = *t; + if (c == '<' || c == '>' || c == '&' || c == ' ' || c == '\t') { + html_raw(txt, t - txt); + if (c == '>') + html(">"); + else if (c == '<') + html("<"); + else if (c == '&') + html("&"); + else if (c == ' ') { + if (!prev || prev == ' ' || prev == '\t') { + html(" "); + /* next byte can be unescaped ' ' */ + c = 160; + } else { + html(" "); + } + } else if (c == '\t') { + html("    " + "    "); + /* next byte can be unescaped ' ' */ + c = 160; + } + txt = t + 1; + } + prev = c; + t++; + } + if (t != txt) + html_raw(txt, t - txt); + return slen; +} + + + void html_attrf(const char *fmt, ...) { va_list ap; diff --git a/html.h b/html.h index fa4de77..4479b8e 100644 --- a/html.h +++ b/html.h @@ -20,6 +20,7 @@ extern void html_attrf(const char *format,...); extern void html_txt(const char *txt); extern ssize_t html_ntxt(const char *txt, size_t len); +extern ssize_t html_ntxt_pre(const char *txt, size_t len); extern void html_attr(const char *txt); extern void html_url_path(const char *txt); extern void html_url_arg(const char *txt); diff --git a/ui-diff.c b/ui-diff.c index 5ed5990..a0f2bb7 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -222,7 +222,6 @@ static void cgit_print_diffstat(const struct object_id *old_oid, static void print_line(char *line, int len) { char *class = "ctx"; - char c = line[len-1]; if (line[0] == '+') class = "add"; @@ -232,10 +231,8 @@ static void print_line(char *line, int len) class = "hunk"; htmlf("
", class); - line[len-1] = '\0'; - html_txt(line); + html_ntxt_pre(line, len - 1); html("
"); - line[len-1] = c; } static void header(const struct object_id *oid1, char *path1, int mode1, From e at 80x24.org Fri Mar 19 20:23:35 2021 From: e at 80x24.org (Eric Wong) Date: Fri, 19 Mar 2021 20:23:35 +0000 Subject: [PATCH 3/5] ui-log: improve decoration display for browsers without CSS In-Reply-To: <20210319202337.21676-1-e@80x24.org> References: <20210319202337.21676-1-e@80x24.org> Message-ID: <20210319202337.21676-4-e@80x24.org> Text-based browsers without CSS support show all the decorations bunched together without spacing. Rely on a whitespace instead of CSS support. Signed-off-by: Eric Wong --- cgit.css | 1 - ui-log.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cgit.css b/cgit.css index f9549a1..6ab28a1 100644 --- a/cgit.css +++ b/cgit.css @@ -708,7 +708,6 @@ div#cgit div.commit-subject a.tag-deco, div#cgit div.commit-subject a.tag-annotated-deco, div#cgit div.commit-subject a.remote-deco, div#cgit div.commit-subject a.deco { - margin-left: 1em; font-size: 75%; } diff --git a/ui-log.c b/ui-log.c index 6914f75..3679c0a 100644 --- a/ui-log.c +++ b/ui-log.c @@ -67,6 +67,7 @@ void show_commit_decorations(struct commit *commit) while (deco) { struct object_id peeled; int is_annotated = 0; + strlcpy(buf, prettify_refname(deco->name), sizeof(buf)); switch(deco->type) { case DECORATION_NONE: @@ -74,11 +75,13 @@ void show_commit_decorations(struct commit *commit) * don't display anything. */ break; case DECORATION_REF_LOCAL: + html(" "); cgit_log_link(buf, NULL, "branch-deco", buf, NULL, ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, 0); break; case DECORATION_REF_TAG: + html(" "); if (!peel_ref(deco->name, &peeled)) is_annotated = !oidcmp(&commit->object.oid, &peeled); cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf); @@ -86,12 +89,14 @@ void show_commit_decorations(struct commit *commit) case DECORATION_REF_REMOTE: if (!ctx.repo->enable_remote_branches) break; + html(" "); cgit_log_link(buf, NULL, "remote-deco", NULL, oid_to_hex(&commit->object.oid), ctx.qry.vpath, 0, NULL, NULL, ctx.qry.showmsg, 0); break; default: + html(" "); cgit_commit_link(buf, NULL, "deco", ctx.qry.head, oid_to_hex(&commit->object.oid), ctx.qry.vpath); From e at 80x24.org Fri Mar 19 20:23:32 2021 From: e at 80x24.org (Eric Wong) Date: Fri, 19 Mar 2021 20:23:32 +0000 Subject: [PATCH (resend) 0/5] improve rendering w/o CSS reliance Message-ID: <20210319202337.21676-1-e@80x24.org> Rebased againsg commit bd6f5683f6cde4212364354b3139c1d521f40f39 ("tests: t0107: support older and/or non-GNU tar") Here are a few changes to improve rendering for people with low-end machines using text-based browsers (w3m, lynx) or lightweight GUI browsers such as dillo, which has incomplete CSS support. The only incompatible (with existing CSS customisations) change might be the one to use
 instead of 
for commit-msg. I'm not sure how much of a stable interface the CSS styles are expected to be for this project. Eric Wong (5): ui-shared: improve pageheader display on text-based browsers ui-{commit,tag}: use
 for commit-msg
  ui-log: improve decoration display for browsers without CSS
  ui-diff: preserve spaces w/o CSS on context lines
  ui-{tree,repolist}: improve button spacing for browsers w/o CSS

 cgit.css              |  8 --------
 html.c                | 46 +++++++++++++++++++++++++++++++++++++++++++
 html.h                |  1 +
 tests/t0105-commit.sh |  2 +-
 ui-commit.c           |  4 ++--
 ui-diff.c             |  5 +----
 ui-log.c              |  5 +++++
 ui-repolist.c         |  2 ++
 ui-shared.c           | 15 +++++++++++---
 ui-tag.c              |  4 ++--
 ui-tree.c             | 12 ++++++++---
 11 files changed, 81 insertions(+), 23 deletions(-)

From e at 80x24.org  Fri Mar 19 20:30:47 2021
From: e at 80x24.org (Eric Wong)
Date: Fri, 19 Mar 2021 20:30:47 +0000
Subject: [PULL (resend)] improve rendering w/o CSS reliance
Message-ID: <20210319203047.27230-1-e@80x24.org>

Using "git request-pull" because lists.zx2c4.com is misdetecting
patches to C code with HTML in them as HTML mail...

Rebased against commit bd6f5683f6cde4212364354b3139c1d521f40f39
("tests: t0107: support older and/or non-GNU tar")

Here are a few changes to improve rendering for people with
low-end machines using text-based browsers (w3m, lynx) or
lightweight GUI browsers such as dillo, which has incomplete CSS
support.

The only incompatible (with existing CSS customisations) change
might be the one to use 
 instead of 
for commit-msg. I'm not sure how much of a stable interface the CSS styles are expected to be for this project. The following changes since commit bd6f5683f6cde4212364354b3139c1d521f40f39: tests: t0107: support older and/or non-GNU tar (2020-12-29 21:06:17 +0100) are available in the Git repository at: https://80x24.org/cgit.git no-css for you to fetch changes up to ab8ff5295cfed27f6c827600fed28376b4540bb4: ui-{tree,repolist}: improve button spacing for browsers w/o CSS (2021-03-19 20:17:01 +0000) ---------------------------------------------------------------- Eric Wong (5): ui-shared: improve pageheader display on text-based browsers ui-{commit,tag}: use
 for commit-msg
      ui-log: improve decoration display for browsers without CSS
      ui-diff: preserve spaces w/o CSS on context lines
      ui-{tree,repolist}: improve button spacing for browsers w/o CSS

 cgit.css              |  8 --------
 html.c                | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 html.h                |  1 +
 tests/t0105-commit.sh |  2 +-
 ui-commit.c           |  4 ++--
 ui-diff.c             |  5 +----
 ui-log.c              |  5 +++++
 ui-repolist.c         |  2 ++
 ui-shared.c           | 15 ++++++++++++---
 ui-tag.c              |  4 ++--
 ui-tree.c             | 12 +++++++++---
 11 files changed, 81 insertions(+), 23 deletions(-)

From e at 80x24.org  Fri Mar 19 20:38:22 2021
From: e at 80x24.org (Eric Wong)
Date: Fri, 19 Mar 2021 20:38:22 +0000
Subject: [PATCH (resend)] use buffered stdio
Message-ID: <20210319203822.GA30217@dcvr>

Our generation of HTML triggers many small write(2) syscalls
which is inefficient.

Time output on a horrible query against my git.git mirror
shows significant performance improvement:

QUERY_STRING='id=2b93bfac0f5bcabbf60f174f4e7bfa9e318e64d5&id2=d6da71a9d16b8cf27f9d8f90692d3625c849cbc8'
PATH_INFO=/mirrors/git.git/diff
export QUERY_STRING PATH_INFO
time ./cgit >/dev/null

Before:
real    0m1.585s
user    0m0.904s
sys     0m0.658s

After:
real    0m0.750s
user    0m0.666s
sys     0m0.076s

Signed-off-by: Eric Wong 
---
 I've been running this with Lua commit filter for the past two
 years without known problems.  I don't use the cgit cache,
 though, so extra eyes on that would be appreciated.

 cache.c       |  7 +++++++
 cgit.c        |  2 +-
 filter.c      | 22 +++++++++++++++++++++-
 html.c        |  2 +-
 ui-snapshot.c |  3 +++
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/cache.c b/cache.c
index 55199e8..578b73b 100644
--- a/cache.c
+++ b/cache.c
@@ -265,6 +265,13 @@ static int process_slot(struct cache_slot *slot)
 {
 	int err;
 
+	/*
+	 * Make sure any buffered data is flushed before we redirect,
+	 * do sendfile(2) or write(2)
+	 */
+	if (fflush(stdout))
+		return errno;
+
 	err = open_slot(slot);
 	if (!err && slot->match) {
 		if (is_expired(slot)) {
diff --git a/cgit.c b/cgit.c
index 08d81a1..40825cb 100644
--- a/cgit.c
+++ b/cgit.c
@@ -674,7 +674,7 @@ static inline void authenticate_post(void)
 		len = MAX_AUTHENTICATION_POST_BYTES;
 	if ((len = read(STDIN_FILENO, buffer, len)) < 0)
 		die_errno("Could not read POST from stdin");
-	if (write(STDOUT_FILENO, buffer, len) < 0)
+	if (fwrite(buffer, 1, len, stdout) < len)
 		die_errno("Could not write POST to stdout");
 	cgit_close_filter(ctx.cfg.auth_filter);
 	exit(0);
diff --git a/filter.c b/filter.c
index 70f5b74..fba26aa 100644
--- a/filter.c
+++ b/filter.c
@@ -48,6 +48,7 @@ static int open_exec_filter(struct cgit_filter *base, va_list ap)
 	for (i = 0; i < filter->base.argument_count; i++)
 		filter->argv[i + 1] = va_arg(ap, char *);
 
+	chk_zero(fflush(stdout), "unable to flush STDOUT");
 	filter->old_stdout = chk_positive(dup(STDOUT_FILENO),
 		"Unable to duplicate STDOUT");
 	chk_zero(pipe(pipe_fh), "Unable to create pipe to subprocess");
@@ -71,6 +72,7 @@ static int close_exec_filter(struct cgit_filter *base)
 	struct cgit_exec_filter *filter = (struct cgit_exec_filter *)base;
 	int i, exit_status = 0;
 
+	chk_zero(fflush(stdout), "unable to flush STDOUT");
 	chk_non_negative(dup2(filter->old_stdout, STDOUT_FILENO),
 		"Unable to restore STDOUT");
 	close(filter->old_stdout);
@@ -143,17 +145,32 @@ void cgit_init_filters(void)
 #endif
 
 #ifndef NO_LUA
-static ssize_t (*libc_write)(int fd, const void *buf, size_t count);
+static size_t (*libc_fwrite)(const void *buf, size_t size, size_t n, FILE *);
+static ssize_t (*libc_write)(int fd, const void *buf, size_t size);
 static ssize_t (*filter_write)(struct cgit_filter *base, const void *buf, size_t count) = NULL;
 static struct cgit_filter *current_write_filter = NULL;
 
 void cgit_init_filters(void)
 {
+	/*
+	 * we need to wrap both functions since the Lua filter may
+	 * have code which calls write(2) directly, bypassing fwrite(3)
+	 */
+	libc_fwrite = dlsym(RTLD_NEXT, "fwrite");
+	if (!libc_fwrite)
+		die("Could not locate libc's write function");
 	libc_write = dlsym(RTLD_NEXT, "write");
 	if (!libc_write)
 		die("Could not locate libc's write function");
 }
 
+size_t fwrite(const void *buf, size_t size, size_t n, FILE *f)
+{
+	if (f != stdout || !filter_write)
+		return libc_fwrite(buf, size, n, f);
+	return filter_write(current_write_filter, buf, size * n);
+}
+
 ssize_t write(int fd, const void *buf, size_t count)
 {
 	if (fd != STDOUT_FILENO || !filter_write)
@@ -305,6 +322,9 @@ static int open_lua_filter(struct cgit_filter *base, va_list ap)
 	struct lua_filter *filter = (struct lua_filter *)base;
 	int i;
 
+	if (fflush(stdout))
+		return 1;
+
 	if (init_lua_filter(filter))
 		return 1;
 
diff --git a/html.c b/html.c
index 7f81965..cefcf5e 100644
--- a/html.c
+++ b/html.c
@@ -80,7 +80,7 @@ char *fmtalloc(const char *format, ...)
 
 void html_raw(const char *data, size_t size)
 {
-	if (write(STDOUT_FILENO, data, size) != size)
+	if (fwrite(data, 1, size, stdout) != size)
 		die_errno("write error on html output");
 }
 
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 18361a6..2801393 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -37,6 +37,9 @@ static int write_archive_type(const char *format, const char *hex, const char *p
 	/* strvec guarantees a trailing NULL entry. */
 	memcpy(nargv, argv.v, sizeof(char *) * (argv.nr + 1));
 
+	if (fflush(stdout))
+		return errno;
+
 	result = write_archive(argv.nr, nargv, NULL, the_repository, NULL, 0);
 	strvec_clear(&argv);
 	free(nargv);

From pwr at bydasein.com  Sun Mar 28 05:35:55 2021
From: pwr at bydasein.com (Paul W. Rankin)
Date: Sun, 28 Mar 2021 15:35:55 +1000
Subject: about-filter in chroot on OpenBSD (httpd + slowcgi)
Message-ID: 

Hello,

I'm running cgit on OpenBSD with httpd + slowcgi and can't seem to get 
the about-filter to work. Both httpd and slowcgi run in the default 
chroot of /var/www.

I've compiled lowdown with "-static -pie" to /var/www/bin/lowdown 
(chroot /bin/lowdown) with permissions:

     -rwxr-xr-x  1 root  bin  1325512 Mar  4 01:38 /var/www/bin/lowdown

In my cgitrc (cgit.conf):

     about-filter=/bin/lowdown
     readme=:README.md

However, upon visiting an About page of a repo that includes a 
README.md, I get only a blank page and the following is logged in 
error.log:

     lowdown: README.md: No such file or directory

Here's the cgit server section in httpd.conf:

	server "git.bydasein.com" {
			listen on * port 80
			listen on * tls port 443
			root "/cgi-bin/cgit.cgi"
			tls {
					certificate "/etc/ssl/bydasein.com.fullchain.pem"
					key "/etc/ssl/private/bydasein.com.key"
			}
			location "/.well-known/acme-challenge/*" {
					root "/acme"
					request strip 2
			}
			location "/robots.txt" {
					root "/htdocs/git.bydasein.com"
					no fastcgi
			}
			location "/favicon.ico" {
					root "/htdocs/git.bydasein.com"
					no fastcgi
			}
			location "/cgit.css" {
					root "/htdocs/git.bydasein.com"
					no fastcgi
			}
			location "/custom.css" {
					root "/htdocs/git.bydasein.com"
					no fastcgi
			}
			fastcgi {
					socket "/run/slowcgi.sock"
					param CGIT_CONFIG "/conf/cgit.conf"
			}
	}

I'm pretty sure I can have this work if I disable the chroot in httpd 
and/or slowcgi, but I'd prefer a solution that doesn't require that.

Does anyone have any ideas? Has anyone managed to get cgit running on 
OpenBSD using httpd + slowcgi with chroot enabled?

Thanks for your time :)

-- 
Paul W. Rankin
https://bydasein.com

The single best thing you can do for the world is delete your social 
media accounts.

From pwr at bydasein.com  Sun Mar 28 09:05:51 2021
From: pwr at bydasein.com (Paul W. Rankin)
Date: Sun, 28 Mar 2021 19:05:51 +1000
Subject: about-filter in chroot on OpenBSD (httpd + slowcgi)
In-Reply-To: <87sg4fpulm.fsf@oscarnajera.com>
References: 
 <87sg4fpulm.fsf@oscarnajera.com>
Message-ID: <7aea255f48d681ed9d36dca28f5ffa05@bydasein.com>


On 2021-03-28 18:09, Oscar Najera wrote:
> Paths are absolute on. Try
> 
> about-filter=/var/www/bin/lowdown

Thanks Oscar, but cgit is running in chroot at /var/www so this path 
would become /var/www/var/www/bin/lowdown.

This is now solved. I was making two mistakes; the first is that 
about-filter doesn't want an executable to do the conversion, it wants a 
the command to pass to do the conversion. The second is that my script 
was #!/bin/sh but sh wasn't in the chroot, so I needed to copy the sh 
binary into /var/www/bin.

But with some help from the OpenBSD list I was able to make a little 
static C program that works:

	#include 

	int main(void) {
		execl("/bin/lowdown", "lowdown", NULL);
		return 1;
	}