[Bug 266808] www/obhttpd has various issues in both pkg and ports

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 04 Oct 2022 02:19:37 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266808

            Bug ID: 266808
           Summary: www/obhttpd has various issues in both pkg and ports
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: freebsd@kumba.dev
                CC: koue@chaosophia.net
             Flags: maintainer-feedback?(koue@chaosophia.net)
                CC: koue@chaosophia.net

Summary, there are three issues:
1. obhttpd from pkg needs OpenBSD libevent, but this is not auto-fulfilled
2. Using libevent-2.1.12 will cause a SIGSEGV signal 11 crash
3. Compiling from ports doesn't work because of weird way it includes OpenBSD
libs during build

Long detail:
Running obhttpd-7.1.20220923_1 from pkg in a jail, using a minimal config file
to listen only on TCP/80 for IPv4 and IPv6, when I attempt to connect to the
server, the server process (not the logger process) will crash with a SIGSEGV
signal 11:

Sample obhttpd.conf (site name redacted):

> chroot "/srv/www"
> prefork 1
> 
> server "www.foo" {
>         listen on <IPv4> port 80
>         listen on <IPv6> port 80
>         gzip-static
>         root "/htdocs"
>         directory auto index
> 
>         tcp {
>                 nodelay
>                 sack
>         }
> }

Running obhttpd directly in the foreground, undaemonized:
# /usr/local/sbin/obhttpd -f /usr/local/etc/obhttpd.conf -d
startup
logger exiting, pid 44521
lost child: pid 44302 terminated; signal 11
parent terminating, pid 44121

The point between "startup" and "logger exiting" is where the crash happens. 
Here is the output of truss on the server PID (I already tested the logger PID
and it exits fine).  Server name changed for privacy (and offsets adjusted):
> # truss -a -f -e -p 44302
> 44302: kevent(4,{ },0,{ 6,EVFILT_READ,0x0,0,0x1,0x30303 },64,0x0) = 1 (0x1)
> 44302: __sysctl("kern.proc.nfds.0",4,0x820cc998c,0x820cc9980,0x0,0) = 0 (0x0)
> 44302: getdtablesize()                           = 466434 (0x71e02)
> 44302: accept4(0x6,0x820cc9a28,0x820cc9a24,0x20000000) = 8 (0x8)
> 44302: getpid()                                  = 44302 (0xad0e)
> 44302: getsockname(8,{ AF_INET <IPv4>:80 },0x820cc9a24) = 0 (0x0)
> 44302: getsockopt(8,SOL_SOCKET,SO_SNDBUF,0x8274b75d8,0x820cc99d4) = 0 (0x0)
> 44302: kevent(4,{ 6,EVFILT_READ,EV_ADD,0,0,0x30303 8,EVFILT_READ,EV_ADD,0,0,0x30303 8,EVFILT_WRITE,EV_ADD,0,0,0x30303 },3,{ 8,EVFILT_READ,0x0,0,0x167,0x30303 8,EVFILT_WRITE,0x0,0,0x8c00,0x30303 },64,{ 60.000000000 }) = 2 (0x2)
> 44302: ioctl(8,FIONREAD,0x820cc9a20)             = 0 (0x0)
> 44302: readv(8,[{"GET / HTTP/1.1\r\nHost: www.foo"...,359}],1) = 359 (0x167)
> 44302: SIGNAL 11 (SIGSEGV) code=SEGV_MAPERR trapno=12 addr=0xe1f41

My thinking is it has to do with libevent.  It looks like obhttpd relies on
using the libevent from OpenBSD, but when installing from pkg and not ports,
there is no dependency on a FreeBSD package containing OpenBSD's version of
libevent.so.  When I first ran into this, not realizing it needed OpenBSD's
version, I installed libevent-2.1.12 from pkg, which is NOT the one from
OpenBSD, and I think this is the source of the above crash.

When I went to dig into this one, it looks like the obhttpd port pulls down
OpenBSD copies of libevent and libimsg from the obhttpd maintainer's github and
builds them in the same work directory as obhttpd.  However, trying to build
the current version in ports fails because it wants to include an "imsg.h"
header (which should be provided by libimsg, but the include paths aren't set
right, I assume).  One can partially satisfy that by installing libopenbsd,
which looks to be unmaintained, but obhttpd fails to compile again looking for
tls.h (from libressl I think).  I gave up at this point, as this does not
appear to be a pkg/port that is straight-forward to install and use.

Small snippet of the build failure from a single .c file:
>--- config.o ---
>cc  -O2 -pipe -fno-strict-aliasing -Wall -I/usr/ports/www/obhttpd/work/httpd-7.1.20220923/src/usr.sbin/httpd -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wshadow -Wpointer-arith -Wsign-compare -Wcast-qual -I/usr/ports/www/obhttpd/work/httpd-7.1.20220923/src/usr.sbin/httpd/../../../libevent/src/lib/libevent  -I/usr/ports/www/obhttpd/work/httpd-7.1.20220923/src/usr.sbin/httpd/../../../libimsg/src/lib/libutil  -I/usr/ports/www/obhttpd/work/httpd-7.1.20220923/src/usr.sbin/httpd/../../include  -I /usr/local/include -D__dead=''  -DHAVE_CONFIG_H -march=native  -MD  -MF.depend.config.o -MTconfig.o -std=gnu99 -Wno-format-zero-length -nobuiltininc -idirafter /usr/lib/clang/13.0.0/include -fstack-protector-strong    -Qunused-arguments    -c config.c -o config.o
>
>--- config.o ---
>config.c:31:10: fatal error: 'imsg.h' file not found
>#include <imsg.h>
>         ^~~~~~~~

-- 
You are receiving this mail because:
You are the assignee for the bug.