--datadir=DIR architecture-independent data files [PREFIX/share]
--mandir=DIR manual pages [DATADIR/man]
--sysconfdir=DIR directory for configuration files [/etc]
- --pamdir=DIR PAM directory [SYSCONFDIR/pam.d]
--build=build-alias a cpu-vendor-opsys for the system where the application will be built
--host=host-alias a cpu-vendor-opsys for the system where the application will run
--with-timestamp enable timestamp support
+ --without-kiss-insults disable kiss insults
+
--uid-max=NUM set UID_MAX (default 65535)
--gid-max=NUM set GID_MAX (default 65535)
# defaults
WITHOUT_TIMESTAMP=yes
+WITHOUT_KISS_INSULTS=""
UID_MAX=65535
GID_MAX=65535
--datadir) SHAREDIR=$var ;;
--mandir) MANDIR=$var ;;
--sysconfdir) SYSCONFDIR=$var ;;
- --pamdir) PAMDIR=$var ;;
--build) BUILD=$var ;;
--host) HOST=$var ;;
--target) TARGET=$var ;;
--with-shadow) WITHOUT_SHADOW=; WITHOUT_PAM=yes ;;
--without-pam) WITHOUT_PAM=yes ;;
--without-shadow) WITHOUT_SHADOW=yes ;;
+ --without-kiss-insults) WITHOUT_KISS_INSULTS=yes ;;
--with-timestamp) WITHOUT_TIMESTAMP= ;;
--without-timestamp) WITHOUT_TIMESTAMP=yes ;;
--uid-max) UID_MAX=$var ;;
!
-cat <<EOF >>$CONFIG_MK
-PREFIX ?= ${PREFIX:="/usr"}
-EPREFIX ?= ${EPREFIX:="${PREFIX}"}
-BINDIR ?= ${BINDIR:="${PREFIX}/bin"}
-SHAREDIR ?= ${SHAREDIR:="${PREFIX}/share"}
-MANDIR ?= ${MANDIR:="${SHAREDIR}/man"}
-SYSCONFDIR?= ${SYSCONFDIR:="/etc"}
-PAMDIR ?= ${PAMDIR:="${SYSCONFDIR}/pam.d"}
-EOF
-
if [ -z "$BUILD" ]; then
BUILD="$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')"
fi
printf 'Setting GID_MAX\t\t\t\t%d.\n' "$GID_MAX" >&2
printf '#define GID_MAX %s\n' "$GID_MAX" >>$CONFIG_H
OS_CFLAGS="$OS_CFLAGS -D_DEFAULT_SOURCE -D_GNU_SOURCE"
- printf 'CURDIR := .\n' >>$CONFIG_MK
+ ;;
+ netbsd)
+ OS_CFLAGS="$OS_CFLAGS -D_OPENBSD_SOURCE"
+ printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
+ : ${BINGRP:=wheel}
+ ;;
+ freebsd)
+ printf 'LDLIBS += -lutil\n' >>$CONFIG_MK
+ : ${BINGRP:=wheel}
+ ;;
+ darwin)
+ : ${BINGRP:=wheel}
;;
esac
+: ${PREFIX:=/usr/local}
+: ${EPREFIX:=${PREFIX}}
+: ${BINDIR:=${PREFIX}/bin}
+: ${SHAREDIR:=${PREFIX}/share}
+: ${MANDIR:=${SHAREDIR}/man}
+: ${SYSCONFDIR:=/etc}
+: ${BINMODE:=4755}
+: ${BINOWN:=root}
+: ${BINGRP:=root}
+
+cat <<EOF >>$CONFIG_MK
+PREFIX ?= ${PREFIX}
+EPREFIX ?= ${EPREFIX}
+BINDIR ?= ${BINDIR}
+SHAREDIR ?= ${SHAREDIR}
+MANDIR ?= ${MANDIR}
+SYSCONFDIR?= ${SYSCONFDIR}
+BINMODE ?= ${BINMODE}
+BINOWN ?= ${BINOWN}
+BINGRP ?= ${BINGRP}
+EOF
+
[ -n "$OS_CFLAGS" ] && \
- printf 'CFLAGS += %s\n' "$OS_CFLAGS" >>$CONFIG_MK
+ printf 'OS_CFLAGS += %s\n' "$OS_CFLAGS" >>$CONFIG_MK
[ -n "$DEBUG" ] && \
printf 'CFLAGS += -O0 -g\n' >>$CONFIG_MK
[ -n "$BUILD_STATIC" ] && \
printf 'CFLAGS += -static\n' >>$CONFIG_MK
-# Add CPPFLAGS/CFLAGS/LDFLAGS to CC for testing features
-XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS"
+# Add CPPFLAGS/CFLAGS/LDFLAGS/LDLIBS to CC for testing features
+XCC="${CC:=cc} $CFLAGS $OS_CFLAGS $CPPFLAGS $LDFLAGS $LDLIBS"
# Make sure to disable --as-needed for CC tests.
-XCC="$XCC -Wl,--no-as-needed"
+
+case "$OS" in
+ darwin) ;;
+ *) XCC="$XCC -Wl,--no-as-needed" ;;
+esac
check_func() {
func="$1"; src="$2"; shift 2
}'
[ -z "$WITHOUT_PAM" ] && check_func "pam_appl_h" "$src" && {
printf 'SRCS += pam.c\n' >>$CONFIG_MK
- printf 'LDFLAGS += -lpam\n' >>$CONFIG_MK
+ printf 'LDLIBS += -lpam\n' >>$CONFIG_MK
printf '#define USE_PAM\n' >>$CONFIG_H
printf 'pam\n'
-
- pam_file="pam.d__doas__${OS}"
- [ -e "$pam_file" ] && printf 'PAM_DOAS = %s\n' "$pam_file" >>$CONFIG_MK
return 0
}
}'
[ -z "$WITHOUT_SHADOW" ] && check_func "shadow_h" "$src" && {
printf 'SRCS += shadow.c\n' >>$CONFIG_MK
- printf 'LDFLAGS += -lcrypt\n' >>$CONFIG_MK
+ printf 'LDLIBS += -lcrypt\n' >>$CONFIG_MK
printf '#define USE_SHADOW\n' >>$CONFIG_H
printf 'shadow\n'
return 0
return 1
}
+definsults() {
+ printf 'SRCS += insults.c\n' >>$CONFIG_MK
+ [ "$WITHOUT_KISS_INSULTS" ] && {
+ printf 'Not using KISS insults'
+ return 0
+ }
+}
+
+
persistmethod() {
[ -z "$WITHOUT_TIMESTAMP" ] && {
printf '#define USE_TIMESTAMP\n' >>$CONFIG_H
# Check for verrc().
#
src='
+#include <stddef.h>
#include <err.h>
int main(void) {
- verrc(0, 0, "");
+ verrc(0, 0, "x", NULL);
return 0;
}'
check_func "verrc" "$src" || {
execvpe("", p, p);
return 0;
}'
-check_func "execvpe" "$src" || die "system has no execvpe(3): not supported"
+check_func "execvpe" "$src" || {
+ printf 'SRCS += libopenbsd/execvpe.c\n' >>$CONFIG_MK
+}
#
# Check for setresuid().
setresuid(0, 0, 0);
return 0;
}'
-check_func "setresuid" "$src" || {
+check_func "setresuid" "$src"
+have_setresuid=$?
+
+#
+# Check for setresgid().
+#
+src='
+#include <unistd.h>
+int main(void) {
+ setresgid(0, 0, 0);
+ return 0;
+}'
+check_func "setresgid" "$src"
+have_setresgid=$?
+
+if [ $have_setresuid -eq 1 -o $have_setresgid -eq 1 ]; then
printf 'SRCS += libopenbsd/bsd-setres_id.c\n' >>$CONFIG_MK
-}
+fi
+
+#
+# Check for setreuid().
+#
+src='
+#include <unistd.h>
+int main(void) {
+ setreuid(0, 0);
+ return 0;
+}'
+check_func "setreuid" "$src"
+
+
+#
+# Check for setregid().
+#
+src='
+#include <unistd.h>
+int main(void) {
+ setregid(0, 0);
+ return 0;
+}'
+check_func "setregid" "$src"
#
# Check for closefrom().
__attribute__((__unused__)) static void foo(void){return;}
'
check_func "__attribute__" "$src" || {
- printf 'CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
+ printf 'OS_CFLAGS += -DNO_ATTRIBUTE_ON_RETURN_TYPE=1\n' >>$CONFIG_MK
}
auth=$(authmethod)
exit 1
fi
+insults=$(definsults)
+
persist=$(persistmethod)
if [ $? -eq 0 ]; then
printf 'Using persist method\t\t\t%s.\n' "$persist" >&2