libproxyprotocol: add test and options to link the library if present

This commit is contained in:
Yves Rutschle 2025-02-01 10:12:04 +01:00
parent a2b4da8483
commit e527b8e588
5 changed files with 47 additions and 1 deletions

View File

@ -37,7 +37,7 @@ AR ?= ar
CFLAGS +=-Wall -O2 -DLIBPCRE -g $(CFLAGS_COV) $(CFLAGS_SAN)
LIBS=-lm -lpcre2-8
LIBS=-lm -lpcre2-8 @LIBS@
OBJS=sslh-conf.o common.o log.o sslh-main.o probe.o tls.o argtable3.o collection.o gap.o tcp-probe.o landlock.o
OBJS_A=libsslh.a
FORK_OBJS=sslh-fork.o $(OBJS_A)

View File

@ -6,4 +6,7 @@
/* Landlock sandboxing Linux LSM */
#undef HAVE_LANDLOCK
/* Support for Proxy-protocol using libproxyprotocol */
#undef HAVE_PROXYPROTOCOL
#endif

22
configure vendored
View File

@ -2163,6 +2163,7 @@ ac_config_headers="$ac_config_headers config.h"
ac_config_files="$ac_config_files Makefile"
have_proxyprotocol=0
@ -3199,6 +3200,27 @@ then :
fi
done
for ac_header in proxy_protocol.h
do :
ac_fn_c_check_header_compile "$LINENO" "proxy_protocol.h" "ac_cv_header_proxy_protocol_h" "$ac_includes_default"
if test "x$ac_cv_header_proxy_protocol_h" = xyes
then :
printf "%s\n" "#define HAVE_PROXY_PROTOCOL_H 1" >>confdefs.h
printf "%s\n" "#define HAVE_PROXYPROTOCOL 1" >>confdefs.h
else $as_nop
have_proxyprotocol=1
fi
done
if test $have_proxyprotocol == 0
then
LIBS="$LIBS -lproxyprotocol"
fi
LIBS="$LIBS"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure

View File

@ -1,9 +1,21 @@
dnl Use autoconf to generate the `configure` script from this and Makefile.in
dnl This is awkardly adapted from https://github.com/edrosten/autoconf_tutorial
dnl (all mistakes mine)
AC_INIT
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_FILES([Makefile])
have_proxyprotocol=0
AC_CHECK_HEADERS(linux/landlock.h, AC_DEFINE(HAVE_LANDLOCK), [])
AC_CHECK_HEADERS(proxy_protocol.h, AC_DEFINE(HAVE_PROXYPROTOCOL), [have_proxyprotocol=1])
if test $have_proxyprotocol == 0
then
LIBS="$LIBS -lproxyprotocol"
fi
LIBS="$LIBS"
AC_SUBST([LIBS])
AC_OUTPUT

View File

@ -42,6 +42,15 @@ Dependencies
* libev-dev, in package `libev-dev`.
If you build a binary specifically and do not build `sslh-ev`, you don't need this.
* [libproxyprotocol](https://github.com/kosmas-valianos/libproxyprotocol.git)
to support HAProxy's [ProxyProtocol](https://www.haproxy.org/download/2.3/doc/proxy-protocol.txt).
As this is not part of the distribution packages, set
C_INCLUDE_PATH and LD_LIBRARY_PATH to the appropriate
values:
```
export C_INCLUDE_PATH=/home/user/src/libproxyprotocol/src
export LD_LIBRARY_PATH=/home/user/src/libproxyprotocol/src
```
For OpenSUSE, these are contained in packages libconfig9 and
libconfig-dev in repository