Commit Diff


commit - b9c0e1a44c0d96b5fbc86c4f24ead705d46bdb1f
commit + 0efd7c9a43ed9b0fe0b47cdc09e91334d11d1909
blob - 4cbf3b74a2901ae9e6700aa28ebc5c331e49ae7a
blob + 7c3b37f68dac8ca94a20e66d06da32d54cc79251
--- .gitignore
+++ .gitignore
@@ -1,4 +1,10 @@
-*.o
-*.d
+Makefile.configure
+lstun
+config.h
+config.h.old
+config.log
+config.log.old
+**/*.o
+**/*.d
 **/obj
-**/lstun
+**/tags
blob - 501902c58ff5ea82a0af183741a15edede27c832
blob + 2f7bc77eb85e4bace728ebdde64edcb732da99d8
--- Makefile
+++ Makefile
@@ -1,44 +1,77 @@
+.PHONY: all clean distclean install
+
+VERSION =	0.4
 PROG =		lstun
-SRCS =		lstun.c log.c
+DISTNAME =	${PROG}-${VERSION}
 
-LDADD =		-levent
-DPADD =		${LIBEVENT}
+HEADERS =	log.h
 
-WARNINGS =	yes
+SOURCES =	compats.c \
+		log.c \
+		lstun.c
 
-.include "lstun-version.mk"
+OBJS =		${SOURCES:.c=.o}
 
-.if "${LSTUN_RELEASE}" == "Yes"
-PREFIX ?= /usr/local
-BINDIR ?= ${PREFIX}/bin
-MANDIR ?= ${PREFIX}/man/man
-.else
-NOMAN = Yes
-PREFIX ?= ${HOME}
-BINDIR ?= ${PREFIX}/bin
-BINOWN ?= ${USER}
-.if !defined(BINGRP)
-BINGRP != id -g -n
-.endif
-DEBUG = -O0 -g
-.endif
+DISTFILES =	CHANGES \
+		LICENSE \
+		Makefile \
+		README.md \
+		configure \
+		lstun.1 \
+		${HEADERS} \
+		${SOURCES}
 
-release: clean
-	sed -i -e 's/_RELEASE=No/_RELEASE=Yes/' lstun-version.mk
-	${MAKE} dist
-	sed -i -e 's/_RELEASE=No/_RELEASE=No/' lstun-version.mk
+all: ${PROG}
 
-dist: clean
-	mkdir /tmp/lstun-${LSTUN_VERSION}
-	pax -rw * /tmp/lstun-${LSTUN_VERSION}
-	find /tmp/lstun-${LSTUN_VERSION} -type d -name obj -delete
-	rm /tmp/lstun-${LSTUN_VERSION}/lstun-dist.txt
-	tar -C /tmp -zcf lstun-${LSTUN_VERSION}.tar.gz lstun-${LSTUN_VERSION}
-	rm -rf /tmp/lstun-${LSTUN_VERSION}/
-	tar -ztf lstun-${LSTUN_VERSION}.tar.gz | \
-		sed -e 's/^lstun-${LSTUN_VERSION}//' | \
-		sort > lstun-dist.txt.new
-	diff -u lstun-dist.txt lstun-dist.txt.new
-	rm lstun-dist.txt.new
+Makefile.configure config.h: configure tests.c
+	@echo "$@ is out of date; please run ./configure"
+	@exit 1
 
-.include <bsd.prog.mk>
+include Makefile.configure
+
+# -- targets --
+
+${PROG}: ${OBJS}
+	${CC} -o $@ ${OBJS} ${LDFLAGS} ${LDADD}
+
+clean:
+	rm -f ${OBJS} ${OBJS:.o=.d} ${PROG}
+
+distclean: clean
+	rm -f Makefile.configure config.h config.h.old config.log config.log.old
+
+install: ${PROG}
+	mkdir -p ${DESTDIR}${BINDIR}
+	mkdir -p ${DESTDIR}${MANDIR}/man1
+	${INSTALL_PROGRAM} ${PROG} ${DESTDIR}${BINDIR}
+	${INSTALL_MAN} lstun.1 ${DESTDIR}${MANDIR}/man1/${PROG.1}
+
+install-local: ${PROG}
+	mkdir -p ${HOME}/bin
+	${INSTALL_PROGRAM} ${PROG} ${HOME}/bin
+
+uninstall:
+	rm ${DESTDIR}${BINDIR}/${PROG}
+	rm ${DESTDIR}${MANDIR}/man1/${PROG}.1
+
+# --- maintainer targets ---
+
+dist: ${DISTNAME}.sha256
+
+${DISTNAME}.sha256: ${DISTNAME}.tar.gz
+	sha256 ${DISTNAME}.tar.gz > $@
+
+${DISTNAME}.tar.gz: ${DISTFILES}
+	mkdir -p .dist/${DISTNAME}
+	${INSTALL} -m 0644 ${DISTFILES} .dist/${DISTNAME}
+	chmod 755 .dist/${DISTNAME}/configure
+	cd .dist && tar zcf ../$@ ${DISTNAME}
+	rm -rf .dist
+
+# -- dependency management ---
+
+# these .d files are produced during the first build if the compiler
+# supports it.
+
+-include log.d
+-include lstun.d
blob - 362b9c4cbfe5998442528d99f3faaa2315f44972
blob + 274d7c6a51cd85118f48783e9d48b880cca384e7
--- log.c
+++ log.c
@@ -14,6 +14,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
blob - /dev/null
blob + 2d4f92944b7bfc8d6e388621c2379cf59f22588e (mode 644)
--- /dev/null
+++ compats.c
@@ -0,0 +1,225 @@
+#include "config.h"
+#if !HAVE_GETPROGNAME
+/*
+ * Copyright (c) 2016 Nicholas Marriott <nicholas.marriott@gmail.com>
+ * Copyright (c) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2020 Stephen Gregoratto <dev@sgregoratto.me>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include <errno.h>
+
+#if HAVE_GETEXECNAME
+#include <stdlib.h>
+const char *
+getprogname(void)
+{
+	return getexecname();
+}
+#elif HAVE_PROGRAM_INVOCATION_SHORT_NAME
+const char *
+getprogname(void)
+{
+	return (program_invocation_short_name);
+}
+#elif HAVE___PROGNAME
+const char *
+getprogname(void)
+{
+	extern char	*__progname;
+
+	return (__progname);
+}
+#else
+#warning No getprogname available.
+const char *
+getprogname(void)
+{
+	return ("lstun");
+}
+#endif
+#endif /* !HAVE_GETPROGNAME */
+#if !HAVE_STRLCAT
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left).  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+	char *d = dst;
+	const char *s = src;
+	size_t n = siz;
+	size_t dlen;
+
+	/* Find the end of dst and adjust bytes left but don't go past end */
+	while (n-- != 0 && *d != '\0')
+		d++;
+	dlen = d - dst;
+	n = siz - dlen;
+
+	if (n == 0)
+		return(dlen + strlen(s));
+	while (*s != '\0') {
+		if (n != 1) {
+			*d++ = *s;
+			n--;
+		}
+		s++;
+	}
+	*d = '\0';
+
+	return(dlen + (s - src));	/* count does not include NUL */
+}
+#endif /* !HAVE_STRLCAT */
+#if !HAVE_STRLCPY
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+	char *d = dst;
+	const char *s = src;
+	size_t n = siz;
+
+	/* Copy as many bytes as will fit */
+	if (n != 0) {
+		while (--n != 0) {
+			if ((*d++ = *s++) == '\0')
+				break;
+		}
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src */
+	if (n == 0) {
+		if (siz != 0)
+			*d = '\0';		/* NUL-terminate dst */
+		while (*s++)
+			;
+	}
+
+	return(s - src - 1);	/* count does not include NUL */
+}
+#endif /* !HAVE_STRLCPY */
+#if !HAVE_STRTONUM
+/*
+ * Copyright (c) 2004 Ted Unangst and Todd Miller
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+
+#define	INVALID		1
+#define	TOOSMALL	2
+#define	TOOLARGE	3
+
+long long
+strtonum(const char *numstr, long long minval, long long maxval,
+    const char **errstrp)
+{
+	long long ll = 0;
+	int error = 0;
+	char *ep;
+	struct errval {
+		const char *errstr;
+		int err;
+	} ev[4] = {
+		{ NULL,		0 },
+		{ "invalid",	EINVAL },
+		{ "too small",	ERANGE },
+		{ "too large",	ERANGE },
+	};
+
+	ev[0].err = errno;
+	errno = 0;
+	if (minval > maxval) {
+		error = INVALID;
+	} else {
+		ll = strtoll(numstr, &ep, 10);
+		if (numstr == ep || *ep != '\0')
+			error = INVALID;
+		else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
+			error = TOOSMALL;
+		else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)
+			error = TOOLARGE;
+	}
+	if (errstrp != NULL)
+		*errstrp = ev[error].errstr;
+	errno = ev[error].err;
+	if (error)
+		ll = 0;
+
+	return (ll);
+}
+#endif /* !HAVE_STRTONUM */
blob - /dev/null
blob + 4e61c324c9b6c6d2d37d2cb800b1f0c732c2fd7c (mode 755)
--- /dev/null
+++ configure
@@ -0,0 +1,622 @@
+#! /bin/sh
+#
+# Copyright (c) 2014, 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2017, 2018 Kristaps Dzonsons <kristaps@bsd.lv>
+# Copyright (c) 2022 Omar Polo <op@omarpolo.com>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+OCONFIGURE_VERSION="0.3.8"
+
+#
+# This script outputs two files: config.h and Makefile.configure.
+# It tries to read from configure.local, which contains predefined
+# values we won't autoconfigure.
+#
+# If you want to use configure with your project, have your GNUmakefile
+# or BSDmakefile---whichever---try to import/include Makefile.configure
+# at the beginning of the file.
+#
+# Like so (note no quotes, no period, etc.):
+#
+#   include Makefile.configure
+#
+# If it exists, configure was run; otherwise, it wasn't.
+#
+# You'll probably want to change parts of this file.  I've noted the
+# parts that you'll probably change in the section documentation.
+#
+# See https://github.com/kristapsdz/oconfigure for more.
+
+set -e
+
+# try to be helpful
+case "$1" in
+--help|-h)
+	cat <<EOF
+\`configure' configures lstun to adapt to many kinds of systems.
+
+Usage: $0 [-h] [--prefix=path] [VAR=VALUE]...
+
+The options are as follows:
+
+    -h, --help     print this help message
+
+    --prefix=path  equivalent to specifying the PREFIX variable, supported
+                   for compatibility with other common "configure" scripts.
+
+Variables available:
+
+    LDADD                  generic linker flags
+    LDADD_LIBEVENT         linker flags for libevent
+    LDADD_LIBEVENT2        linker flags for libevent2
+    LDADD_LIBSOCKET        linker flags for libsocket
+    LDFLAGS                extra linker flags
+    CPPFLAGS               C preprocessors flags
+    DESTDIR                destination directory
+    PREFIX                 where to install files
+    MANDIR                 where to install man pages (PREFIX/man)
+    LIBDIR                 where to install libraries (PREFIX/lib)
+    BINDIR                 where to install executables (PREFIX/bin)
+    SHAREDIR               where to install misc files (PREFIX/share)
+    SBINDIR                where to install system executables (PREFIX/sbin)
+    INCLUDEDIR             where to install header files (PREFIX/include)
+    PKG_CONFIG             path to the pkg-config program or empty to disable
+
+Additionally, the following environment variables are used if set:
+
+    CC        the C compiler to use (defaults to cc, clang or gcc)
+    CFLAGS    generic C compiler flags
+
+EOF
+	exit 0 ;;
+esac
+
+#----------------------------------------------------------------------
+# Prepare for running: move aside previous configure runs.
+# Output file descriptor usage:
+#  1 (stdout): config.h or Makefile.configure
+#  2 (stderr): original stderr, usually to the console
+#  3: config.log
+# You DO NOT want to change this.
+#----------------------------------------------------------------------
+
+[ -w config.log ] && mv config.log config.log.old
+[ -w config.h   ] && mv config.h config.h.old
+
+exec 3> config.log
+echo "config.log: writing..."
+
+# GNU submake prints different output if invoked recursively, which
+# messes up CC and CFLAGS detection.  Pass --no-print-directory if
+# we have a MAKELEVEL (GNU and FreeBSD make) and the argument is
+# allowed.
+
+MAKE_FLAGS=""
+
+if [ -n "${MAKELEVEL}" ]; then
+	if [ "${MAKELEVEL}" -gt 0 ] ; then
+		MAKE_FLAGS="--no-print-directory"
+		echo "all:" | make ${MAKE_FLAGS} -sf - 2>/dev/null || MAKE_FLAGS=""
+	fi
+fi
+
+if [ -n "$MAKE_FLAGS" ]; then
+	echo "GNU submake detected: using --no-print-directory" 1>&2
+	echo "GNU submake detected: using --no-print-directory" 1>&3
+fi
+
+#----------------------------------------------------------------------
+# Initialize all variables here such that nothing can leak in from the
+# environment except for CC and CFLAGS, which we might have passed in.
+#----------------------------------------------------------------------
+
+CC=`printf "all:\\n\\t@echo \\\$(CC)\\n" | make ${MAKE_FLAGS} -sf -`
+CFLAGS=`printf "all:\\n\\t@echo \\\$(CFLAGS)\\n" | make ${MAKE_FLAGS} -sf -`
+CFLAGS="${CFLAGS} -g -W -Wall -Wmissing-prototypes -Wstrict-prototypes"
+CFLAGS="${CFLAGS} -Wmissing-declarations -Wno-unused-parameter"
+CFLAGS="${CFLAGS} -Wno-sign-compare"
+LDADD=
+LDADD_LIBEVENT=
+LDADD_LIBEVENT2=
+LDADD_LIB_SOCKET=
+LDADD_STATIC=
+CPPFLAGS=
+LDFLAGS=
+DESTDIR=
+PREFIX="/usr/local"
+BINDIR=
+SBINDIR=
+INCLUDEDIR=
+LIBDIR=
+MANDIR=
+SHAREDIR=
+INSTALL="install"
+INSTALL_PROGRAM=
+INSTALL_LIB=
+INSTALL_MAN=
+INSTALL_DATA=
+PKG_CONFIG=
+
+# SunOS sets "cc", but this doesn't exist.
+# It does have gcc, so try that instead.
+# Prefer clang, though.
+
+command -v ${CC} 2>/dev/null 1>&2 || {
+	echo "${CC} not found: trying clang" 1>&2
+	echo "${CC} not found: trying clang" 1>&3
+	CC=clang
+	command -v ${CC} 2>/dev/null 1>&2 || {
+		echo "${CC} not found: trying gcc" 1>&2
+		echo "${CC} not found: trying gcc" 1>&3
+		CC=gcc
+		command -v ${CC} 2>/dev/null 1>&2 || {
+			echo "gcc not found: giving up" 1>&2
+			echo "gcc not found: giving up" 1>&3
+			exit 1
+		}
+	}
+}
+
+command -v pkg-config 2>/dev/null 1>&2 && {
+	PKG_CONFIG=pkg-config
+	echo "pkg-config found" 1>&2
+	echo "pkg-config found" 1>&3
+} || {
+	echo "pkg-config not found" 1>&2
+	echo "pkg-config not found" 1>&3
+}
+
+#----------------------------------------------------------------------
+# Allow certain variables to be overriden on the command line.
+#----------------------------------------------------------------------
+
+while [ $# -gt 0 ]; do
+	key=${1%%=*}
+	val=${1#*=}
+
+	if [ "$key" = "--prefix" ]; then
+		key=PREFIX
+		if [ "$1" = "--prefix" ]; then
+			if ! shift 2>&1 >/dev/null; then
+				echo "$0: missing value for --prefix" 1>&2
+				exit 1
+			fi
+			val="$1"
+		fi
+	fi
+
+	if [ "$1" = "$key" ]; then
+		echo "$0: invalid key-value: $1" 1>&2
+		exit 1
+	fi
+
+	shift
+
+	case "$key" in
+	LDADD)
+		LDADD="$val" ;;
+	LDADD_LIBEVENT)
+		LDADD_LIBEVENT="$val" ;;
+	LDADD_LIBEVENT2)
+		LDADD_LIBEVENT2="$val" ;;
+	LDADD_LIBSOCKET)
+		LDADD_LIBSOCKET="$val" ;;
+	LDFLAGS)
+		LDFLAGS="$val" ;;
+	CPPFLAGS)
+		CPPFLAGS="$val" ;;
+	DESTDIR)
+		DESTDIR="$val" ;;
+	PREFIX)
+		PREFIX="$val" ;;
+	MANDIR)
+		MANDIR="$val" ;;
+	LIBDIR)
+		LIBDIR="$val" ;;
+	BINDIR)
+		BINDIR="$val" ;;
+	SHAREDIR)
+		SHAREDIR="$val" ;;
+	SBINDIR)
+		SBINDIR="$val" ;;
+	INCLUDEDIR)
+		INCLUDEDIR="$val" ;;
+	PKG_CONFIG)
+		PKG_CONFIG="$val" ;;
+	*)
+		echo "$0: invalid key: $key" 1>&2
+		exit 1
+	esac
+done
+
+
+#----------------------------------------------------------------------
+# These are the values that will be pushed into config.h after we test
+# for whether they're supported or not.
+# Each of these must have a runtest(), below.
+# Please sort by alpha, for clarity.
+# You WANT to change this.
+#----------------------------------------------------------------------
+
+HAVE_GETEXECNAME=
+HAVE_GETPROGNAME=
+HAVE_LIBEVENT=
+HAVE_LIBEVENT2=0		# may not be checked
+HAVE_PLEDGE=
+HAVE_PROGRAM_INVOCATION_SHORT_NAME=
+HAVE_PR_SET_NAME=
+HAVE_STRLCAT=
+HAVE_STRLCPY=
+HAVE_STRTONUM=
+HAVE_UNVEIL=
+HAVE___PROGNAME=
+
+#----------------------------------------------------------------------
+# Allow configure.local to override all variables, default settings,
+# command-line arguments, and tested features, above.
+# You PROBABLY DO NOT want to change this.
+#----------------------------------------------------------------------
+
+if [ -r ./configure.local ]; then
+	echo "configure.local: reading..." 1>&2
+	echo "configure.local: reading..." 1>&3
+	cat ./configure.local 1>&3
+	. ./configure.local
+else
+	echo "configure.local: no (fully automatic configuration)" 1>&2
+	echo "configure.local: no (fully automatic configuration)" 1>&3
+fi
+
+echo 1>&3
+
+#----------------------------------------------------------------------
+# Infrastructure for running tests.
+# These consists of a series of functions that will attempt to run the
+# given test file and record its exit into a HAVE_xxx variable.
+# You DO NOT want to change this.
+#----------------------------------------------------------------------
+
+COMP="${CC} ${CFLAGS} ${CPPFLAGS} -Wno-unused -Werror"
+
+# Check whether this HAVE_ setting is manually overridden.
+# If yes, use the override, if no, do not decide anything yet.
+# Arguments: lower-case test name, manual value
+
+ismanual() {
+	[ -z "${3}" ] && return 1
+	echo "${1}: manual (HAVE_${2}=${3})" 1>&2
+	echo "${1}: manual (HAVE_${2}=${3})" 1>&3
+	echo 1>&3
+	return 0
+}
+
+# Run a single autoconfiguration test.
+# In case of success, enable the feature.
+# In case of failure, do not decide anything yet.
+# Arguments: lower-case test name, upper-case test name, additional
+# CFLAGS, additional LIBS.
+
+singletest() {
+	extralib=""
+	pkgcfs=""
+	pkglib=""
+
+	cat 1>&3 <<EOF
+${1}: testing...
+${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${4}
+EOF
+	if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${4} 1>&3 2>&3; then
+		echo "${1}: ${CC} succeeded" 1>&3
+	else
+		if [ -n "${5}" ] ; then
+			echo "${1}: ${CC} failed with $? (retrying)" 1>&3
+			cat 1>&3 <<EOF
+${1}: testing...
+${COMP} -DTEST_${2} ${3} -o test-${1} tests.c ${LDFLAGS} ${5}
+EOF
+			if ${COMP} -DTEST_${2} ${3} -o "test-${1}" tests.c ${LDFLAGS} ${5} 1>&3 2>&3; then
+				echo "${1}: ${CC} succeeded" 1>&3
+				extralib="(with ${5})"
+			else
+				test -n "${PKG_CONFIG}" -a -n "${6}" && ${PKG_CONFIG} "$6"
+				if [ $? -eq 0 ]; then
+					echo "${1}: ${CC} failed with $? (retrying)" 1>&3
+					pkgcfs=$($PKG_CONFIG --cflags "${6}")
+					pkglib=$($PKG_CONFIG --libs "${6}")
+					cat 1>&3 <<EOF
+${1}: testing...
+${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib}
+EOF
+					if ${COMP} -DTEST_${2} ${3} ${pkgcfs} -o test-${1} tests.c ${LDFLAGS} ${pkglib} 1>&3 2>&3; then
+						echo "${1}: ${CC} succeeded" 1>&3
+						extralib="(with ${pkgcfs} ${pkglib})"
+					else
+						echo "${1}: ${CC} failed with $?" 1>&3
+						echo 1>&3
+						return 1
+					fi
+				else
+					echo "${1}: ${CC} failed with $?" 1>&3
+					echo 1>&3
+					return 1
+				fi
+			fi
+		else
+			echo "${1}: ${CC} failed with $?" 1>&3
+			echo 1>&3
+			return 1
+		fi
+	fi
+
+	rm -f test-${1}.d
+
+	if [ -n "${pkgcfs}" -o -n "${pkglib}" ]
+	then
+		CFLAGS="${CFLAGS} ${pkgcfs}"
+		eval "LDADD_${2}=\"${pkglib}\""
+	elif [ -n "${extralib}" ]
+	then
+		eval "LDADD_${2}=\"${5}\""
+	elif [ -n "${4}" ]
+	then
+		eval "LDADD_${2}=\"${4}\""
+	fi
+
+	echo "${1}: yes ${extralib}" 1>&2
+	echo "${1}: yes ${extralib}" 1>&3
+	echo 1>&3
+	eval HAVE_${2}=1
+	rm "test-${1}"
+	return 0
+}
+
+# Run a complete autoconfiguration test, including the check for
+# a manual override and disabling the feature on failure.
+# Arguments: lower case name, upper case name, additional CFLAGS,
+# additional LDADD, alternative LDADD, pkg-config name.
+
+runtest() {
+	eval _manual=\${HAVE_${2}}
+	ismanual "${1}" "${2}" "${_manual}" && return 0
+	singletest "${1}" "${2}" "${3}" "${4}" "${5}" "${6}" && return 0
+	echo "${1}: no" 1>&2
+	eval HAVE_${2}=0
+	return 1
+}
+
+#----------------------------------------------------------------------
+# Begin running the tests themselves.
+# All of your tests must be defined here.
+# Please sort as the HAVE_xxxx values were defined.
+# You WANT to change this.
+# It consists of the following columns:
+#    runtest
+#    (1) test file
+#    (2) macro to set
+#    (3) argument to cc *before* -o
+#    (4) argument to cc *after*
+#    (5) alternative argument to cc *after*
+#    (6) name for pkg-config auto-discovery
+#----------------------------------------------------------------------
+
+if runtest -MMD _MMD -MMD; then
+	CFLAGS="${CFLAGS} -MMD"
+	echo "adding -MMD to CFLAGS" 1>&2
+	echo "adding -MMD to CFLAGS" 1>&3
+fi
+
+runtest getexecname	GETEXECNAME			  || true
+runtest getprogname	GETPROGNAME			  || true
+
+runtest libevent	LIBEVENT "" "" "-levent"	  || \
+runtest libevent2	LIBEVENT2 "" "" "-levent_extra -levent_core" "libevent" || true
+
+runtest lib_socket	LIB_SOCKET "" "" "-lsocket -lnsl" || true
+runtest pledge		PLEDGE				  || true
+runtest program_invocation_short_name	PROGRAM_INVOCATION_SHORT_NAME || true
+runtest PR_SET_NAME	PR_SET_NAME			  || true
+runtest static		STATIC "" "-static"		  || true
+runtest strlcat		STRLCAT				  || true
+runtest strlcpy		STRLCPY				  || true
+runtest strtonum	STRTONUM			  || true
+runtest unveil		UNVEIL				  || true
+runtest __progname	__PROGNAME			  || true
+
+if [ "${HAVE_LIBEVENT}" -eq 0 -a "${HAVE_LIBEVENT2}" -eq 0 ]; then
+	echo "Fatal: missing libevent" 1>&2
+	echo "Fatal: missing libevent" 1>&3
+	exit 1
+fi
+
+#----------------------------------------------------------------------
+# Output writing: generate the config.h file.
+# This file contains all of the HAVE_xxxx variables necessary for
+# compiling your source.
+# You must include "config.h" BEFORE any other variables.
+# You WANT to change this.
+#----------------------------------------------------------------------
+
+exec > config.h
+
+# Start with prologue.
+
+cat <<EOF
+#ifndef OCONFIGURE_CONFIG_H
+#define OCONFIGURE_CONFIG_H
+
+#ifdef __cplusplus
+# error "Do not use C++: this is a C application."
+#endif
+#if !defined(__GNUC__) || (__GNUC__ < 4)
+# define __attribute__(x)
+#endif
+#if defined(__linux__) || defined(__MINT__)
+# define _GNU_SOURCE /* memmem, memrchr, setresuid... */
+# define _DEFAULT_SOURCE /* le32toh, crypt, ... */
+#endif
+#if defined(__NetBSD__)
+# define _OPENBSD_SOURCE /* reallocarray, etc. */
+#endif
+#if defined(__sun)
+# ifndef _XOPEN_SOURCE /* SunOS already defines */
+#  define _XOPEN_SOURCE /* XPGx */
+# endif
+# define _XOPEN_SOURCE_EXTENDED 1 /* XPG4v2 */
+# ifndef __EXTENSIONS__ /* SunOS already defines */
+#  define __EXTENSIONS__ /* reallocarray, etc. */
+# endif
+#endif
+#if !defined(__BEGIN_DECLS)
+# define __BEGIN_DECLS
+#endif
+#if !defined(__END_DECLS)
+# define __END_DECLS
+#endif
+
+EOF
+
+# This is just for size_t, mode_t, and dev_t.
+# Most of these functions, in the real world, pull in <string.h> or
+# someting that pulls in support for size_t.
+# Our function declarations are standalone, so specify them here.
+
+if [ ${HAVE_STRLCAT} -eq 0 -o \
+     ${HAVE_STRLCPY} -eq 0 ]
+then
+	echo "#include <sys/types.h> /* size_t, mode_t, dev_t */ "
+	echo
+fi
+
+if [ ${HAVE_GETPROGNAME} -eq 0 ]; then
+	echo "#include <stdlib.h>"
+	echo
+fi
+
+if [ ${HAVE_PLEDGE} -eq 0 -o ${HAVE_UNVEIL} -eq 0 ]; then
+	echo "#include <unistd.h>"
+	echo
+fi
+
+if [ ${HAVE_LIBEVENT2} -eq 1 ]; then
+	cat <<EOF
+#include <event2/event.h>
+#include <event2/event_compat.h>
+#include <event2/event_struct.h>
+#include <event2/buffer.h>
+#include <event2/buffer_compat.h>
+#include <event2/bufferevent.h>
+#include <event2/bufferevent_struct.h>
+#include <event2/bufferevent_compat.h>
+EOF
+fi
+
+if [ ${HAVE_LIBEVENT} -eq 1 ]; then
+	cat <<EOF
+#include <event.h>
+EOF
+fi
+
+# Now we handle our HAVE_xxxx values.
+# Most will just be defined as 0 or 1.
+
+cat <<EOF
+
+/*
+ * Results of configuration feature-testing.
+ */
+#define HAVE_GETEXECNAME ${HAVE_GETEXECNAME}
+#define HAVE_GETPROGNAME ${HAVE_GETPROGNAME}
+#define HAVE_PLEDGE ${HAVE_PLEDGE}
+#define HAVE_PROGRAM_INVOCATION_SHORT_NAME ${HAVE_PROGRAM_INVOCATION_SHORT_NAME}
+#define HAVE_PR_SET_NAME ${HAVE_PR_SET_NAME}
+#define HAVE_STRLCAT ${HAVE_STRLCAT}
+#define HAVE_STRLCPY ${HAVE_STRLCPY}
+#define HAVE_STRTONUM ${HAVE_STRTONUM}
+#define HAVE_UNVEIL ${HAVE_UNVEIL}
+#define HAVE___PROGNAME ${HAVE___PROGNAME}
+
+/* Now we do our function declarations for missing functions. */
+
+#if !HAVE_GETPROGNAME
+extern const char *getprogname(void);
+#endif
+
+#if !HAVE_STRLCAT
+extern size_t strlcat(char *, const char *, size_t);
+#endif
+
+#if !HAVE_STRLCPY
+extern size_t strlcpy(char *, const char *, size_t);
+#endif
+
+#if !HAVE_STRTONUM
+extern long long strtonum(const char *, long long, long long, const char **);
+#endif
+
+#ifndef __dead
+# define __dead __attribute__((noreturn))
+#endif
+
+#endif /*!OCONFIGURE_CONFIG_H*/
+EOF
+
+echo "config.h: written" 1>&2
+echo "config.h: written" 1>&3
+
+#----------------------------------------------------------------------
+# Now we go to generate our Makefile.configure.
+# This file is simply a bunch of Makefile variables.
+# They'll work in both GNUmakefile and BSDmakefile.
+# You MIGHT want to change this.
+#----------------------------------------------------------------------
+
+exec > Makefile.configure
+
+[ -z "${BINDIR}"     ] && BINDIR="${PREFIX}/bin"
+[ -z "${SBINDIR}"    ] && SBINDIR="${PREFIX}/sbin"
+[ -z "${INCLUDEDIR}" ] && INCLUDEDIR="${PREFIX}/include"
+[ -z "${LIBDIR}"     ] && LIBDIR="${PREFIX}/lib"
+[ -z "${MANDIR}"     ] && MANDIR="${PREFIX}/man"
+[ -z "${SHAREDIR}"   ] && SHAREDIR="${PREFIX}/share"
+
+[ -z "${INSTALL_PROGRAM}" ] && INSTALL_PROGRAM="${INSTALL} -m 0555"
+[ -z "${INSTALL_LIB}"     ] && INSTALL_LIB="${INSTALL} -m 0444"
+[ -z "${INSTALL_MAN}"     ] && INSTALL_MAN="${INSTALL} -m 0444"
+[ -z "${INSTALL_DATA}"    ] && INSTALL_DATA="${INSTALL} -m 0444"
+
+cat <<EOF
+CC		 = ${CC}
+CFLAGS		 = ${CFLAGS}
+CPPFLAGS	 = ${CPPFLAGS}
+LDADD		 = ${LDADD} ${LDADD_LIB_SOCKET} ${LDADD_LIBEVENT} ${LDADD_LIBEVENT2}
+LDADD_STATIC	 = ${LDADD_STATIC}
+LDFLAGS		 = ${LDFLAGS}
+PREFIX		 = ${PREFIX}
+BINDIR		 = ${BINDIR}
+SHAREDIR	 = ${SHAREDIR}
+SBINDIR		 = ${SBINDIR}
+INCLUDEDIR	 = ${INCLUDEDIR}
+LIBDIR		 = ${LIBDIR}
+MANDIR		 = ${MANDIR}
+INSTALL		 = ${INSTALL}
+INSTALL_PROGRAM	 = ${INSTALL_PROGRAM}
+INSTALL_LIB	 = ${INSTALL_LIB}
+INSTALL_MAN	 = ${INSTALL_MAN}
+INSTALL_DATA	 = ${INSTALL_DATA}
+EOF
+
+echo "Makefile.configure: written" 1>&2
+echo "Makefile.configure: written" 1>&3
+
+exit 0
blob - abb6767fc3272187b2f08e24e44f3e300cf6161d (mode 644)
blob + /dev/null
--- lstun-dist.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-
-/CHANGES
-/LICENSE
-/Makefile
-/README.md
-/log.c
-/log.h
-/lstun-version.mk
-/lstun.1
-/lstun.c
blob - /dev/null
blob + 1a4f64ba577477d9676b7c3834d1a6682489b9e7 (mode 644)
--- /dev/null
+++ configure.local.example
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2022 Omar Polo <op@openbsd.org>
+# Copyright (c) 2014-2022 Ingo Schwarze <schwarze@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+# For all settings documented in this file, there are reasonable
+# defaults and/or the ./configure script attempts autodetection.
+# Consequently, you only need to create a file ./configure.local
+# and put any of these settings into it if ./configure autodetection
+# fails or if you want to make different choices for other reasons.
+
+# If autodetection fails, please tell <op@omarpolo.com>.
+
+# We recommend that you write ./configure.local from scratch and
+# only put the lines there you need.  This file contains examples.
+# It is not intended as a template to be copied as a whole.
+
+# Some systems may want to set additional linker flags for all the
+# binaries, for example for hardening options.
+
+LDFLAGS="-Wl,-z,relro"
+
+# It may be needed to change the flags for the individual libraries.
+
+LDADD_LIBEVENT2="-L/opt/lib/ -levent_extra -levent_core"
+LDADD_LIB_SOCKET=
+
+# To disable the autoconfiguration via pkg-config set PKG_CONFIG to
+# `false' or to the empty string:
+
+PKG_CONFIG=
+
+# It is possible to change the utility program used for installation
+# and the modes files are installed with.  The defaults are:
+
+INSTALL="install"
+INSTALL_PROGRAM="${INSTALL} -m 0555"
+INSTALL_LIB="${INSTALL} -m 0444"
+INSTALL_MAN="${INSTALL} -m 0444"
+INSTALL_DATA="${INSTALL} -m 0444"
+
+# In rare cases, it may be required to skip individual automatic tests.
+# Each of the following variables can be set to 0 (test will not be run
+# and will be regarded as failed) or 1 (test will not be run and will
+# be regarded as successful).
+
+HAVE_GETEXECNAME=0
+HAVE_GETPROGNAME=0
+HAVE_LIBEVENT=0
+HAVE_LIBEVENT2=0
+HAVE_PLEDGE=0
+HAVE_PROGRAM_INVOCATION_SHORT_NAME=0
+HAVE_PR_SET_NAME=0
+HAVE_STRLCAT=0
+HAVE_STRLCPY=0
+HAVE_STRTONUM=0
+HAVE_UNVEIL=0
+HAVE___PROGNAME=0
blob - 2dd9cbadc09c9dae5ffdecda3a0b0189304fc792 (mode 644)
blob + /dev/null
--- lstun-version.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-LSTUN_RELEASE=No
-LSTUN_VERSION_NUMBER=0.3
-
-.if ${LSTUN_RELEASE} == Yes
-LSTUN_VERSION=${LSTUN_VERSION_NUMBER}
-.else
-LSTUN_VERSION=${LSTUN_VERSION_NUMBER}-current
-.endif
blob - 8c56f86d766d0657350427f9e6358550c5bb0354
blob + 76d1c926a07fddfea1512f3aa474e861975525e1
--- lstun.c
+++ lstun.c
@@ -14,6 +14,8 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include "config.h"
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
@@ -21,7 +23,6 @@
 
 #include <ctype.h>
 #include <errno.h>
-#include <event.h>
 #include <fcntl.h>
 #include <limits.h>
 #include <netdb.h>
blob - /dev/null
blob + 3ac5d07899463dd2f7686bdb4d644b9b756021fd (mode 644)
--- /dev/null
+++ tests.c
@@ -0,0 +1,200 @@
+#if TEST_GETEXECNAME
+#include <stdlib.h>
+
+int
+main(void)
+{
+	const char * progname;
+
+	progname = getexecname();
+	return progname == NULL;
+}
+#endif /* TEST_GETEXECNAME */
+#if TEST_GETPROGNAME
+#include <stdlib.h>
+
+int
+main(void)
+{
+	const char * progname;
+
+	progname = getprogname();
+	return progname == NULL;
+}
+#endif /* TEST_GETPROGNAME */
+#if TEST_LIBEVENT
+#include <event.h>
+
+int
+main(void)
+{
+	struct event ev;
+
+	event_set(&ev, 0, EV_READ, NULL, NULL);
+	event_add(&ev, NULL);
+	event_del(&ev);
+	return 0;
+}
+#endif /* TEST_LIBEVENT */
+#if TEST_LIBEVENT2
+#include <event2/event.h>
+#include <event2/event_compat.h>
+#include <event2/event_struct.h>
+#include <event2/buffer.h>
+#include <event2/buffer_compat.h>
+#include <event2/bufferevent.h>
+#include <event2/bufferevent_struct.h>
+#include <event2/bufferevent_compat.h>
+
+int
+main(void)
+{
+	struct event ev;
+
+	event_set(&ev, 0, EV_READ, NULL, NULL);
+	event_add(&ev, NULL);
+	event_del(&ev);
+	return 0;
+}
+#endif /* TEST_LIBEVENT2 */
+#if TEST_LIB_SOCKET
+#include <sys/socket.h>
+
+int
+main(void)
+{
+	int fds[2], c;
+
+	c = socketpair(AF_UNIX, SOCK_STREAM, 0, fds);
+	return c == -1;
+}
+#endif /* TEST_LIB_SOCKET */
+#if TEST_PLEDGE
+#include <unistd.h>
+
+int
+main(void)
+{
+	return !!pledge("stdio", NULL);
+}
+#endif /* TEST_PLEDGE */
+#if TEST_PROGRAM_INVOCATION_SHORT_NAME
+#define _GNU_SOURCE         /* See feature_test_macros(7) */
+#include <errno.h>
+
+int
+main(void)
+{
+
+	return !program_invocation_short_name;
+}
+#endif /* TEST_PROGRAM_INVOCATION_SHORT_NAME */
+#if TEST_PR_SET_NAME
+#include <sys/prctl.h>
+
+int
+main(void)
+{
+	prctl(PR_SET_NAME, "foo");
+	return 0;
+}
+#endif /* TEST_PR_SET_NAME */
+#if TEST_STATIC
+int
+main(void)
+{
+	return 0; /* not meant to do anything */
+}
+#endif /* TEST_STATIC */
+#if TEST_STRLCAT
+#include <string.h>
+
+int
+main(void)
+{
+	char buf[3] = "a";
+	return ! (strlcat(buf, "b", sizeof(buf)) == 2 &&
+	    buf[0] == 'a' && buf[1] == 'b' && buf[2] == '\0');
+}
+#endif /* TEST_STRLCAT */
+#if TEST_STRLCPY
+#include <string.h>
+
+int
+main(void)
+{
+	char buf[2] = "";
+	return ! (strlcpy(buf, "a", sizeof(buf)) == 1 &&
+	    buf[0] == 'a' && buf[1] == '\0');
+}
+#endif /* TEST_STRLCPY */
+#if TEST_STRTONUM
+/*
+ * Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef __NetBSD__
+# define _OPENBSD_SOURCE
+#endif
+#include <stdlib.h>
+
+int
+main(void)
+{
+	const char *errstr;
+
+	if (strtonum("1", 0, 2, &errstr) != 1)
+		return 1;
+	if (errstr != NULL)
+		return 2;
+	if (strtonum("1x", 0, 2, &errstr) != 0)
+		return 3;
+	if (errstr == NULL)
+		return 4;
+	if (strtonum("2", 0, 1, &errstr) != 0)
+		return 5;
+	if (errstr == NULL)
+		return 6;
+	if (strtonum("0", 1, 2, &errstr) != 0)
+		return 7;
+	if (errstr == NULL)
+		return 8;
+	return 0;
+}
+#endif /* TEST_STRTONUM */
+#if TEST_UNVEIL
+#include <unistd.h>
+
+int
+main(void)
+{
+	return -1 != unveil(NULL, NULL);
+}
+#endif /* TEST_UNVEIL */
+#if TEST__MMD
+int
+main(void)
+{
+	return 0;
+}
+#endif /* TEST_NOOP */
+#if TEST___PROGNAME
+int
+main(void)
+{
+	extern char *__progname;
+
+	return !__progname;
+}
+#endif /* TEST___PROGNAME */