From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 152891F4CC for ; Sat, 30 Nov 2024 22:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1733007546; bh=lu8Lo+jOhEayO1nrNX8OCwbPt75fgGCbySfWUOcN7xA=; h=From:To:Subject:Date:From; b=P5BPW2TD6N1mok41pqT09qSMWYEr30/wYkL/uIJZLM3zPQ13tYVmskkyhYxX2Pf1y lRkOomBTSM2L4euYpf+eFTZqjp7DvXOZETLZqw+JXbCYUP4dlfYOjcWr3y/x5CDbJY P4CvNRVntNcRt/X7hOTUbmqfI/PgDl76tZouww+0= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] daemon: improve warning on missing SO_ACCEPTFILTER Date: Sat, 30 Nov 2024 22:59:05 +0000 Message-ID: <20241130225905.38128-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: I noticed tests were failing on a freshly booted FreeBSD instance due to the accf_http module not being loaded and triggering autodie-generated error messages from setsockopt. Instead, give a helpful warning message for users to use kldload(8) to load the necessary filter. We'll also relax tests to ignore the kldload warning and fix an overzealous use of /.*/ while we're at by using /[^\n]/ instead to avoid filtering out subsequent lines. --- lib/PublicInbox/Daemon.pm | 7 +++++-- lib/PublicInbox/TestCommon.pm | 19 ++++++++++++------- t/solver_git.t | 7 ++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index 8e6ddbb9..57f01d2c 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -658,8 +658,11 @@ sub defer_accept ($$) { # getsockopt can EINVAL if SO_ACCEPTFILTER is unset: my $x = getsockopt($s, SOL_SOCKET, $SO_ACCEPTFILTER); return if ($x // '') =~ /[^\0]/s; # don't change if set - my $accf_arg = pack('a16a240', $af_name, ''); - setsockopt $s, SOL_SOCKET, $SO_ACCEPTFILTER, $accf_arg; + CORE::setsockopt $s, SOL_SOCKET, $SO_ACCEPTFILTER, + pack('a16a240', $af_name, '') or + warn 'W: ', sockname($s), < $ua); $cb->() if $cb; $td->join('TERM'); - open my $fh, '<', $err; - my $e = read_all($fh); - if ($e =~ s/^Plack::Middleware::ReverseProxy missing,\n//gms) { - $e =~ s/^URL generation for redirects .*\n//gms; - } - is($e, '', 'no errors'); + no_httpd_errors $err; } }; diff --git a/t/solver_git.t b/t/solver_git.t index cebcf47f..c45011ad 100644 --- a/t/solver_git.t +++ b/t/solver_git.t @@ -43,11 +43,8 @@ my $v1_0_0_tag_short = substr($v1_0_0_tag, 0, 16); my $expect = '69df7d565d49fbaaeb0a067910f03dc22cd52bd0'; my $non_existent = 'ee5e32211bf62ab6531bdf39b84b6920d0b6775a'; my $stderr_empty = sub { - my ($msg) = @_; - open my $efh, '<', "$tmpdir/stderr.log"; - my @l = <$efh>; - @l = grep(!/reverse ?proxy/i, @l); - is_xdeeply(\@l, [], $msg // 'stderr.log is empty'); + no_httpd_errors "$tmpdir/stderr.log", + $_[0] // 'stderr.log is empty'; }; test_lei({tmpdir => "$tmpdir/blob"}, sub {