aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2023-06-27 17:01:49 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2023-06-27 17:01:49 +0000
commit5894a4142a9d5ae5f7f6bee1f46237a3d20d0b5b (patch)
treebbd14af7062f5ca6ab3eaa60d51fe922daf26e79 /t
parent5d48efff83b6fdae4767f16014f8391a22d31ac9 (diff)
Vendor import of OpenPAM Ximenia.vendor/openpam/XIMENIA
Diffstat (limited to 't')
-rw-r--r--t/Makefile.am4
-rw-r--r--t/Makefile.in87
-rw-r--r--t/t_openpam_ctype.c2
-rw-r--r--t/t_openpam_dispatch.c2
-rw-r--r--t/t_openpam_readlinev.c2
-rw-r--r--t/t_openpam_readword.c2
-rw-r--r--t/t_openpam_straddch.c183
-rw-r--r--t/t_openpam_subst.c105
-rw-r--r--t/t_pam_conv.c2
-rw-r--r--t/t_pam_conv.h2
-rw-r--r--t/t_pam_env.c2
-rw-r--r--t/t_pam_err.c2
-rw-r--r--t/t_pam_err.h2
13 files changed, 360 insertions, 37 deletions
diff --git a/t/Makefile.am b/t/Makefile.am
index 2cd5d21e2246..8fe055f25256 100644
--- a/t/Makefile.am
+++ b/t/Makefile.am
@@ -1,5 +1,3 @@
-# $OpenPAM: Makefile.am 943 2019-02-20 13:23:51Z des $
-
if WITH_TEST
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/libpam \
@@ -14,6 +12,8 @@ TESTS += t_openpam_ctype
TESTS += t_openpam_dispatch
TESTS += t_openpam_readword
TESTS += t_openpam_readlinev
+TESTS += t_openpam_straddch
+TESTS += t_openpam_subst
TESTS += t_pam_env
check_PROGRAMS = $(TESTS)
diff --git a/t/Makefile.in b/t/Makefile.in
index a0c5d4f18da5..005a35e42730 100644
--- a/t/Makefile.in
+++ b/t/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -14,8 +14,6 @@
@SET_MAKE@
-# $OpenPAM: Makefile.am 943 2019-02-20 13:23:51Z des $
-
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
@@ -94,16 +92,18 @@ host_triplet = @host@
@WITH_TEST_TRUE@ t_openpam_dispatch$(EXEEXT) \
@WITH_TEST_TRUE@ t_openpam_readword$(EXEEXT) \
@WITH_TEST_TRUE@ t_openpam_readlinev$(EXEEXT) \
-@WITH_TEST_TRUE@ t_pam_env$(EXEEXT)
+@WITH_TEST_TRUE@ t_openpam_straddch$(EXEEXT) \
+@WITH_TEST_TRUE@ t_openpam_subst$(EXEEXT) t_pam_env$(EXEEXT)
@WITH_TEST_TRUE@check_PROGRAMS = $(am__EXEEXT_1)
@WITH_SYSTEM_LIBPAM_TRUE@@WITH_TEST_TRUE@am__append_1 = $(SYSTEM_LIBPAM)
@WITH_SYSTEM_LIBPAM_FALSE@@WITH_TEST_TRUE@am__append_2 = $(top_builddir)/lib/libpam/libpam.la
subdir = t
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/ax_pkg_config.m4 \
- $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
- $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
- $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compiler_vendor.m4 \
+ $(top_srcdir)/m4/ax_pkg_config.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__noinst_HEADERS_DIST) \
@@ -116,7 +116,8 @@ CONFIG_CLEAN_VPATH_FILES =
@WITH_TEST_TRUE@ t_openpam_dispatch$(EXEEXT) \
@WITH_TEST_TRUE@ t_openpam_readword$(EXEEXT) \
@WITH_TEST_TRUE@ t_openpam_readlinev$(EXEEXT) \
-@WITH_TEST_TRUE@ t_pam_env$(EXEEXT)
+@WITH_TEST_TRUE@ t_openpam_straddch$(EXEEXT) \
+@WITH_TEST_TRUE@ t_openpam_subst$(EXEEXT) t_pam_env$(EXEEXT)
ARFLAGS = cru
AM_V_AR = $(am__v_AR_@AM_V@)
am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
@@ -157,6 +158,17 @@ t_openpam_readword_LDADD = $(LDADD)
@WITH_TEST_TRUE@t_openpam_readword_DEPENDENCIES = \
@WITH_TEST_TRUE@ $(am__DEPENDENCIES_1) libt.a \
@WITH_TEST_TRUE@ $(am__DEPENDENCIES_2) $(am__append_2)
+t_openpam_straddch_SOURCES = t_openpam_straddch.c
+t_openpam_straddch_OBJECTS = t_openpam_straddch.$(OBJEXT)
+t_openpam_straddch_LDADD = $(LDADD)
+@WITH_TEST_TRUE@t_openpam_straddch_DEPENDENCIES = \
+@WITH_TEST_TRUE@ $(am__DEPENDENCIES_1) libt.a \
+@WITH_TEST_TRUE@ $(am__DEPENDENCIES_2) $(am__append_2)
+t_openpam_subst_SOURCES = t_openpam_subst.c
+t_openpam_subst_OBJECTS = t_openpam_subst.$(OBJEXT)
+t_openpam_subst_LDADD = $(LDADD)
+@WITH_TEST_TRUE@t_openpam_subst_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+@WITH_TEST_TRUE@ libt.a $(am__DEPENDENCIES_2) $(am__append_2)
t_pam_env_SOURCES = t_pam_env.c
t_pam_env_OBJECTS = t_pam_env.$(OBJEXT)
t_pam_env_LDADD = $(LDADD)
@@ -180,7 +192,9 @@ am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/t_openpam_ctype.Po \
./$(DEPDIR)/t_openpam_dispatch.Po \
./$(DEPDIR)/t_openpam_readlinev.Po \
- ./$(DEPDIR)/t_openpam_readword.Po ./$(DEPDIR)/t_pam_conv.Po \
+ ./$(DEPDIR)/t_openpam_readword.Po \
+ ./$(DEPDIR)/t_openpam_straddch.Po \
+ ./$(DEPDIR)/t_openpam_subst.Po ./$(DEPDIR)/t_pam_conv.Po \
./$(DEPDIR)/t_pam_env.Po ./$(DEPDIR)/t_pam_err.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
@@ -202,10 +216,12 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libt_a_SOURCES) t_openpam_ctype.c t_openpam_dispatch.c \
- t_openpam_readlinev.c t_openpam_readword.c t_pam_env.c
+ t_openpam_readlinev.c t_openpam_readword.c \
+ t_openpam_straddch.c t_openpam_subst.c t_pam_env.c
DIST_SOURCES = $(am__libt_a_SOURCES_DIST) t_openpam_ctype.c \
t_openpam_dispatch.c t_openpam_readlinev.c \
- t_openpam_readword.c t_pam_env.c
+ t_openpam_readword.c t_openpam_straddch.c t_openpam_subst.c \
+ t_pam_env.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -230,8 +246,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
@@ -414,6 +428,7 @@ am__set_TESTS_bases = \
bases='$(TEST_LOGS)'; \
bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
bases=`echo $$bases`
+AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
RECHECK_LOGS = $(TEST_LOGS)
AM_RECURSIVE_TARGETS = check recheck
TEST_SUITE_LOG = test-suite.log
@@ -455,6 +470,12 @@ CPPFLAGS = @CPPFLAGS@
CRYB_TEST_CFLAGS = @CRYB_TEST_CFLAGS@
CRYB_TEST_LIBS = @CRYB_TEST_LIBS@
CRYB_TEST_VERSION = @CRYB_TEST_VERSION@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
@@ -466,8 +487,10 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
+ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
+FILECMD = @FILECMD@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
@@ -518,6 +541,7 @@ abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
@@ -531,6 +555,7 @@ build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
+clang_ver = @clang_ver@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
@@ -557,6 +582,7 @@ pkgconfigdir = @pkgconfigdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -647,6 +673,14 @@ t_openpam_readword$(EXEEXT): $(t_openpam_readword_OBJECTS) $(t_openpam_readword_
@rm -f t_openpam_readword$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_openpam_readword_OBJECTS) $(t_openpam_readword_LDADD) $(LIBS)
+t_openpam_straddch$(EXEEXT): $(t_openpam_straddch_OBJECTS) $(t_openpam_straddch_DEPENDENCIES) $(EXTRA_t_openpam_straddch_DEPENDENCIES)
+ @rm -f t_openpam_straddch$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(t_openpam_straddch_OBJECTS) $(t_openpam_straddch_LDADD) $(LIBS)
+
+t_openpam_subst$(EXEEXT): $(t_openpam_subst_OBJECTS) $(t_openpam_subst_DEPENDENCIES) $(EXTRA_t_openpam_subst_DEPENDENCIES)
+ @rm -f t_openpam_subst$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(t_openpam_subst_OBJECTS) $(t_openpam_subst_LDADD) $(LIBS)
+
t_pam_env$(EXEEXT): $(t_pam_env_OBJECTS) $(t_pam_env_DEPENDENCIES) $(EXTRA_t_pam_env_DEPENDENCIES)
@rm -f t_pam_env$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_pam_env_OBJECTS) $(t_pam_env_LDADD) $(LIBS)
@@ -661,6 +695,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_openpam_dispatch.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_openpam_readlinev.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_openpam_readword.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_openpam_straddch.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_openpam_subst.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pam_conv.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pam_env.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_pam_err.Po@am__quote@ # am--include-marker
@@ -857,7 +893,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
fi; \
echo "$${col}$$br$${std}"; \
- echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
+ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
echo "$${col}$$br$${std}"; \
create_testsuite_report --maybe-color; \
echo "$$col$$br$$std"; \
@@ -919,6 +955,20 @@ t_openpam_readlinev.log: t_openpam_readlinev$(EXEEXT)
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+t_openpam_straddch.log: t_openpam_straddch$(EXEEXT)
+ @p='t_openpam_straddch$(EXEEXT)'; \
+ b='t_openpam_straddch'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+t_openpam_subst.log: t_openpam_subst$(EXEEXT)
+ @p='t_openpam_subst$(EXEEXT)'; \
+ b='t_openpam_subst'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
t_pam_env.log: t_pam_env$(EXEEXT)
@p='t_pam_env$(EXEEXT)'; \
b='t_pam_env'; \
@@ -940,7 +990,6 @@ t_pam_env.log: t_pam_env$(EXEEXT)
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
-
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
@@ -1023,6 +1072,8 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/t_openpam_dispatch.Po
-rm -f ./$(DEPDIR)/t_openpam_readlinev.Po
-rm -f ./$(DEPDIR)/t_openpam_readword.Po
+ -rm -f ./$(DEPDIR)/t_openpam_straddch.Po
+ -rm -f ./$(DEPDIR)/t_openpam_subst.Po
-rm -f ./$(DEPDIR)/t_pam_conv.Po
-rm -f ./$(DEPDIR)/t_pam_env.Po
-rm -f ./$(DEPDIR)/t_pam_err.Po
@@ -1075,6 +1126,8 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/t_openpam_dispatch.Po
-rm -f ./$(DEPDIR)/t_openpam_readlinev.Po
-rm -f ./$(DEPDIR)/t_openpam_readword.Po
+ -rm -f ./$(DEPDIR)/t_openpam_straddch.Po
+ -rm -f ./$(DEPDIR)/t_openpam_subst.Po
-rm -f ./$(DEPDIR)/t_pam_conv.Po
-rm -f ./$(DEPDIR)/t_pam_env.Po
-rm -f ./$(DEPDIR)/t_pam_err.Po
diff --git a/t/t_openpam_ctype.c b/t/t_openpam_ctype.c
index ec7e807d0e60..b07d52ca5d08 100644
--- a/t/t_openpam_ctype.c
+++ b/t/t_openpam_ctype.c
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM: t_openpam_ctype.c 938 2017-04-30 21:34:42Z des $
*/
#ifdef HAVE_CONFIG_H
diff --git a/t/t_openpam_dispatch.c b/t/t_openpam_dispatch.c
index f2f3053a726c..bc8c19a56504 100644
--- a/t/t_openpam_dispatch.c
+++ b/t/t_openpam_dispatch.c
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM: t_openpam_dispatch.c 938 2017-04-30 21:34:42Z des $
*/
#ifdef HAVE_CONFIG_H
diff --git a/t/t_openpam_readlinev.c b/t/t_openpam_readlinev.c
index e32f33879453..84e5eec78daf 100644
--- a/t/t_openpam_readlinev.c
+++ b/t/t_openpam_readlinev.c
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM: t_openpam_readlinev.c 938 2017-04-30 21:34:42Z des $
*/
#ifdef HAVE_CONFIG_H
diff --git a/t/t_openpam_readword.c b/t/t_openpam_readword.c
index e7e9871f45ca..635c27969bea 100644
--- a/t/t_openpam_readword.c
+++ b/t/t_openpam_readword.c
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM: t_openpam_readword.c 938 2017-04-30 21:34:42Z des $
*/
#ifdef HAVE_CONFIG_H
diff --git a/t/t_openpam_straddch.c b/t/t_openpam_straddch.c
new file mode 100644
index 000000000000..55fbbb054338
--- /dev/null
+++ b/t/t_openpam_straddch.c
@@ -0,0 +1,183 @@
+/*-
+ * Copyright (c) 2021 Dag-Erling Smørgrav
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include <cryb/test.h>
+
+#include <security/pam_appl.h>
+#include "openpam_impl.h"
+
+static int
+t_straddch_empty(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED)
+{
+ char *str;
+ size_t size, len;
+ int ret;
+
+ str = NULL;
+ size = len = SIZE_MAX;
+ ret = t_is_zero_i(openpam_straddch(&str, &size, &len, '\0'));
+ ret &= t_is_not_null(str);
+ ret &= t_is_not_zero_sz(size);
+ ret &= t_is_zero_sz(len);
+ free(str);
+ return ret;
+}
+
+static int
+t_straddch_alloc_fail(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED)
+{
+ char *str;
+ size_t size, len;
+ int ret;
+
+ str = NULL;
+ size = len = SIZE_MAX;
+ errno = 0;
+ t_malloc_fail = 1;
+ ret = t_compare_i(-1, openpam_straddch(&str, &size, &len, '\0'));
+ t_malloc_fail = 0;
+ ret &= t_compare_i(ENOMEM, errno);
+ ret &= t_is_null(str);
+ ret &= t_compare_sz(SIZE_MAX, size);
+ ret &= t_compare_sz(SIZE_MAX, len);
+ free(str);
+ return ret;
+}
+
+static int
+t_straddch_realloc_fail(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED)
+{
+ char *str, *_str;
+ size_t size, _size, len, _len;
+ int i, ret;
+
+ // start with an empty string
+ str = NULL;
+ size = len = SIZE_MAX;
+ ret = t_is_zero_i(openpam_straddch(&str, &size, &len, '\0'));
+ ret &= t_is_not_null(str);
+ ret &= t_is_not_zero_sz(size);
+ ret &= t_is_zero_sz(len);
+ if (!ret)
+ goto end;
+ // repeatedly append to it until allocation fails
+ errno = 0;
+ _str = str;
+ _size = size;
+ _len = len;
+ t_malloc_fail = 1;
+ for (i = 0; i < 4096; i++) {
+ if ((ret = openpam_straddch(&str, &size, &len, 'x')) != 0)
+ break;
+ _size = size;
+ _len = len;
+ }
+ t_malloc_fail = 0;
+ ret = t_compare_i(-1, ret);
+ ret &= t_compare_i(ENOMEM, errno);
+ ret &= t_compare_ptr(_str, str);
+ ret &= t_compare_sz(_size, size);
+ ret &= t_compare_sz(_len, len);
+end:
+ free(str);
+ return ret;
+}
+
+static int
+t_straddch_realloc_ok(char **desc CRYB_UNUSED, void *arg CRYB_UNUSED)
+{
+ char *str;
+ size_t size, _size, len, _len;
+ int i, ret;
+
+ // start with an empty string
+ str = NULL;
+ size = len = SIZE_MAX;
+ ret = t_is_zero_i(openpam_straddch(&str, &size, &len, '\0'));
+ ret &= t_is_not_null(str);
+ ret &= t_is_not_zero_sz(size);
+ ret &= t_is_zero_sz(len);
+ if (!ret)
+ goto end;
+ // repeatedly append to it until size changes
+ _size = size;
+ _len = len;
+ for (i = ' '; i <= '~'; i++) { // assume ascii
+ if ((ret = openpam_straddch(&str, &size, &len, i)) != 0)
+ break;
+ if (size != _size)
+ break;
+ if (len != _len + 1)
+ break;
+ _len = len;
+ }
+ ret = t_is_zero_i(ret);
+ if (!ret)
+ goto end;
+ ret &= t_compare_sz(_len + 1, len);
+ ret &= t_compare_sz(_size * 2, size);
+ ret &= t_compare_i(i, str[_len]);
+ ret &= t_is_zero_i(str[len]);
+end:
+ free(str);
+ return ret;
+}
+
+
+/***************************************************************************
+ * Boilerplate
+ */
+
+static int
+t_prepare(int argc CRYB_UNUSED, char *argv[] CRYB_UNUSED)
+{
+
+ t_add_test(t_straddch_empty, NULL, "empty string");
+ t_add_test(t_straddch_alloc_fail, NULL, "allocation failure");
+ t_add_test(t_straddch_realloc_fail, NULL, "reallocation failure");
+ t_add_test(t_straddch_realloc_ok, NULL, "reallocation success");
+ return (0);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ t_main(t_prepare, NULL, argc, argv);
+}
diff --git a/t/t_openpam_subst.c b/t/t_openpam_subst.c
new file mode 100644
index 000000000000..b4fb6c30067f
--- /dev/null
+++ b/t/t_openpam_subst.c
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2023 Dag-Erling Smørgrav
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <err.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <cryb/test.h>
+
+#include <security/pam_appl.h>
+#include <security/openpam.h>
+
+#include "openpam_impl.h"
+
+#define T_FUNC(n, d) \
+ static const char *t_ ## n ## _desc = d; \
+ static int t_ ## n ## _func(OPENPAM_UNUSED(char **desc), \
+ OPENPAM_UNUSED(void *arg))
+
+#define T(n) \
+ t_add_test(&t_ ## n ## _func, NULL, "%s", t_ ## n ## _desc)
+
+const char *pam_return_so;
+
+T_FUNC(final_percent, "template ends with %")
+{
+ char template[] = "test%\0deadbeef";
+ char buf[] = "Squeamish Ossifrage";
+ size_t bufsize = sizeof(buf);
+ int pam_err, ret;
+
+ pam_err = openpam_subst(NULL, buf, &bufsize, template);
+ ret = (pam_err == PAM_SUCCESS);
+ ret &= t_compare_sz(sizeof("test%"), bufsize);
+ ret &= t_compare_str("test%", buf);
+ return (ret);
+}
+
+
+/***************************************************************************
+ * Boilerplate
+ */
+
+static int
+t_prepare(int argc, char *argv[])
+{
+
+ (void)argc;
+ (void)argv;
+
+ if ((pam_return_so = getenv("PAM_RETURN_SO")) == NULL) {
+ t_printv("define PAM_RETURN_SO before running these tests\n");
+ return (0);
+ }
+
+ openpam_set_feature(OPENPAM_RESTRICT_MODULE_NAME, 0);
+ openpam_set_feature(OPENPAM_VERIFY_MODULE_FILE, 0);
+ openpam_set_feature(OPENPAM_RESTRICT_SERVICE_NAME, 0);
+ openpam_set_feature(OPENPAM_VERIFY_POLICY_FILE, 0);
+ openpam_set_feature(OPENPAM_FALLBACK_TO_OTHER, 0);
+
+ T(final_percent);
+
+ return (0);
+}
+
+int
+main(int argc, char *argv[])
+{
+
+ t_main(t_prepare, NULL, argc, argv);
+}
diff --git a/t/t_pam_conv.c b/t/t_pam_conv.c
index 243d96df3f76..3f7620fb13de 100644
--- a/t/t_pam_conv.c
+++ b/t/t_pam_conv.c
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM: t_pam_conv.c 938 2017-04-30 21:34:42Z des $
*/
#ifdef HAVE_CONFIG_H
diff --git a/t/t_pam_conv.h b/t/t_pam_conv.h
index 07ba702c940a..f9977be2d3f1 100644
--- a/t/t_pam_conv.h
+++ b/t/t_pam_conv.h
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM: t_pam_conv.h 938 2017-04-30 21:34:42Z des $
*/
#ifndef T_PAM_CONV_H_INCLUDED
diff --git a/t/t_pam_env.c b/t/t_pam_env.c
index 3f0174592c58..3e4a11a414ef 100644
--- a/t/t_pam_env.c
+++ b/t/t_pam_env.c
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM$
*/
#ifdef HAVE_CONFIG_H
diff --git a/t/t_pam_err.c b/t/t_pam_err.c
index 8c97a129dcb7..a705826bb6b2 100644
--- a/t/t_pam_err.c
+++ b/t/t_pam_err.c
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM$
*/
#ifdef HAVE_CONFIG_H
diff --git a/t/t_pam_err.h b/t/t_pam_err.h
index 612bb7580197..e4f00734cf59 100644
--- a/t/t_pam_err.h
+++ b/t/t_pam_err.h
@@ -25,8 +25,6 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $OpenPAM$
*/
#ifndef T_PAM_ERR_H_INCLUDED