summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am19
-rw-r--r--tests/Makefile.in708
-rw-r--r--tests/tst-dlopen.c48
-rw-r--r--tests/tst-pam_acct_mgmt.c58
-rw-r--r--tests/tst-pam_authenticate.c58
-rw-r--r--tests/tst-pam_chauthtok.c58
-rw-r--r--tests/tst-pam_close_session.c58
-rw-r--r--tests/tst-pam_end.c79
-rw-r--r--tests/tst-pam_fail_delay.c79
-rw-r--r--tests/tst-pam_get_item.c133
-rw-r--r--tests/tst-pam_get_user.c176
-rw-r--r--tests/tst-pam_getenvlist.c134
-rw-r--r--tests/tst-pam_open_session.c58
-rw-r--r--tests/tst-pam_set_data.c488
-rw-r--r--tests/tst-pam_set_item.c149
-rw-r--r--tests/tst-pam_setcred.c58
-rw-r--r--tests/tst-pam_start.c107
17 files changed, 2468 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644
index 00000000..de1594bd
--- /dev/null
+++ b/tests/Makefile.am
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2006 Thorsten Kukuk <kukuk@suse.de>
+#
+
+AM_CFLAGS = -DLIBPAM_COMPILE -I$(top_srcdir)/libpam/include \
+ -I$(top_srcdir)/libpam
+LDADD = -L$(top_builddir)/libpam -lpam
+
+CLEANFILES = *~
+
+TESTS = tst-pam_start tst-pam_end tst-pam_fail_delay tst-pam_open_session \
+ tst-pam_close_session tst-pam_acct_mgmt tst-pam_authenticate \
+ tst-pam_chauthtok tst-pam_setcred tst-pam_get_item tst-pam_set_item \
+ tst-pam_getenvlist tst-pam_get_user tst-pam_set_data
+
+check_PROGRAMS = ${TESTS} tst-dlopen
+
+tst_dlopen_LDADD = -ldl
+
diff --git a/tests/Makefile.in b/tests/Makefile.in
new file mode 100644
index 00000000..c6c56c49
--- /dev/null
+++ b/tests/Makefile.in
@@ -0,0 +1,708 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+#
+# Copyright (c) 2006 Thorsten Kukuk <kukuk@suse.de>
+#
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+TESTS = tst-pam_start$(EXEEXT) tst-pam_end$(EXEEXT) \
+ tst-pam_fail_delay$(EXEEXT) tst-pam_open_session$(EXEEXT) \
+ tst-pam_close_session$(EXEEXT) tst-pam_acct_mgmt$(EXEEXT) \
+ tst-pam_authenticate$(EXEEXT) tst-pam_chauthtok$(EXEEXT) \
+ tst-pam_setcred$(EXEEXT) tst-pam_get_item$(EXEEXT) \
+ tst-pam_set_item$(EXEEXT) tst-pam_getenvlist$(EXEEXT) \
+ tst-pam_get_user$(EXEEXT) tst-pam_set_data$(EXEEXT)
+check_PROGRAMS = $(am__EXEEXT_1) tst-dlopen$(EXEEXT)
+subdir = tests
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
+ $(top_srcdir)/m4/iconv.m4 \
+ $(top_srcdir)/m4/jh_path_xml_catalog.m4 \
+ $(top_srcdir)/m4/ld-O1.m4 $(top_srcdir)/m4/ld-as-needed.m4 \
+ $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
+ $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libprelude.m4 \
+ $(top_srcdir)/m4/nls.m4 $(top_srcdir)/m4/po.m4 \
+ $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__EXEEXT_1 = tst-pam_start$(EXEEXT) tst-pam_end$(EXEEXT) \
+ tst-pam_fail_delay$(EXEEXT) tst-pam_open_session$(EXEEXT) \
+ tst-pam_close_session$(EXEEXT) tst-pam_acct_mgmt$(EXEEXT) \
+ tst-pam_authenticate$(EXEEXT) tst-pam_chauthtok$(EXEEXT) \
+ tst-pam_setcred$(EXEEXT) tst-pam_get_item$(EXEEXT) \
+ tst-pam_set_item$(EXEEXT) tst-pam_getenvlist$(EXEEXT) \
+ tst-pam_get_user$(EXEEXT) tst-pam_set_data$(EXEEXT)
+tst_dlopen_SOURCES = tst-dlopen.c
+tst_dlopen_OBJECTS = tst-dlopen.$(OBJEXT)
+tst_dlopen_DEPENDENCIES =
+tst_pam_acct_mgmt_SOURCES = tst-pam_acct_mgmt.c
+tst_pam_acct_mgmt_OBJECTS = tst-pam_acct_mgmt.$(OBJEXT)
+tst_pam_acct_mgmt_LDADD = $(LDADD)
+tst_pam_acct_mgmt_DEPENDENCIES =
+tst_pam_authenticate_SOURCES = tst-pam_authenticate.c
+tst_pam_authenticate_OBJECTS = tst-pam_authenticate.$(OBJEXT)
+tst_pam_authenticate_LDADD = $(LDADD)
+tst_pam_authenticate_DEPENDENCIES =
+tst_pam_chauthtok_SOURCES = tst-pam_chauthtok.c
+tst_pam_chauthtok_OBJECTS = tst-pam_chauthtok.$(OBJEXT)
+tst_pam_chauthtok_LDADD = $(LDADD)
+tst_pam_chauthtok_DEPENDENCIES =
+tst_pam_close_session_SOURCES = tst-pam_close_session.c
+tst_pam_close_session_OBJECTS = tst-pam_close_session.$(OBJEXT)
+tst_pam_close_session_LDADD = $(LDADD)
+tst_pam_close_session_DEPENDENCIES =
+tst_pam_end_SOURCES = tst-pam_end.c
+tst_pam_end_OBJECTS = tst-pam_end.$(OBJEXT)
+tst_pam_end_LDADD = $(LDADD)
+tst_pam_end_DEPENDENCIES =
+tst_pam_fail_delay_SOURCES = tst-pam_fail_delay.c
+tst_pam_fail_delay_OBJECTS = tst-pam_fail_delay.$(OBJEXT)
+tst_pam_fail_delay_LDADD = $(LDADD)
+tst_pam_fail_delay_DEPENDENCIES =
+tst_pam_get_item_SOURCES = tst-pam_get_item.c
+tst_pam_get_item_OBJECTS = tst-pam_get_item.$(OBJEXT)
+tst_pam_get_item_LDADD = $(LDADD)
+tst_pam_get_item_DEPENDENCIES =
+tst_pam_get_user_SOURCES = tst-pam_get_user.c
+tst_pam_get_user_OBJECTS = tst-pam_get_user.$(OBJEXT)
+tst_pam_get_user_LDADD = $(LDADD)
+tst_pam_get_user_DEPENDENCIES =
+tst_pam_getenvlist_SOURCES = tst-pam_getenvlist.c
+tst_pam_getenvlist_OBJECTS = tst-pam_getenvlist.$(OBJEXT)
+tst_pam_getenvlist_LDADD = $(LDADD)
+tst_pam_getenvlist_DEPENDENCIES =
+tst_pam_open_session_SOURCES = tst-pam_open_session.c
+tst_pam_open_session_OBJECTS = tst-pam_open_session.$(OBJEXT)
+tst_pam_open_session_LDADD = $(LDADD)
+tst_pam_open_session_DEPENDENCIES =
+tst_pam_set_data_SOURCES = tst-pam_set_data.c
+tst_pam_set_data_OBJECTS = tst-pam_set_data.$(OBJEXT)
+tst_pam_set_data_LDADD = $(LDADD)
+tst_pam_set_data_DEPENDENCIES =
+tst_pam_set_item_SOURCES = tst-pam_set_item.c
+tst_pam_set_item_OBJECTS = tst-pam_set_item.$(OBJEXT)
+tst_pam_set_item_LDADD = $(LDADD)
+tst_pam_set_item_DEPENDENCIES =
+tst_pam_setcred_SOURCES = tst-pam_setcred.c
+tst_pam_setcred_OBJECTS = tst-pam_setcred.$(OBJEXT)
+tst_pam_setcred_LDADD = $(LDADD)
+tst_pam_setcred_DEPENDENCIES =
+tst_pam_start_SOURCES = tst-pam_start.c
+tst_pam_start_OBJECTS = tst-pam_start.$(OBJEXT)
+tst_pam_start_LDADD = $(LDADD)
+tst_pam_start_DEPENDENCIES =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = tst-dlopen.c tst-pam_acct_mgmt.c tst-pam_authenticate.c \
+ tst-pam_chauthtok.c tst-pam_close_session.c tst-pam_end.c \
+ tst-pam_fail_delay.c tst-pam_get_item.c tst-pam_get_user.c \
+ tst-pam_getenvlist.c tst-pam_open_session.c tst-pam_set_data.c \
+ tst-pam_set_item.c tst-pam_setcred.c tst-pam_start.c
+DIST_SOURCES = tst-dlopen.c tst-pam_acct_mgmt.c tst-pam_authenticate.c \
+ tst-pam_chauthtok.c tst-pam_close_session.c tst-pam_end.c \
+ tst-pam_fail_delay.c tst-pam_get_item.c tst-pam_get_user.c \
+ tst-pam_getenvlist.c tst-pam_open_session.c tst-pam_set_data.c \
+ tst-pam_set_item.c tst-pam_setcred.c tst-pam_start.c
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BROWSER = @BROWSER@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FO2PDF = @FO2PDF@
+GMSGFMT = @GMSGFMT@
+GMSGFMT_015 = @GMSGFMT_015@
+GREP = @GREP@
+HAVE_KEY_MANAGEMENT = @HAVE_KEY_MANAGEMENT@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+INTLLIBS = @INTLLIBS@
+INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBAUDIT = @LIBAUDIT@
+LIBCRACK = @LIBCRACK@
+LIBCRYPT = @LIBCRYPT@
+LIBDB = @LIBDB@
+LIBDL = @LIBDL@
+LIBICONV = @LIBICONV@
+LIBINTL = @LIBINTL@
+LIBNSL = @LIBNSL@
+LIBOBJS = @LIBOBJS@
+LIBPRELUDE_CFLAGS = @LIBPRELUDE_CFLAGS@
+LIBPRELUDE_CONFIG = @LIBPRELUDE_CONFIG@
+LIBPRELUDE_CONFIG_PREFIX = @LIBPRELUDE_CONFIG_PREFIX@
+LIBPRELUDE_LDFLAGS = @LIBPRELUDE_LDFLAGS@
+LIBPRELUDE_LIBS = @LIBPRELUDE_LIBS@
+LIBPRELUDE_PREFIX = @LIBPRELUDE_PREFIX@
+LIBPRELUDE_PTHREAD_CFLAGS = @LIBPRELUDE_PTHREAD_CFLAGS@
+LIBS = @LIBS@
+LIBSELINUX = @LIBSELINUX@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBICONV = @LTLIBICONV@
+LTLIBINTL = @LTLIBINTL@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MSGFMT = @MSGFMT@
+MSGFMT_015 = @MSGFMT_015@
+MSGMERGE = @MSGMERGE@
+NMEDIT = @NMEDIT@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PAM_READ_BOTH_CONFS = @PAM_READ_BOTH_CONFS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PIE_CFLAGS = @PIE_CFLAGS@
+PIE_LDFLAGS = @PIE_LDFLAGS@
+POSUB = @POSUB@
+RANLIB = @RANLIB@
+SCONFIGDIR = @SCONFIGDIR@
+SECUREDIR = @SECUREDIR@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+USE_NLS = @USE_NLS@
+VERSION = @VERSION@
+WITH_DEBUG = @WITH_DEBUG@
+WITH_PAMLOCKING = @WITH_PAMLOCKING@
+XGETTEXT = @XGETTEXT@
+XGETTEXT_015 = @XGETTEXT_015@
+XMLCATALOG = @XMLCATALOG@
+XMLLINT = @XMLLINT@
+XML_CATALOG_FILE = @XML_CATALOG_FILE@
+XSLTPROC = @XSLTPROC@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libc_cv_fpie = @libc_cv_fpie@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pam_cv_ld_as_needed = @pam_cv_ld_as_needed@
+pam_xauth_path = @pam_xauth_path@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CFLAGS = -DLIBPAM_COMPILE -I$(top_srcdir)/libpam/include \
+ -I$(top_srcdir)/libpam
+
+LDADD = -L$(top_builddir)/libpam -lpam
+CLEANFILES = *~
+tst_dlopen_LDADD = -ldl
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu tests/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+tst-dlopen$(EXEEXT): $(tst_dlopen_OBJECTS) $(tst_dlopen_DEPENDENCIES)
+ @rm -f tst-dlopen$(EXEEXT)
+ $(LINK) $(tst_dlopen_OBJECTS) $(tst_dlopen_LDADD) $(LIBS)
+tst-pam_acct_mgmt$(EXEEXT): $(tst_pam_acct_mgmt_OBJECTS) $(tst_pam_acct_mgmt_DEPENDENCIES)
+ @rm -f tst-pam_acct_mgmt$(EXEEXT)
+ $(LINK) $(tst_pam_acct_mgmt_OBJECTS) $(tst_pam_acct_mgmt_LDADD) $(LIBS)
+tst-pam_authenticate$(EXEEXT): $(tst_pam_authenticate_OBJECTS) $(tst_pam_authenticate_DEPENDENCIES)
+ @rm -f tst-pam_authenticate$(EXEEXT)
+ $(LINK) $(tst_pam_authenticate_OBJECTS) $(tst_pam_authenticate_LDADD) $(LIBS)
+tst-pam_chauthtok$(EXEEXT): $(tst_pam_chauthtok_OBJECTS) $(tst_pam_chauthtok_DEPENDENCIES)
+ @rm -f tst-pam_chauthtok$(EXEEXT)
+ $(LINK) $(tst_pam_chauthtok_OBJECTS) $(tst_pam_chauthtok_LDADD) $(LIBS)
+tst-pam_close_session$(EXEEXT): $(tst_pam_close_session_OBJECTS) $(tst_pam_close_session_DEPENDENCIES)
+ @rm -f tst-pam_close_session$(EXEEXT)
+ $(LINK) $(tst_pam_close_session_OBJECTS) $(tst_pam_close_session_LDADD) $(LIBS)
+tst-pam_end$(EXEEXT): $(tst_pam_end_OBJECTS) $(tst_pam_end_DEPENDENCIES)
+ @rm -f tst-pam_end$(EXEEXT)
+ $(LINK) $(tst_pam_end_OBJECTS) $(tst_pam_end_LDADD) $(LIBS)
+tst-pam_fail_delay$(EXEEXT): $(tst_pam_fail_delay_OBJECTS) $(tst_pam_fail_delay_DEPENDENCIES)
+ @rm -f tst-pam_fail_delay$(EXEEXT)
+ $(LINK) $(tst_pam_fail_delay_OBJECTS) $(tst_pam_fail_delay_LDADD) $(LIBS)
+tst-pam_get_item$(EXEEXT): $(tst_pam_get_item_OBJECTS) $(tst_pam_get_item_DEPENDENCIES)
+ @rm -f tst-pam_get_item$(EXEEXT)
+ $(LINK) $(tst_pam_get_item_OBJECTS) $(tst_pam_get_item_LDADD) $(LIBS)
+tst-pam_get_user$(EXEEXT): $(tst_pam_get_user_OBJECTS) $(tst_pam_get_user_DEPENDENCIES)
+ @rm -f tst-pam_get_user$(EXEEXT)
+ $(LINK) $(tst_pam_get_user_OBJECTS) $(tst_pam_get_user_LDADD) $(LIBS)
+tst-pam_getenvlist$(EXEEXT): $(tst_pam_getenvlist_OBJECTS) $(tst_pam_getenvlist_DEPENDENCIES)
+ @rm -f tst-pam_getenvlist$(EXEEXT)
+ $(LINK) $(tst_pam_getenvlist_OBJECTS) $(tst_pam_getenvlist_LDADD) $(LIBS)
+tst-pam_open_session$(EXEEXT): $(tst_pam_open_session_OBJECTS) $(tst_pam_open_session_DEPENDENCIES)
+ @rm -f tst-pam_open_session$(EXEEXT)
+ $(LINK) $(tst_pam_open_session_OBJECTS) $(tst_pam_open_session_LDADD) $(LIBS)
+tst-pam_set_data$(EXEEXT): $(tst_pam_set_data_OBJECTS) $(tst_pam_set_data_DEPENDENCIES)
+ @rm -f tst-pam_set_data$(EXEEXT)
+ $(LINK) $(tst_pam_set_data_OBJECTS) $(tst_pam_set_data_LDADD) $(LIBS)
+tst-pam_set_item$(EXEEXT): $(tst_pam_set_item_OBJECTS) $(tst_pam_set_item_DEPENDENCIES)
+ @rm -f tst-pam_set_item$(EXEEXT)
+ $(LINK) $(tst_pam_set_item_OBJECTS) $(tst_pam_set_item_LDADD) $(LIBS)
+tst-pam_setcred$(EXEEXT): $(tst_pam_setcred_OBJECTS) $(tst_pam_setcred_DEPENDENCIES)
+ @rm -f tst-pam_setcred$(EXEEXT)
+ $(LINK) $(tst_pam_setcred_OBJECTS) $(tst_pam_setcred_LDADD) $(LIBS)
+tst-pam_start$(EXEEXT): $(tst_pam_start_OBJECTS) $(tst_pam_start_DEPENDENCIES)
+ @rm -f tst-pam_start$(EXEEXT)
+ $(LINK) $(tst_pam_start_OBJECTS) $(tst_pam_start_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-dlopen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_acct_mgmt.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_authenticate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_chauthtok.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_close_session.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_end.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_fail_delay.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_get_item.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_get_user.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_getenvlist.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_open_session.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_set_data.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_set_item.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_setcred.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tst-pam_start.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *$$ws$$tst$$ws*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ echo "XPASS: $$tst"; \
+ ;; \
+ *) \
+ echo "PASS: $$tst"; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *$$ws$$tst$$ws*) \
+ xfail=`expr $$xfail + 1`; \
+ echo "XFAIL: $$tst"; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ echo "FAIL: $$tst"; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ echo "SKIP: $$tst"; \
+ fi; \
+ done; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="All $$all tests passed"; \
+ else \
+ banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all tests failed"; \
+ else \
+ banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ skipped="($$skip tests were not run)"; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ echo "$$dashes"; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-checkPROGRAMS clean-generic clean-libtool ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/tst-dlopen.c b/tests/tst-dlopen.c
new file mode 100644
index 00000000..e4770eea
--- /dev/null
+++ b/tests/tst-dlopen.c
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) Nalin Dahyabhai <nalin@redhat.com> 2003
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <limits.h>
+#include <sys/stat.h>
+
+/* Simple program to see if dlopen() would succeed. */
+int main(int argc, char **argv)
+{
+#ifdef PAM_STATIC
+ return 77;
+#else
+ int i;
+ struct stat st;
+ char buf[PATH_MAX];
+
+ for (i = 1; i < argc; i++) {
+ if (dlopen(argv[i], RTLD_NOW)) {
+ fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
+ argv[i]);
+ } else {
+ snprintf(buf, sizeof(buf), "./%s", argv[i]);
+ if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
+ fprintf(stdout, "dlopen() of \"./%s\" "
+ "succeeded.\n", argv[i]);
+ } else {
+ fprintf(stdout, "dlopen() of \"%s\" failed: "
+ "%s\n", argv[i], dlerror());
+ return 1;
+ }
+ }
+ }
+ return 0;
+#endif
+}
+
diff --git a/tests/tst-pam_acct_mgmt.c b/tests/tst-pam_acct_mgmt.c
new file mode 100644
index 00000000..1e8c4b4d
--- /dev/null
+++ b/tests/tst-pam_acct_mgmt.c
@@ -0,0 +1,58 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ int retval;
+
+ /* 1: Call with NULL as pam handle */
+ retval = pam_acct_mgmt (NULL, 0);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_acct_mgmt (NULL, 0) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_authenticate.c b/tests/tst-pam_authenticate.c
new file mode 100644
index 00000000..1d43ec3a
--- /dev/null
+++ b/tests/tst-pam_authenticate.c
@@ -0,0 +1,58 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ int retval;
+
+ /* 1: Call with NULL as pam handle */
+ retval = pam_authenticate (NULL, 0);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "tst-pam_authenticate (NULL, 0) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_chauthtok.c b/tests/tst-pam_chauthtok.c
new file mode 100644
index 00000000..37ed83d3
--- /dev/null
+++ b/tests/tst-pam_chauthtok.c
@@ -0,0 +1,58 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ int retval;
+
+ /* 1: Call with NULL as pam handle */
+ retval = pam_chauthtok (NULL, 0);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "tst-pam_chauthtok (NULL, 0) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_close_session.c b/tests/tst-pam_close_session.c
new file mode 100644
index 00000000..86187bb9
--- /dev/null
+++ b/tests/tst-pam_close_session.c
@@ -0,0 +1,58 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ int retval;
+
+ /* 1: Call with NULL as pam handle */
+ retval = pam_close_session (NULL, 0);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_close_session (NULL, 0) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_end.c b/tests/tst-pam_end.c
new file mode 100644
index 00000000..93c2fc32
--- /dev/null
+++ b/tests/tst-pam_end.c
@@ -0,0 +1,79 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ const char *service = "dummy";
+ const char *user = "root";
+ struct pam_conv conv;
+ pam_handle_t *pamh;
+ int retval;
+
+ /* 1: close valid pam handle */
+ /* create valid pam handle */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ retval = pam_end (pamh, 0);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_end (pamh, 0) returned %d\n", retval);
+ return 1;
+ }
+
+ /* 2: close NULL pam handle */
+ retval = pam_end (NULL, 0);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_end (NULL, 0) returned %d\n", retval);
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_fail_delay.c b/tests/tst-pam_fail_delay.c
new file mode 100644
index 00000000..c4323178
--- /dev/null
+++ b/tests/tst-pam_fail_delay.c
@@ -0,0 +1,79 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ const char *service = "dummy";
+ const char *user = "root";
+ struct pam_conv conv;
+ pam_handle_t *pamh;
+ int retval;
+
+ /* 1: set valid delay */
+ /* create valid pam handle */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ retval = pam_fail_delay (pamh, 60);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_fail_delay (pamh, 60) returned %d\n", retval);
+ return 1;
+ }
+
+ /* 2: use NULL pam handle */
+ retval = pam_fail_delay (NULL, 60);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_fail_delay (NULL, 60) returned %d\n", retval);
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_get_item.c b/tests/tst-pam_get_item.c
new file mode 100644
index 00000000..d88b8b29
--- /dev/null
+++ b/tests/tst-pam_get_item.c
@@ -0,0 +1,133 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+struct mapping {
+ int type;
+ const char *string;
+ int expected;
+};
+
+struct mapping items[] = {
+ {PAM_SERVICE, "PAM_SERVICE", PAM_SUCCESS},
+ {PAM_USER, "PAM_USER", 0},
+ {PAM_TTY, "PAM_TTY", 0},
+ {PAM_RHOST, "PAM_RHOST", 0},
+ {PAM_CONV, "PAM_CONV", 0},
+ {PAM_AUTHTOK, "PAM_AUTHTOK", PAM_BAD_ITEM},
+ {PAM_OLDAUTHTOK, "PAM_OLDAUTHTOK", PAM_BAD_ITEM},
+ {PAM_RUSER, "PAM_RUSER", 0},
+ {PAM_USER_PROMPT, "PAM_USER_PROMPT", 0},
+ {PAM_FAIL_DELAY, "PAM_FAIL_DELAY", 0}
+};
+
+int
+main (void)
+{
+ const char *service = "dummy";
+ const char *user = "root";
+ struct pam_conv conv;
+ pam_handle_t *pamh;
+ int retval, num, i;
+ const void *value;
+
+ /* 1: Call with NULL as pam handle */
+ retval = pam_get_item (NULL, PAM_SERVICE, &value);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_get_item (NULL, 0) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ /* setup pam handle */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ /* 2: check for valid item types. Expected return value is
+ PAM_SUCCESS, except it has to fail. */
+ num = sizeof(items) / sizeof(struct mapping);
+
+ for (i = 0; i < num; i++)
+ {
+ retval = pam_get_item (pamh, items[i].type, &value);
+
+ if (retval != items[i].expected)
+ {
+ fprintf (stderr,
+ "pam_get_item failed to get value for %s. Returned %d\n",
+ items[i].string, retval);
+ return 1;
+ }
+ }
+
+ /* 3: check for bad item */
+ retval = pam_get_item (pamh, -1, &value);
+ if (retval != PAM_BAD_ITEM)
+ {
+ fprintf (stderr,
+ "pam_get_item returned %d when expecting PAM_BAD_ITEM\n",
+ retval);
+ return 1;
+ }
+
+ /* 4: check for valid item types, but NULL as value address. */
+ for (i = 0; i < num; i++)
+ {
+ retval = pam_get_item (pamh, items[i].type, NULL);
+
+ if (retval != PAM_PERM_DENIED)
+ {
+ fprintf (stderr,
+ "pam_get_item returned %d to get value for %s\n",
+ retval, items[i].string);
+ return 1;
+ }
+ }
+
+ pam_end (pamh, 0);
+
+ return 0;
+}
diff --git a/tests/tst-pam_get_user.c b/tests/tst-pam_get_user.c
new file mode 100644
index 00000000..16f31236
--- /dev/null
+++ b/tests/tst-pam_get_user.c
@@ -0,0 +1,176 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <config.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <security/pam_appl.h>
+#include <security/pam_modules.h>
+
+static const char *prompt = "myprompt:";
+static const char *user = "itsme";
+
+static int
+login_conv (int num_msg, const struct pam_message **mesg,
+ struct pam_response **resp, void *appdata_ptr UNUSED)
+{
+ struct pam_response *reply;
+ int count;
+
+ reply = calloc(num_msg, sizeof (struct pam_response));
+
+ if (reply == NULL)
+ return PAM_BUF_ERR;
+
+ for (count = 0; count < num_msg; count++)
+ {
+ reply[count].resp_retcode = 0;
+ reply[count].resp = NULL;
+
+ switch (mesg[count]->msg_style)
+ {
+ case PAM_PROMPT_ECHO_ON:
+ if (strcmp (mesg[count]->msg, prompt) != 0)
+ {
+ fprintf (stderr, "conv function called with wrong prompt: %s\n",
+ mesg[count]->msg);
+ exit (1);
+ }
+ reply[count].resp = strdup (user);
+ break;
+
+ default:
+ fprintf (stderr,
+ "pam_get_user calls conv function with unexpected msg style");
+ exit (1);
+ }
+ }
+
+ *resp = reply;
+ return PAM_SUCCESS;
+}
+
+int
+main (void)
+{
+ const char *service = "dummy";
+ const char *value;
+ struct pam_conv conv = { &login_conv, NULL};
+ pam_handle_t *pamh;
+ int retval;
+
+ /* 1: Call with NULL for every argument */
+ retval = pam_get_user (NULL, NULL, NULL);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "tst-pam_get_user (NULL, NULL, NULL) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ /* setup pam handle */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ /* 2: Call with valid pamh handle but NULL for user */
+ retval = pam_get_user (pamh, NULL, NULL);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "tst-pam_get_user (pamh, NULL, NULL) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ /* 3: Call with valid pamh handle and valid user ptr */
+ retval = pam_get_user (pamh, &value, NULL);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "tst-pam_get_user (pamh, &value, NULL) returned %d\n",
+ retval);
+ return 1;
+ }
+ if (strcmp (user, value) != 0)
+ {
+ fprintf (stderr,
+ "tst-pam_get_user (pamh, &value, NULL) mismatch:\n"
+ "expected: %s\n"
+ "got: %s\n", user, value);
+ return 1;
+ }
+
+ pam_end (pamh, 0);
+
+ /* setup pam handle without user */
+ retval = pam_start (service, NULL, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ /* 4: Call with valid pamh handle and valid user ptr */
+ retval = pam_get_user (pamh, &value, prompt);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "tst-pam_get_user (pamh, &value, prompt) returned %d\n",
+ retval);
+ return 1;
+ }
+ if (strcmp (user, value) != 0)
+ {
+ fprintf (stderr,
+ "tst-pam_get_user (pamh, &value, prompt) mismatch:\n"
+ "expected: %s\n"
+ "got: %s\n", user, value);
+ return 1;
+ }
+
+ pam_end (pamh, 0);
+
+ return 0;
+}
diff --git a/tests/tst-pam_getenvlist.c b/tests/tst-pam_getenvlist.c
new file mode 100644
index 00000000..d24a9bf9
--- /dev/null
+++ b/tests/tst-pam_getenvlist.c
@@ -0,0 +1,134 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <security/pam_appl.h>
+
+const char *envvals[] = {"VAL1=1", "VAL2=2", "VAL3=3"};
+
+int
+main (void)
+{
+ const char *service = "dummy";
+ const char *user = "root";
+ struct pam_conv conv;
+ pam_handle_t *pamh;
+ int retval;
+ char **ptr;
+ char *temp;
+ int var, i;
+
+ /* 1: Call with NULL as pam handle */
+ ptr = pam_getenvlist (NULL);
+ if (ptr != NULL)
+ {
+ fprintf (stderr, "pam_getenvlist (NULL) does not return NULL\n");
+ return 1;
+ }
+
+ /* setup pam handle */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ /* 2: Call with pam handle, but no environment set */
+ ptr = pam_getenvlist (pamh);
+ if (ptr == NULL || *ptr != NULL)
+ {
+ fprintf (stderr,
+ "pam_getenvlist (pamh) does not return pointer to NULL\n");
+ temp = *ptr;
+ var = 0;
+ while (temp)
+ {
+ printf ("%s\n", temp);
+ var++;
+ temp = *(ptr + var);
+ }
+ return 1;
+ }
+ free (ptr);
+
+ /* set environment variable */
+ for (i = 0; i < 3; i++)
+ {
+ retval = pam_putenv (pamh, envvals[i]);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_putenv (pamh, \"%s\") returned %d\n",
+ envvals[i], retval);
+ return 1;
+ }
+ }
+
+ /* 3: Call with pam handle and environment set */
+ ptr = pam_getenvlist (pamh);
+ if (ptr == NULL)
+ {
+ fprintf (stderr, "pam_getenvlist (pamh) returned NULL\n");
+ return 1;
+ }
+ else
+ {
+ temp = *ptr;
+ var = 0;
+ while (temp)
+ {
+ if (strcmp (temp, envvals[var]) != 0)
+ {
+ fprintf (stderr,
+ "pam_getenvlist returns wrong value:\n"
+ "expected: %s\n"
+ "got: %s\n", envvals[var], temp);
+ return 1;
+ }
+ free (temp);
+ var++;
+ temp = *(ptr + var);
+ }
+ free (ptr);
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_open_session.c b/tests/tst-pam_open_session.c
new file mode 100644
index 00000000..771ca35c
--- /dev/null
+++ b/tests/tst-pam_open_session.c
@@ -0,0 +1,58 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ int retval;
+
+ /* 1: Call with NULL as pam handle */
+ retval = pam_open_session (NULL, 0);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_open_session (NULL, 0) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_set_data.c b/tests/tst-pam_set_data.c
new file mode 100644
index 00000000..3b30dcc1
--- /dev/null
+++ b/tests/tst-pam_set_data.c
@@ -0,0 +1,488 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <security/pam_appl.h>
+#include <security/pam_modules.h>
+#include <pam_private.h>
+
+static int cleanup_was_called = 0;
+static int cleanup3_was_called = 0;
+static int cleanup3_retval = 0;
+static int cleanup6_was_called = 0;
+static int cleanup6_retval = 0;
+static int cleanup7_was_called = 0;
+static int cleanup7_retval = 0;
+static int cleanup7b_was_called = 0;
+static int cleanup7b_retval = 0;
+static int cleanup8_was_called = 0;
+static int cleanup8_retval = 0;
+
+static void
+tst_cleanup (pam_handle_t *pamh UNUSED, void *data, int error_status)
+{
+ cleanup_was_called = 1;
+ fprintf (stderr, "tst_cleanup was called: data=\"%s\", error_status=%d\n",
+ (char *)data, error_status);
+}
+
+static void
+tst_cleanup_3 (pam_handle_t *pamh UNUSED, void *data, int error_status)
+{
+ cleanup3_was_called = 1;
+
+ if (strcmp (data, "test3") != 0)
+ {
+ fprintf (stderr, "tst_cleanup_3 called with wrong data, got \"%s\"\n",
+ (char *)data);
+ cleanup3_retval = 1;
+ return;
+ }
+
+ free (data);
+
+ if (error_status & PAM_DATA_REPLACE)
+ {
+ fprintf (stderr, "tst_cleanup_3 called with PAM_DATA_REPLACE set\n");
+ cleanup3_retval = 1;
+ return;
+ }
+
+ if (error_status & PAM_DATA_SILENT)
+ {
+ fprintf (stderr, "tst_cleanup_3 called with PAM_DATA_SILENT set\n");
+ cleanup3_retval = 1;
+ return;
+ }
+
+ if (error_status != 0)
+ {
+ fprintf (stderr, "tst_cleanup_3 called with error_status set: %d\n",
+ error_status);
+ cleanup3_retval = 1;
+ return;
+ }
+}
+
+static void
+tst_cleanup_6 (pam_handle_t *pamh UNUSED, void *data, int error_status)
+{
+ cleanup6_was_called = 1;
+
+ if (error_status & PAM_DATA_SILENT)
+ {
+ fprintf (stderr, "tst_cleanup_6 called with PAM_DATA_SILENT set\n");
+ cleanup6_retval = 1;
+ return;
+ }
+
+ if (error_status & PAM_DATA_REPLACE)
+ {
+ if (strcmp (data, "test6a") != 0)
+ {
+ fprintf (stderr, "tst_cleanup_6 called with wrong data, got \"%s\"\n",
+ (char *)data);
+ cleanup6_retval = 1;
+ return;
+ }
+
+ if (error_status != PAM_DATA_REPLACE)
+ {
+ fprintf (stderr, "tst_cleanup_6 called with error_status set: %d\n",
+ error_status);
+ cleanup6_retval = 1;
+ return;
+ }
+ }
+ else
+ {
+ if (strcmp (data, "test6b") != 0)
+ {
+ fprintf (stderr, "tst_cleanup_6 called with wrong data, got \"%s\"\n",
+ (char *)data);
+ cleanup6_retval = 1;
+ return;
+ }
+
+ if (error_status != 0)
+ {
+ fprintf (stderr, "tst_cleanup_6 called with error_status set: %d\n",
+ error_status);
+ cleanup6_retval = 1;
+ return;
+ }
+ }
+
+ free (data);
+}
+
+static void
+tst_cleanup_7 (pam_handle_t *pamh UNUSED, void *data, int error_status)
+{
+ cleanup7_was_called = 1;
+
+ if (error_status & PAM_DATA_SILENT)
+ {
+ fprintf (stderr, "tst_cleanup_7 called with PAM_DATA_SILENT set\n");
+ cleanup7_retval = 1;
+ return;
+ }
+
+ if (error_status & PAM_DATA_REPLACE)
+ {
+ if (strcmp (data, "test7a") != 0)
+ {
+ fprintf (stderr, "tst_cleanup_7 called with wrong data, got \"%s\"\n",
+ (char *)data);
+ cleanup7_retval = 1;
+ return;
+ }
+
+ if (error_status != PAM_DATA_REPLACE)
+ {
+ fprintf (stderr, "tst_cleanup_7 called with error_status set: %d\n",
+ error_status);
+ cleanup7_retval = 1;
+ return;
+ }
+ }
+ else
+ {
+ fprintf (stderr, "tst_cleanup_7 called without PAM_DATA_REPLACE set: %d\n",
+ error_status);
+ cleanup7_retval = 1;
+ return;
+ }
+
+ free (data);
+}
+
+static void
+tst_cleanup_7b (pam_handle_t *pamh UNUSED, void *data, int error_status)
+{
+ cleanup7b_was_called = 1;
+
+ if (strcmp (data, "test7b") != 0)
+ {
+ fprintf (stderr, "tst_cleanup_7b called with wrong data, got \"%s\"\n",
+ (char *)data);
+ cleanup7b_retval = 1;
+ return;
+ }
+
+ free (data);
+
+ if (error_status & PAM_DATA_REPLACE)
+ {
+ fprintf (stderr, "tst_cleanup_7b called with PAM_DATA_REPLACE set\n");
+ cleanup7b_retval = 1;
+ return;
+ }
+
+ if (error_status & PAM_DATA_SILENT)
+ {
+ fprintf (stderr, "tst_cleanup_7b called with PAM_DATA_SILENT set\n");
+ cleanup7b_retval = 1;
+ return;
+ }
+
+ if (error_status != 0)
+ {
+ fprintf (stderr, "tst_cleanup_7b called with error_status set: %d\n",
+ error_status);
+ cleanup7b_retval = 1;
+ return;
+ }
+}
+
+static void
+tst_cleanup_8 (pam_handle_t *pamh UNUSED, void *data, int error_status)
+{
+ cleanup8_was_called = 1;
+
+ if (strcmp (data, "test8") != 0)
+ {
+ fprintf (stderr, "tst_cleanup_8 called with wrong data, got \"%s\"\n",
+ (char *)data);
+ cleanup8_retval = 1;
+ return;
+ }
+
+ free (data);
+
+ if (error_status & PAM_DATA_REPLACE)
+ {
+ fprintf (stderr, "tst_cleanup_8 called with PAM_DATA_REPLACE set\n");
+ cleanup8_retval = 1;
+ return;
+ }
+
+ if (error_status & PAM_DATA_SILENT)
+ {
+ fprintf (stderr, "tst_cleanup_8 called with PAM_DATA_SILENT set\n");
+ cleanup8_retval = 1;
+ return;
+ }
+
+ if (error_status != 987)
+ {
+ fprintf (stderr, "tst_cleanup_8 called with wrong error_status set: %d\n",
+ error_status);
+ cleanup8_retval = 1;
+ return;
+ }
+}
+
+int
+main (void)
+{
+ const char *service = "dummy";
+ const char *user = "root";
+ struct pam_conv conv;
+ pam_handle_t *pamh;
+ void *dataptr;
+ int retval;
+
+ /* 1: Call with NULL as pam handle */
+ dataptr = strdup ("test1");
+ retval = pam_set_data (NULL, "tst-pam_set_data-1", dataptr, tst_cleanup);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_set_data (NULL, ...) returned PAM_SUCCESS\n");
+ return 1;
+ }
+ free (dataptr);
+
+ /* setup pam handle */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ /* 2: check for call from application */
+ dataptr = strdup ("test2");
+ retval = pam_set_data (pamh, "tst-pam_set_data-2", dataptr, tst_cleanup);
+ if (retval != PAM_SYSTEM_ERR)
+ {
+ fprintf (stderr,
+ "pam_set_data returned %d when expecting PAM_SYSTEM_ERR\n",
+ retval);
+ return 1;
+ }
+ free (dataptr);
+
+
+ /* 3: check for call from module */
+ __PAM_TO_MODULE(pamh);
+ dataptr = strdup ("test3");
+ retval = pam_set_data (pamh, "tst-pam_set_data-3", dataptr,
+ tst_cleanup_3);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "pam_set_data failed: %d\n",
+ retval);
+ return 1;
+ }
+
+ /* 4: check for call with NULL as module_data_name */
+ dataptr = strdup ("test4");
+ retval = pam_set_data (pamh, NULL, dataptr, tst_cleanup);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "pam_set_data with NULL as module_data_name succeded!\n");
+ return 1;
+ }
+ free (dataptr);
+
+ /* 5: check for call with NULL as cleanup function */
+ dataptr = strdup ("test5");
+ retval = pam_set_data (pamh, "tst-pam_set_data-5", dataptr, NULL);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "pam_set_data with NULL as cleanup function failed: %d\n",
+ retval);
+ return 1;
+ }
+ free (dataptr);
+
+ /* 6: Overwrite data and check cleanup flags */
+ dataptr = strdup ("test6a");
+ retval = pam_set_data (pamh, "tst-pam_set_data-6", dataptr,
+ tst_cleanup_6);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "test6: first pam_set_data failed: %d\n",
+ retval);
+ return 1;
+ }
+
+ dataptr = strdup ("test6b");
+ retval = pam_set_data (pamh, "tst-pam_set_data-6", dataptr,
+ tst_cleanup_6);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "test6: second pam_set_data failed: %d\n",
+ retval);
+ return 1;
+ }
+
+ /* 7: Overwrite data and cleanup function, check cleanup flags */
+ dataptr = strdup ("test7a");
+ retval = pam_set_data (pamh, "tst-pam_set_data-7", dataptr,
+ tst_cleanup_7);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "test7: first pam_set_data failed: %d\n",
+ retval);
+ return 1;
+ }
+
+ dataptr = strdup ("test7b");
+ retval = pam_set_data (pamh, "tst-pam_set_data-7", dataptr,
+ tst_cleanup_7b);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "test7: second pam_set_data failed: %d\n",
+ retval);
+ return 1;
+ }
+
+ __PAM_TO_APP(pamh);
+
+ /* Close PAM handle and check return codes of cleanup functions */
+ retval = pam_end (pamh, 0);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "pam_end reported an error: %d\n",
+ retval);
+ return 1;
+ }
+
+ if (cleanup_was_called == 1)
+ return 1;
+
+ if (cleanup3_was_called == 0)
+ {
+ fprintf (stderr, "tst_cleanup_3 was never called!\n");
+ return 1;
+ }
+ if (cleanup3_retval != 0)
+ return 1;
+
+ if (cleanup6_was_called == 0)
+ {
+ fprintf (stderr, "tst_cleanup_6 was never called!\n");
+ return 1;
+ }
+ if (cleanup6_retval != 0)
+ return 1;
+
+ if (cleanup7_was_called == 0)
+ {
+ fprintf (stderr, "tst_cleanup_7 was never called!\n");
+ return 1;
+ }
+ if (cleanup7_retval != 0)
+ return 1;
+
+ if (cleanup7b_was_called == 0)
+ {
+ fprintf (stderr, "tst_cleanup_7b was never called!\n");
+ return 1;
+ }
+ if (cleanup7b_retval != 0)
+ return 1;
+
+ /* test if error code is delivered to cleanup function */
+ /* setup pam handle */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ /* 8: check if cleanup function is called with correct error code */
+ __PAM_TO_MODULE(pamh);
+ dataptr = strdup ("test8");
+ retval = pam_set_data (pamh, "tst-pam_set_data-8", dataptr,
+ tst_cleanup_8);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "test8: pam_set_data failed: %d\n",
+ retval);
+ return 1;
+ }
+
+ __PAM_TO_APP(pamh);
+
+ retval = pam_end (pamh, 987);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "pam_end reported an error: %d\n",
+ retval);
+ return 1;
+ }
+
+ if (cleanup8_was_called == 0)
+ {
+ fprintf (stderr, "tst_cleanup_3 was never called!\n");
+ return 1;
+ }
+
+ if (cleanup8_retval != 0)
+ return 1;
+
+ return 0;
+}
diff --git a/tests/tst-pam_set_item.c b/tests/tst-pam_set_item.c
new file mode 100644
index 00000000..069d7aff
--- /dev/null
+++ b/tests/tst-pam_set_item.c
@@ -0,0 +1,149 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <security/pam_appl.h>
+
+struct mapping {
+ int type;
+ const char *string;
+ int expected;
+ const char *new_value;
+};
+
+struct mapping items[] = {
+ {PAM_SERVICE, "PAM_SERVICE", PAM_SUCCESS, "logout"},
+ {PAM_USER, "PAM_USER", PAM_SUCCESS, "noroot"},
+ {PAM_TTY, "PAM_TTY", PAM_SUCCESS, "TTyX"},
+ {PAM_RHOST, "PAM_RHOST", PAM_SUCCESS, "remote"},
+ {PAM_AUTHTOK, "PAM_AUTHTOK", PAM_BAD_ITEM, "none"},
+ {PAM_OLDAUTHTOK, "PAM_OLDAUTHTOK", PAM_BAD_ITEM, "none"},
+ {PAM_RUSER, "PAM_RUSER", PAM_SUCCESS, "noroot"},
+ {PAM_USER_PROMPT, "PAM_USER_PROMPT", PAM_SUCCESS, "your name: "},
+ {PAM_FAIL_DELAY, "PAM_FAIL_DELAY", PAM_SUCCESS, "4000"}
+};
+
+int
+main (void)
+{
+ const char *service = "dummy";
+ const char *user = "root";
+ struct pam_conv conv;
+ pam_handle_t *pamh;
+ int retval, num, i;
+
+ /* 1: Call with NULL as pam handle */
+ retval = pam_set_item (NULL, PAM_SERVICE, "dummy");
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_set_item (NULL, ...) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ /* setup pam handle */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ /* 2: check for bad item */
+ retval = pam_set_item (pamh, -1, "dummy");
+ if (retval != PAM_BAD_ITEM)
+ {
+ fprintf (stderr,
+ "pam_set_item returned %d when expecting PAM_BAD_ITEM\n",
+ retval);
+ return 1;
+ }
+
+ /* 3: try to set PAM_CONV to NULL */
+ retval = pam_set_item (pamh, PAM_CONV, NULL);
+ if (retval != PAM_PERM_DENIED)
+ {
+ fprintf (stderr,
+ "pam_set_item (pamh, PAM_CONV, NULL) returned %d\n",
+ retval);
+ return 1;
+ }
+
+ /* 4: try to replace all items */
+ num = sizeof(items) / sizeof(struct mapping);
+
+ for (i = 0; i < num; i++)
+ {
+ retval = pam_set_item (pamh, items[i].type, items[i].new_value);
+
+ if (retval != items[i].expected)
+ {
+ fprintf (stderr,
+ "pam_set_item failed to set value for %s. Returned %d\n",
+ items[i].string, retval);
+ return 1;
+ }
+ else if (items[i].expected == PAM_SUCCESS)
+ {
+ const void *value;
+
+ retval = pam_get_item (pamh, items[i].type, &value);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr,
+ "pam_get_item was not able to fetch changed value: %d\n",
+ retval);
+ return 1;
+ }
+ if (strcmp (items[i].new_value, value) != 0)
+ {
+ fprintf (stderr,
+ "pam_get_item got wrong value:\n"
+ "expected: %s\n"
+ "got: %s\n", items[i].new_value, (const char *)value);
+ return 1;
+ }
+ }
+ }
+
+ pam_end (pamh, 0);
+
+ return 0;
+}
diff --git a/tests/tst-pam_setcred.c b/tests/tst-pam_setcred.c
new file mode 100644
index 00000000..917d4d05
--- /dev/null
+++ b/tests/tst-pam_setcred.c
@@ -0,0 +1,58 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ int retval;
+
+ /* 1: Call with NULL as pam handle */
+ retval = pam_setcred (NULL, 0);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_setcred (NULL, 0) returned PAM_SUCCESS\n");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/tst-pam_start.c b/tests/tst-pam_start.c
new file mode 100644
index 00000000..ce013633
--- /dev/null
+++ b/tests/tst-pam_start.c
@@ -0,0 +1,107 @@
+/*
+ * 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, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 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.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``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 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 <stdio.h>
+#include <unistd.h>
+
+#include <security/pam_appl.h>
+
+
+int
+main (void)
+{
+ const char *service = "dummy";
+ const char *user = "root";
+ struct pam_conv conv;
+ pam_handle_t *pamh;
+ int retval;
+
+ /* 1: check with valid arguments */
+ retval = pam_start (service, user, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+ else if (pamh == NULL)
+ {
+ fprintf (stderr,
+ "pam_start (%s, %s, &conv, &pamh) returned NULL for pamh\n",
+ service, user);
+ return 1;
+ }
+
+ /* 2: check with NULL for service */
+ retval = pam_start (NULL, user, &conv, &pamh);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (NULL, %s, &conv, &pamh) returned %d\n",
+ user, retval);
+ return 1;
+ }
+
+ /* 3: check with NULL for user */
+ retval = pam_start (service, NULL, &conv, &pamh);
+ if (retval != PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, NULL, &conv, &pamh) returned %d\n",
+ service, retval);
+ return 1;
+ }
+
+
+ /* 4: check with NULL for conv */
+ retval = pam_start (service, user, NULL, &pamh);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, NULL, &pamh) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ /* 5: check with NULL for pamh */
+ retval = pam_start (service, user, &conv, NULL);
+ if (retval == PAM_SUCCESS)
+ {
+ fprintf (stderr, "pam_start (%s, %s, &conv, NULL) returned %d\n",
+ service, user, retval);
+ return 1;
+ }
+
+ return 0;
+}