X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=configure;h=4dfd287ade349527c511d53434813253b501cbb9;hb=38e072b353f5b1325bbf52dfb759fe49ff6ef0f7;hp=e6a842a126ac2bced46e71b12dcc5070b7a4e1be;hpb=154b849c750be60d4c76cdcac56314b28c8a2790;p=opendoas.git diff --git a/configure b/configure index e6a842a..4dfd287 100755 --- a/configure +++ b/configure @@ -25,12 +25,18 @@ usage: configure [options] --enable-static prepare for static build --without-pam disable pam support + --without-shadow disable shadow support + + --with-timestamp enable timestamp support --help, -h display this help and exit EOF exit 0 } +# defaults +WITHOUT_TIMESTAMP=yes + for x; do opt=${x%%=*} var=${x#*=} @@ -47,8 +53,12 @@ for x; do --target) TARGET=$var ;; --enable-debug) DEBUG=yes ;; --enable-static) BUILD_STATIC=yes ;; - --with-pam) WITHOUT_PAM= ;; + --with-pam) WITHOUT_PAM=; WITHOUT_SHADOW=yes ;; + --with-shadow) WITHOUT_SHADOW=; WITHOUT_PAM=yes ;; --without-pam) WITHOUT_PAM=yes ;; + --without-shadow) WITHOUT_SHADOW=yes ;; + --with-timestamp) WITHOUT_TIMESTAMP= ;; + --without-timestamp) WITHOUT_TIMESTAMP=yes ;; --help|-h) usage ;; *) die "Error: unknown option $opt" ;; esac @@ -58,7 +68,7 @@ CONFIG_MK=config.mk rm -f "$CONFIG_MK" # : ${VERSION:="$(git describe --dirty --tags --long --always)"} -: ${VERSION:="0.3.2"} +: ${VERSION:="6.2"} cat <>$CONFIG_MK PREFIX ?= ${PREFIX:="/usr"} @@ -115,28 +125,77 @@ esac printf 'CFLAGS += -static\n' >>$CONFIG_MK # Add CPPFLAGS/CFLAGS/LDFLAGS to CC for testing features -XCC="${CC:=clang} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS" +XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS" # Make sure to disable --as-needed for CC tests. XCC="$XCC -Wl,--no-as-needed" check_func() { func="$1"; src="$2"; shift 2 - printf 'Checking for %-14s\t\t' "$func ..." + printf 'Checking for %-14s\t\t' "$func ..." >&2 printf '%s\n' "$src" >"_$func.c" $XCC "_$func.c" -o "_$func" 2>/dev/null ret=$? rm -f "_$func.c" "_$func" if [ $ret -eq 0 ]; then - printf 'yes.\n' + printf 'yes.\n' >&2 upperfunc="$(printf '%s\n' "$func" | tr '[[:lower:]]' '[[:upper:]]')" printf 'CFLAGS += -DHAVE_%s\n' "$upperfunc" >>$CONFIG_MK return 0 else - printf 'no.\n' + printf 'no.\n' >&2 return 1 fi } +authmethod() { + # + # Check for pam_appl.h. + # + src=' +#include +int main(void) { + return 0; +}' + [ -z "$WITHOUT_PAM" ] && check_func "pam_appl_h" "$src" && { + printf 'SRCS += pam.c\n' >>$CONFIG_MK + printf 'LDFLAGS += -lpam\n' >>$CONFIG_MK + printf 'CPPFLAGS += -DUSE_PAM\n' >>$CONFIG_MK + printf 'pam\n' + return 0 + } + + # + # Check for shadow.h. + # + src=' +#include +int main(void) { + return 0; +}' + [ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && { + printf 'SRCS += shadow.c\n' >>$CONFIG_MK + printf 'LDFLAGS += -lcrypt\n' >>$CONFIG_MK + printf 'CPPFLAGS += -DUSE_SHADOW\n' >>$CONFIG_MK + printf 'shadow\n' + return 0 + } + + return 1 +} + +persistmethod() { + [ -z "$WITHOUT_TIMESTAMP" ] && { + printf 'CPPFLAGS += -DUSE_TIMESTAMP\n' >>$CONFIG_MK + printf 'SRCS += timestamp.c\n' >>$CONFIG_MK + printf 'timestamp\n' + return 0 + } + return 1 +} + +# +# Check for explicit_bzero(). +# src=' #include int main(void) { @@ -147,7 +206,6 @@ check_func "explicit_bzero" "$src" || { printf 'OPENBSD += explicit_bzero.o\n' >>$CONFIG_MK } - # # Check for strlcat(). # @@ -259,83 +317,140 @@ check_func "reallocarray" "$src" || { } # -# Check for bsd_auth.h. +# Check for execvpe(). # src=' -#include +#include int main(void) { + const char *p = { "", NULL }; + execvpe("", p, p); return 0; }' -check_func "bsd_auth_h" "$src" && \ - have_bsd_auth_h=1 +check_func "execvpe" "$src" || { + printf 'OPENBSD += execvpe.o\n' >>$CONFIG_MK +} # -# Check for pam_appl.h. +# Check for setresuid(). # src=' -#include +#include int main(void) { + setresuid(0, 0, 0); return 0; }' -check_func "pam_appl_h" "$src" && { - [ -z "$WITHOUT_PAM" -a -z "$have_bsd_auth_h" ] && { - printf 'SRCS += pam.c\n' >>$CONFIG_MK - printf 'LDFLAGS += -lpam\n' >>$CONFIG_MK - } +check_func "setresuid" "$src" || { + printf 'OPENBSD += setresuid.o\n' >>$CONFIG_MK } # -# Check for shadow.h. +# Check for closefrom(). # src=' -#include +#include int main(void) { + closefrom(0); return 0; }' -check_func "shadow_h" "$src" && { - [ -n "$WITHOUT_PAM" -a -z "$have_bsd_auth_h" ] && \ - printf 'LDFLAGS += -lcrypt\n' >>$CONFIG_MK +check_func "closefrom" "$src" || { + printf 'OPENBSD += closefrom.o\n' >>$CONFIG_MK } # -# Check for execvpe(). +# Check for sysconf(). # src=' #include int main(void) { - const char *p = { "", NULL }; - execvpe("", p, p); + (void)sysconf(0); return 0; }' -check_func "execvpe" "$src" || { - printf 'OPENBSD += execvpe.o\n' >>$CONFIG_MK -} +check_func "sysconf" "$src" # -# Check for setresuid(). +# Check for /proc/$PID. +# +printf 'Checking for %-14s\t\t' "/proc/\$PID ..." >&2 +if test -d /proc/$$; then + printf 'yes.\n' >&2 + printf 'CFLAGS += -DHAVE_%s\n' "PROC_PID" >>$CONFIG_MK +else + printf 'no.\n' >&2 +fi + +# +# Check for dirfd(). # src=' -#include +#include int main(void) { - setresuid(0, 0, 0); + (void)dirfd(0); return 0; }' -check_func "setresuid" "$src" || { - printf 'OPENBSD += setresuid.o\n' >>$CONFIG_MK -} +check_func "dirfd" "$src" # -# Check for pledge(). +# Check for fcntl.h. # src=' -#include +#include int main(void) { - pledge("", NULL); return 0; }' -check_func "pledge" "$src" || { - printf 'OPENBSD += pledge-noop.o\n' >>$CONFIG_MK -} +check_func "fcntl_h" "$src" + +# +# Check for F_CLOSEM. +# +src=' +#include +#ifndef F_CLOSEM +#error no F_CLOSEM +#endif +int main(void) { + return 0; +}' +check_func "F_CLOSEM" "$src" + +# +# Check for dirent.h. +# +src=' +#include +int main(void) { + return 0; +}' +check_func "dirent_h" "$src" + +# +# Check for sys/ndir.h. +# +src=' +#include +int main(void) { + return 0; +}' +check_func "sys_ndir_h" "$src" + +# +# Check for sys/dir.h. +# +src=' +#include +int main(void) { + return 0; +}' +check_func "sys_dir_h" "$src" + +# +# Check for ndir.h. +# +src=' +#include +int main(void) { + return 0; +}' +check_func "ndir_h" "$src" # # @@ -348,3 +463,18 @@ __attribute__((__unused__)) static void foo(void){return;} check_func "__attribute__" "$src" || { printf 'CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK } + +auth=$(authmethod) +if [ $? -eq 0 ]; then + printf 'Using auth method\t\t\t%s.\n' "$auth" >&2 +else + printf 'Error auth method\t\t\n' >&2 + exit 1 +fi + +persist=$(persistmethod) +if [ $? -eq 0 ]; then + printf 'Using persist method\t\t\t%s.\n' "$persist" >&2 +else + printf 'Using persist method\t\t\tnone.\n' >&2 +fi