From 9538f73d65e4b0d09cff18fa01725e86c61379ef Mon Sep 17 00:00:00 2001 From: Samuel Tyler Date: Sun, 29 Dec 2024 11:35:19 +1100 Subject: [PATCH] Autodetect HAVE_PASSWD support Fixes #122 --- .gitignore | 1 + configure | 21 ++++++++++++++++++++- src/gophernicus.h | 4 +++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0a62130..8df778d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ src/filetypes.h src/bin2c src/gophernicus Makefile +config.h README README.options diff --git a/configure b/configure index e7881ce..cc134ba 100755 --- a/configure +++ b/configure @@ -64,6 +64,9 @@ done : ${CFLAGS:=-O2} : ${HOSTNAME:=autodetect} +rm -f config.h +touch config.h + # Check for a compiler that actually works printf "checking for working compiler... " cat > conftest.c < conftest.c </dev/null; then - LIBWRAP="-DHAVE_LIBWRAP -lwrap" + LIBWRAP="-lwrap" + echo "#define HAVE_LIBWARP " >> config.h printf "yes" else LIBWRAP= @@ -251,6 +255,21 @@ else fi printf "\\n" +# Checking for passwd support +printf "checking for passwd support... " +cat > conftest.c < +int main() {} +EOF + +if ${CC} -o conftest conftest.c 2>/dev/null; then + echo "#define HAVE_PASSWD " >> config.h + printf "yes" +else + printf "no" +fi +printf "\\n" + # Check and use SHM if available printf "checking for ipcrm (SHM management)... " if ! IPCRM="$(command -v ipcrm)"; then diff --git a/src/gophernicus.h b/src/gophernicus.h index 33c6dd5..ea2c38f 100644 --- a/src/gophernicus.h +++ b/src/gophernicus.h @@ -53,7 +53,7 @@ /* Defaults should fit standard POSIX systems */ #define HAVE_IPv4 /* IPv4 should work anywhere */ #define HAVE_IPv6 /* Requires modern POSIX */ -#define HAVE_PASSWD /* For systems with passwd-like userdb */ +/* #define HAVE_PASSWD autodetected, For systems with passwd-like userdb */ #define PASSWD_MIN_UID 100 /* Minimum allowed UID for ~userdirs */ #define HAVE_LOCALES /* setlocale() and friends */ #define HAVE_SHMEM /* Shared memory support */ @@ -63,6 +63,8 @@ #undef HAVE_SENDFILE /* sendfile() in Linux & others */ /* #undef HAVE_LIBWRAP autodetected, don't enable here */ +#include "config.h" + /* Linux */ #ifdef __linux #undef PASSWD_MIN_UID