Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package pam_wrapper for openSUSE:Factory 
checked in at 2021-10-28 18:31:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/pam_wrapper (Old)
 and      /work/SRC/openSUSE:Factory/.pam_wrapper.new.1890 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "pam_wrapper"

Thu Oct 28 18:31:24 2021 rev:14 rq:927924 version:1.1.4

Changes:
--------
--- /work/SRC/openSUSE:Factory/pam_wrapper/pam_wrapper.changes  2020-05-20 
18:46:48.613464010 +0200
+++ /work/SRC/openSUSE:Factory/.pam_wrapper.new.1890/pam_wrapper.changes        
2021-10-28 18:31:42.176424462 +0200
@@ -1,0 +2,6 @@
+Thu Oct 28 08:40:28 UTC 2021 - Andreas Schneider <[email protected]>
+
+- Update to version 1.1.4
+  * https://gitlab.com/cwrap/pam_wrapper/-/blob/pam_wrapper-1.1.4/CHANGELOG
+
+-------------------------------------------------------------------

Old:
----
  pam_wrapper-1.1.3.tar.gz
  pam_wrapper-1.1.3.tar.gz.asc

New:
----
  pam_wrapper-1.1.4.tar.gz
  pam_wrapper-1.1.4.tar.gz.asc

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ pam_wrapper.spec ++++++
--- /var/tmp/diff_new_pack.MZKi0Z/_old  2021-10-28 18:31:42.692424783 +0200
+++ /var/tmp/diff_new_pack.MZKi0Z/_new  2021-10-28 18:31:42.696424785 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package pam_wrapper
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
 ############################# NOTE ##################################
 %bcond_without python2
 Name:           pam_wrapper
-Version:        1.1.3
+Version:        1.1.4
 Release:        0
 Summary:        A tool to test PAM applications and PAM modules
 License:        GPL-3.0-or-later

++++++ pam_wrapper-1.1.3.tar.gz -> pam_wrapper-1.1.4.tar.gz ++++++
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/libpamtest.c.50591A3CF2F16696.idx and 
new/pam_wrapper-1.1.4/.cache/clangd/index/libpamtest.c.50591A3CF2F16696.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/libpamtest.h.5D17FC28842DB9A6.idx and 
new/pam_wrapper-1.1.4/.cache/clangd/index/libpamtest.h.5D17FC28842DB9A6.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/pam_chatty.c.20FD0B741C24D56B.idx and 
new/pam_wrapper-1.1.4/.cache/clangd/index/pam_chatty.c.20FD0B741C24D56B.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/pam_get_items.c.0EF57BF2FB557FDA.idx 
and 
new/pam_wrapper-1.1.4/.cache/clangd/index/pam_get_items.c.0EF57BF2FB557FDA.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/pam_matrix.c.06B52DD1FD84DDA5.idx and 
new/pam_wrapper-1.1.4/.cache/clangd/index/pam_matrix.c.06B52DD1FD84DDA5.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/pam_set_items.c.4EB3C1ADFA19BBB6.idx 
and 
new/pam_wrapper-1.1.4/.cache/clangd/index/pam_set_items.c.4EB3C1ADFA19BBB6.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/pam_wrapper.c.88B9874C29C542E9.idx 
and 
new/pam_wrapper-1.1.4/.cache/clangd/index/pam_wrapper.c.88B9874C29C542E9.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/pwrap_compat.h.61E8526BE3F084B4.idx 
and 
new/pam_wrapper-1.1.4/.cache/clangd/index/pwrap_compat.h.61E8526BE3F084B4.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/pypamtest.c.6EAB1E75E1074FD7.idx and 
new/pam_wrapper-1.1.4/.cache/clangd/index/pypamtest.c.6EAB1E75E1074FD7.idx 
differ
Binary files 
old/pam_wrapper-1.1.3/.cache/clangd/index/test_pam_wrapper.c.0DFC22A2864C2D78.idx
 and 
new/pam_wrapper-1.1.4/.cache/clangd/index/test_pam_wrapper.c.0DFC22A2864C2D78.idx
 differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/.gitlab-ci.yml 
new/pam_wrapper-1.1.4/.gitlab-ci.yml
--- old/pam_wrapper-1.1.3/.gitlab-ci.yml        2020-03-25 13:12:12.000000000 
+0100
+++ new/pam_wrapper-1.1.4/.gitlab-ci.yml        2021-10-28 10:37:33.000000000 
+0200
@@ -132,6 +132,9 @@
     when: on_failure
     paths:
       - obj/
+  # pam_wrapper stopped to work with the latest OpenPAM version, this is a
+  # bigger effort to investigate.
+  allow_failure: true
 
 tumbleweed/x86_64/gcc:
   image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/CHANGELOG 
new/pam_wrapper-1.1.4/CHANGELOG
--- old/pam_wrapper-1.1.3/CHANGELOG     2020-03-26 09:43:22.000000000 +0100
+++ new/pam_wrapper-1.1.4/CHANGELOG     2021-10-28 10:37:33.000000000 +0200
@@ -1,6 +1,15 @@
 ChangeLog
 ==========
 
+version 1.1.4 (released 2020-10-28)
+  * NOTE: pam_wrapper stopped working with the latest OpenPAM on FreeBSD 12.
+    Help is needed to add back support.
+  * Added support to retrieve the PAM environment from a python's
+    PAMTEST_GETENVLIST
+  * Added a new keyword parameter to reuse the PAM handle in libpamtest
+  * Fixed pid range
+  * Fixed constructor/destructor on AIX
+
 version 1.1.3 (released 2020-03-26)
   * Fixed paths in pkgconfig and cmake config files
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/CMakeLists.txt 
new/pam_wrapper-1.1.4/CMakeLists.txt
--- old/pam_wrapper-1.1.3/CMakeLists.txt        2020-03-26 09:43:22.000000000 
+0100
+++ new/pam_wrapper-1.1.4/CMakeLists.txt        2021-10-28 10:37:33.000000000 
+0200
@@ -11,7 +11,7 @@
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(pam_wrapper VERSION 1.1.3 LANGUAGES C)
+project(pam_wrapper VERSION 1.1.4 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -25,13 +25,13 @@
 #     Increment PATCH.
 set(LIBRARY_VERSION_MAJOR 0)
 set(LIBRARY_VERSION_MINOR 0)
-set(LIBRARY_VERSION_PATCH 6)
+set(LIBRARY_VERSION_PATCH 7)
 set(LIBRARY_VERSION 
"${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
 set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 
-set(PAMTEST_LIBRARY_VERSION_MAJOR 0)
+set(PAMTEST_LIBRARY_VERSION_MAJOR 1)
 set(PAMTEST_LIBRARY_VERSION_MINOR 0)
-set(PAMTEST_LIBRARY_VERSION_PATCH 5)
+set(PAMTEST_LIBRARY_VERSION_PATCH 0)
 set(PAMTEST_LIBRARY_VERSION 
"${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
 set(PAMTEST_LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/CompilerChecks.cmake 
new/pam_wrapper-1.1.4/CompilerChecks.cmake
--- old/pam_wrapper-1.1.3/CompilerChecks.cmake  2020-03-20 15:01:55.000000000 
+0100
+++ new/pam_wrapper-1.1.4/CompilerChecks.cmake  2021-10-28 10:37:33.000000000 
+0200
@@ -95,6 +95,9 @@
         add_c_compiler_flag("-Wno-error=tautological-compare" 
SUPPORTED_COMPILER_FLAGS)
     endif()
 
+    # Needed by src/python/CMakeLists.txt
+    check_c_compiler_flag("-Wno-cast-function-type" 
WITH_WNO_CAST_FUNCTION_TYPE)
+
     # Unset CMAKE_REQUIRED_FLAGS
     unset(CMAKE_REQUIRED_FLAGS)
 endif()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/ConfigureChecks.cmake 
new/pam_wrapper-1.1.4/ConfigureChecks.cmake
--- old/pam_wrapper-1.1.3/ConfigureChecks.cmake 2020-03-24 13:41:14.000000000 
+0100
+++ new/pam_wrapper-1.1.4/ConfigureChecks.cmake 2021-06-25 10:12:16.000000000 
+0200
@@ -77,9 +77,6 @@
 check_function_exists(pam_syslog HAVE_PAM_SYSLOG)
 check_function_exists(pam_vsyslog HAVE_PAM_VSYSLOG)
 check_function_exists(pam_start_confdir HAVE_PAM_START_CONFDIR)
-# This is available in current PAM master and will be used as a workaround
-# till pam_start_confdir() is available.
-check_function_exists(pam_modutil_search_key HAVE_PAM_MODUTIL_SEARCH_KEY)
 unset(CMAKE_REQUIRED_LIBRARIES)
 
 # OPTIONS
@@ -141,6 +138,32 @@
 }" HAVE_DESTRUCTOR_ATTRIBUTE)
 
 check_c_source_compiles("
+#pragma init (test_constructor)
+void test_constructor(void);
+
+void test_constructor(void)
+{
+     return;
+}
+
+int main(void) {
+     return 0;
+}" HAVE_PRAGMA_INIT)
+
+check_c_source_compiles("
+#pragma fini (test_destructor)
+void test_destructor(void);
+
+void test_destructor(void)
+{
+    return;
+}
+
+int main(void) {
+    return 0;
+}" HAVE_PRAGMA_FINI)
+
+check_c_source_compiles("
 void log_fn(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
 
 int main(void) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/config.h.cmake 
new/pam_wrapper-1.1.4/config.h.cmake
--- old/pam_wrapper-1.1.3/config.h.cmake        2020-03-24 13:41:14.000000000 
+0100
+++ new/pam_wrapper-1.1.4/config.h.cmake        2021-06-25 10:12:16.000000000 
+0200
@@ -21,7 +21,6 @@
 #cmakedefine HAVE_PAM_VSYSLOG 1
 #cmakedefine HAVE_PAM_SYSLOG 1
 #cmakedefine HAVE_PAM_START_CONFDIR 1
-#cmakedefine HAVE_PAM_MODUTIL_SEARCH_KEY 1
 
 #cmakedefine HAVE_PAM_VPROMPT_CONST 1
 #cmakedefine HAVE_PAM_PROMPT_CONST 1
@@ -40,6 +39,8 @@
 #cmakedefine HAVE_GCC_ATOMIC_BUILTINS 1
 #cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
 #cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
+#cmakedefine HAVE_PRAGMA_INIT 1
+#cmakedefine HAVE_PRAGMA_FINI 1
 #cmakedefine HAVE_FUNCTION_ATTRIBUTE_FORMAT 1
 
 /*************************** ENDIAN *****************************/
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/include/libpamtest.h 
new/pam_wrapper-1.1.4/include/libpamtest.h
--- old/pam_wrapper-1.1.3/include/libpamtest.h  2018-06-25 10:59:26.000000000 
+0200
+++ new/pam_wrapper-1.1.4/include/libpamtest.h  2021-06-25 10:35:51.000000000 
+0200
@@ -19,6 +19,7 @@
 #ifndef __LIBPAMTEST_H_
 #define __LIBPAMTEST_H_
 
+#include <stddef.h>
 #include <stdint.h>
 #include <security/pam_appl.h>
 
@@ -128,12 +129,11 @@
         * an index internally.
         */
        const char **in_echo_on;
-
-       /** Captures messages through PAM_TEXT_INFO. The test caller is
+       /** Captures messages through PAM_ERROR_MSG. The test caller is
         * responsible for allocating enough space in the array.
         */
        char **out_err;
-       /** Captures messages through PAM_ERROR_MSG. The test caller is
+       /** Captures messages through PAM_TEXT_INFO. The test caller is
         * responsible for allocating enough space in the array.
         */
        char **out_info;
@@ -156,6 +156,8 @@
  * @param[in]  test_cases   List of libpamtest test cases. Must end with
  *                          PAMTEST_CASE_SENTINEL
  *
+ * @param[in]  pam_handle   The PAM handle to use to run the tests
+ *
  * @code
  * int main(void) {
  *     int rc;
@@ -175,10 +177,11 @@
                                  const char *user,
                                  pam_conv_fn conv_fn,
                                  void *conv_userdata,
-                                 struct pam_testcase test_cases[]);
+                                 struct pam_testcase test_cases[],
+                                 pam_handle_t *pam_handle);
 #else
-#define run_pamtest_conv(service, user, conv_fn, conv_data, test_cases) \
-       _pamtest_conv(service, user, conv_fn, conv_data, test_cases, 
sizeof(test_cases)/sizeof(test_cases[0])
+#define run_pamtest_conv(service, user, conv_fn, conv_data, test_cases, 
pam_handle) \
+       _pamtest_conv(service, user, conv_fn, conv_data, test_cases, 
sizeof(test_cases)/sizeof(test_cases[0], pam_handle)
 #endif
 
 #ifdef DOXYGEN
@@ -196,6 +199,8 @@
  * @param[in]  test_cases   List of libpamtest test cases. Must end with
  *                          PAMTEST_CASE_SENTINEL
  *
+ * @param[in]  pam_handle   The PAM handle to use to run the tests
+ *
  * @code
  * int main(void) {
  *     int rc;
@@ -214,10 +219,11 @@
 enum pamtest_err run_pamtest(const char *service,
                             const char *user,
                             struct pamtest_conv_data *conv_data,
-                            struct pam_testcase test_cases[]);
+                            struct pam_testcase test_cases[],
+                            pam_handle_t *pam_handle);
 #else
-#define run_pamtest(service, user, conv_data, test_cases) \
-       _pamtest(service, user, conv_data, test_cases, 
sizeof(test_cases)/sizeof(test_cases[0]))
+#define run_pamtest(service, user, conv_data, test_cases, pam_handle) \
+       _pamtest(service, user, conv_data, test_cases, 
sizeof(test_cases)/sizeof(test_cases[0]), pam_handle)
 #endif
 
 #ifdef DOXYGEN
@@ -262,13 +268,15 @@
                               pam_conv_fn conv_fn,
                               void *conv_userdata,
                               struct pam_testcase test_cases[],
-                              size_t num_test_cases);
+                              size_t num_test_cases,
+                              pam_handle_t *pam_handle);
 
 enum pamtest_err _pamtest(const char *service,
                          const char *user,
                          struct pamtest_conv_data *conv_data,
                          struct pam_testcase test_cases[],
-                         size_t num_test_cases);
+                         size_t num_test_cases,
+                         pam_handle_t *pam_handle);
 
 const struct pam_testcase *_pamtest_failed_case(struct pam_testcase 
test_cases[],
                                                size_t num_test_cases);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/src/libpamtest.c 
new/pam_wrapper-1.1.4/src/libpamtest.c
--- old/pam_wrapper-1.1.3/src/libpamtest.c      2018-09-25 20:13:36.000000000 
+0200
+++ new/pam_wrapper-1.1.4/src/libpamtest.c      2021-10-28 10:13:31.000000000 
+0200
@@ -66,7 +66,8 @@
                               pam_conv_fn conv_fn,
                               void *conv_userdata,
                               struct pam_testcase test_cases[],
-                              size_t num_test_cases)
+                              size_t num_test_cases,
+                              pam_handle_t *pam_handle)
 {
        int rv;
        pam_handle_t *ph;
@@ -82,9 +83,13 @@
                return PAMTEST_ERR_INTERNAL;
        }
 
-       rv = pam_start(service, user, &conv, &ph);
-       if (rv != PAM_SUCCESS) {
-               return PAMTEST_ERR_START;
+       if (pam_handle == NULL) {
+               rv = pam_start(service, user, &conv, &ph);
+               if (rv != PAM_SUCCESS) {
+                       return PAMTEST_ERR_START;
+               }
+       } else {
+               ph = pam_handle;
        }
 
        for (tcindex = 0; tcindex < num_test_cases; tcindex++) {
@@ -322,7 +327,8 @@
                          const char *user,
                          struct pamtest_conv_data *conv_data,
                          struct pam_testcase test_cases[],
-                         size_t num_test_cases)
+                         size_t num_test_cases,
+                         pam_handle_t *pam_handle)
 {
        struct pamtest_conv_ctx cctx = {
                .data = conv_data,
@@ -332,5 +338,6 @@
                             pamtest_simple_conv,
                             &cctx,
                             test_cases,
-                            num_test_cases);
+                            num_test_cases,
+                            pam_handle);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/src/pam_wrapper.c 
new/pam_wrapper-1.1.4/src/pam_wrapper.c
--- old/pam_wrapper-1.1.3/src/pam_wrapper.c     2020-03-24 13:41:14.000000000 
+0100
+++ new/pam_wrapper-1.1.4/src/pam_wrapper.c     2021-06-25 10:12:16.000000000 
+0200
@@ -311,7 +311,14 @@
  *********************************************************/
 
 bool pam_wrapper_enabled(void);
+#if ! defined(HAVE_CONSTRUCTOR_ATTRIBUTE) && defined(HAVE_PRAGMA_INIT)
+/* xlC and other oldschool compilers support (only) this */
+#pragma init (pwrap_constructor)
+#endif
 void pwrap_constructor(void) CONSTRUCTOR_ATTRIBUTE;
+#if ! defined(HAVE_DESTRUCTOR_ATTRIBUTE) && defined(HAVE_PRAGMA_FINI)
+#pragma fini (pwrap_destructor)
+#endif
 void pwrap_destructor(void) DESTRUCTOR_ATTRIBUTE;
 
 /*********************************************************
@@ -784,14 +791,20 @@
        buf[sizeof(buf) - 1] = '\0';
 
        tmp = strtol(buf, NULL, 10);
-       if (tmp == 0 || tmp > 0xFFFF || errno == ERANGE) {
+       if (tmp == 0 || errno == ERANGE) {
                PWRAP_LOG(PWRAP_LOG_ERROR,
                          "Failed to parse pid, buf=%s",
                          buf);
                return;
        }
 
-       pid = (pid_t)(tmp & 0xFFFF);
+       pid = (pid_t)tmp;
+       /* Check if we are out of pid_t range on this system */
+       if ((long)pid != tmp) {
+               PWRAP_LOG(PWRAP_LOG_ERROR,
+                         "pid out of range: %ld", tmp);
+               return;
+       }
 
        rc = kill(pid, 0);
        if (rc == -1) {
@@ -935,130 +948,6 @@
 
 #else /* HAVE_PAM_START_CONFDIR */
 
-#ifdef HAVE_PAM_MODUTIL_SEARCH_KEY
-/*
- * This is needed to workaround Tumbleweed which packages a libpam git version.
- */
-static int pso_copy(const char *src, const char *dst, const char *pdir, mode_t 
mode)
-{
-#define PSO_COPY_READ_SIZE 16
-       int srcfd = -1;
-       int dstfd = -1;
-       int rc = -1;
-       ssize_t bread, bwritten;
-       struct stat sb;
-       char buf[PSO_COPY_READ_SIZE + 1];
-       size_t pso_copy_read_size = PSO_COPY_READ_SIZE;
-       int cmp;
-       size_t to_read;
-       bool found_slash;
-
-       cmp = strcmp(src, dst);
-       if (cmp == 0) {
-               return -1;
-       }
-
-       srcfd = open(src, O_RDONLY, 0);
-       if (srcfd < 0) {
-               return -1;
-       }
-
-       if (mode == 0) {
-               rc = fstat(srcfd, &sb);
-               if (rc != 0) {
-                       rc = -1;
-                       goto out;
-               }
-               mode = sb.st_mode;
-       }
-
-       dstfd = open(dst, O_CREAT|O_WRONLY|O_TRUNC, mode);
-       if (dstfd < 0) {
-               rc = -1;
-               goto out;
-       }
-
-       found_slash = false;
-       to_read = 1;
-
-       for (;;) {
-               bread = read(srcfd, buf, to_read);
-               if (bread == 0) {
-                       /* done */
-                       break;
-               } else if (bread < 0) {
-                       errno = EIO;
-                       rc = -1;
-                       goto out;
-               }
-
-               to_read = 1;
-               if (!found_slash && buf[0] == '/') {
-                       found_slash = true;
-                       to_read = pso_copy_read_size;
-               }
-
-               if (found_slash && bread == PSO_COPY_READ_SIZE) {
-                       cmp = memcmp(buf, "usr/etc/pam.d/%s", 16);
-                       if (cmp == 0) {
-                               char tmp[16] = {0};
-
-                               snprintf(tmp, sizeof(tmp), "%s/%%s", pdir + 1);
-
-                               memcpy(buf, tmp, 12);
-                               memset(&buf[12], '\0', 4);
-
-                               /*
-                                * If we found this string, we need to reduce
-                                * the read size to not miss, the next one.
-                                */
-                               pso_copy_read_size = 13;
-                       } else {
-                               cmp = memcmp(buf, "usr/etc/pam.d", 13);
-                               if (cmp == 0) {
-                                       memcpy(buf, pdir + 1, 9);
-                                       memset(&buf[9], '\0', 4);
-                               } else {
-                                       cmp = memcmp(buf, "etc/pam.d", 9);
-                                       if (cmp == 0) {
-                                               memcpy(buf, pdir + 1, 9);
-                                       }
-                               }
-                       }
-                       found_slash = false;
-               }
-
-               bwritten = write(dstfd, buf, bread);
-               if (bwritten < 0) {
-                       errno = EIO;
-                       rc = -1;
-                       goto out;
-               }
-
-               if (bread != bwritten) {
-                       errno = EFAULT;
-                       rc = -1;
-                       goto out;
-               }
-       }
-
-       rc = 0;
-out:
-       if (srcfd != -1) {
-               close(srcfd);
-       }
-       if (dstfd != -1) {
-               close(dstfd);
-       }
-       if (rc < 0) {
-               unlink(dst);
-       }
-
-       return rc;
-#undef PSO_COPY_READ_SIZE
-}
-#else /* HAVE_PAM_MODUTIL_SEARCH_KEY */
-
 static int pso_copy(const char *src, const char *dst, const char *pdir, mode_t 
mode)
 {
 #define PSO_COPY_READ_SIZE 9
@@ -1154,7 +1043,6 @@
        return rc;
 #undef PSO_COPY_READ_SIZE
 }
-#endif /* HAVE_PAM_MODUTIL_SEARCH_KEY */
 
 static void pwrap_init(void)
 {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/src/python/CMakeLists.txt 
new/pam_wrapper-1.1.4/src/python/CMakeLists.txt
--- old/pam_wrapper-1.1.3/src/python/CMakeLists.txt     2018-02-13 
08:55:46.000000000 +0100
+++ new/pam_wrapper-1.1.4/src/python/CMakeLists.txt     2021-10-28 
10:37:33.000000000 +0200
@@ -2,3 +2,9 @@
 
 add_subdirectory(python2)
 add_subdirectory(python3)
+
+if (WITH_WNO_CAST_FUNCTION_TYPE)
+    set_source_files_properties(pypamtest.c
+                                DIRECTORY python2 python3
+                                PROPERTIES COMPILE_OPTIONS 
"-Wno-cast-function-type")
+endif()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/src/python/pypamtest.c 
new/pam_wrapper-1.1.4/src/python/pypamtest.c
--- old/pam_wrapper-1.1.3/src/python/pypamtest.c        2020-03-20 
15:01:55.000000000 +0100
+++ new/pam_wrapper-1.1.4/src/python/pypamtest.c        2021-06-25 
09:28:05.000000000 +0200
@@ -58,8 +58,14 @@
        enum pamtest_ops pam_operation;
        int expected_rv;
        int flags;
+
+       PyObject *pam_handle;
+       PyObject *pam_env;
 } TestCaseObject;
 
+#define PyTestCase_AsTestCaseObject(py_obj) \
+       (TestCaseObject *)(py_obj)
+
 /**********************************************************
  *** module-specific exceptions
  **********************************************************/
@@ -461,6 +467,22 @@
                discard_const_p(char, "Additional flags for the PAM operation"),
        },
 
+       {
+               discard_const_p(char, "pam_handle"),
+               T_OBJECT_EX,
+               offsetof(TestCaseObject, pam_handle),
+               READONLY,
+               discard_const_p(char, "Pam handle"),
+       },
+
+       {
+               discard_const_p(char, "pam_env"),
+               T_OBJECT_EX,
+               offsetof(TestCaseObject, pam_env),
+               READONLY,
+               discard_const_p(char, "Pam env"),
+       },
+
        { NULL, 0, 0, 0, NULL } /* Sentinel */
 };
 
@@ -773,6 +795,8 @@
        int rc;
        long value;
 
+       memset(test, 0, sizeof(struct pam_testcase));
+
        rc = py_testcase_get(py_test, "pam_operation", &value);
        if (rc != 0) {
                return rc;
@@ -903,6 +927,84 @@
        return 0;
 }
 
+static int cstruct_to_py_testcase(PyObject *pytest, struct pam_testcase *ctest)
+{
+       TestCaseObject *t = PyTestCase_AsTestCaseObject(pytest);
+       size_t i;
+       int rc;
+
+       switch (t->pam_operation) {
+       case PAMTEST_GETENVLIST:
+               if (ctest->case_out.envlist == NULL) {
+                       break;
+               }
+
+               t->pam_env = PyDict_New();
+               if (t->pam_env == NULL) {
+                       return ENOMEM;
+               }
+               for (i = 0; ctest->case_out.envlist[i] != NULL; i++) {
+                       char *key = NULL;
+                       char *val = NULL;
+                       key = strdup(ctest->case_out.envlist[i]);
+                       if (key == NULL) {
+                               return ENOMEM;
+                       }
+                       val = strrchr(key, '=');
+                       if (val == NULL) {
+                               PyErr_Format(PyExc_IOError,
+                                            "Failed to parse PAM environment "
+                                            "variable");
+                               free(key);
+                               return EINVAL;
+                       }
+                       *val = '\0';
+                       rc = PyDict_SetItem(t->pam_env,
+                                           PyUnicode_FromString(key),
+                                           PyUnicode_FromString(val + 1));
+                       free(key);
+                       if (rc == -1) {
+                               return rc;
+                       }
+               }
+               break;
+       case PAMTEST_KEEPHANDLE:
+               t->pam_handle = PyCapsule_New(ctest->case_out.ph, NULL, NULL);
+               if (t->pam_handle == NULL) {
+                       return ENOMEM;
+               }
+               break;
+       default:
+               break;
+       }
+
+       return 0;
+}
+
+static int cstruct_list_to_py_tc_list(PyObject *py_test_list,
+                                     Py_ssize_t num_tests,
+                                     struct pam_testcase *test_list)
+{
+       Py_ssize_t i;
+       PyObject *py_test = NULL;
+       int rc;
+
+       for (i = 0; i < num_tests; i++) {
+               py_test = PySequence_GetItem(py_test_list, i);
+               if (py_test == NULL) {
+                       return EIO;
+               }
+
+               rc = cstruct_to_py_testcase(py_test, &test_list[i]);
+               Py_DECREF(py_test);
+               if (rc != 0) {
+                       return EIO;
+               }
+       }
+
+       return 0;
+}
+
 PyDoc_STRVAR(RunPamTest__doc__,
 "Run PAM tests\n\n"
 "This function runs PAM test cases and reports result\n"
@@ -917,7 +1019,9 @@
 "conversation for PAM_PROMPT_ECHO_ON input.\n"
 );
 
-static PyObject *pypamtest_run_pamtest(PyObject *module, PyObject *args)
+static PyObject *pypamtest_run_pamtest(PyObject *module,
+                                      PyObject *args,
+                                      PyObject *kwargs)
 {
        int ok;
        int rc;
@@ -926,21 +1030,33 @@
        PyObject *py_test_list;
        PyObject *py_echo_off = NULL;
        PyObject *py_echo_on = NULL;
+       PyObject *py_pam_handle = NULL;
        Py_ssize_t num_tests;
        struct pam_testcase *test_list;
        enum pamtest_err perr;
        struct pamtest_conv_data conv_data;
+       pam_handle_t *pam_handle = NULL;
        TestResultObject *result = NULL;
+       const char * const kwnames[] = { "username",
+                                 "service",
+                                 "tests",
+                                 "echo_off",
+                                 "echo_on",
+                                 "handle",
+                                 NULL };
 
        (void) module;  /* unused */
 
-       ok = PyArg_ParseTuple(args,
-                             discard_const_p(char, "ssO|OO"),
-                             &username,
-                             &service,
-                             &py_test_list,
-                             &py_echo_off,
-                             &py_echo_on);
+       ok = PyArg_ParseTupleAndKeywords(args,
+                                        kwargs,
+                                        discard_const_p(char, "ssO|OOO"),
+                                        discard_const_p(char *, kwnames),
+                                        &username,
+                                        &service,
+                                        &py_test_list,
+                                        &py_echo_off,
+                                        &py_echo_on,
+                                        &py_pam_handle);
        if (!ok) {
                return NULL;
        }
@@ -976,7 +1092,23 @@
                return NULL;
        }
 
-       perr = _pamtest(service, username, &conv_data, test_list, num_tests);
+       if (py_pam_handle != NULL) {
+               pam_handle = (pam_handle_t *)PyCapsule_GetPointer(py_pam_handle,
+                                                                 NULL);
+               if (pam_handle == NULL) {
+                       PyMem_Free(test_list);
+                       PyErr_Format(PyExc_IOError,
+                                    "Failed to get the pam handle pointer");
+                       return NULL;
+               }
+       }
+
+       perr = _pamtest(service,
+                       username,
+                       &conv_data,
+                       test_list,
+                       num_tests,
+                       pam_handle);
        if (perr != PAMTEST_ERR_OK) {
                free_conv_data(&conv_data);
                set_pypamtest_exception(PyExc_PamTestError,
@@ -986,6 +1118,18 @@
                PyMem_Free(test_list);
                return NULL;
        }
+
+       rc = cstruct_list_to_py_tc_list(py_test_list, num_tests, test_list);
+       if (rc != 0) {
+               if (rc == ENOMEM) {
+                       PyErr_NoMemory();
+                       return NULL;
+               } else {
+                       PyErr_Format(PyExc_IOError,
+                                    "Cannot convert C structure to python");
+                       return NULL;
+               }
+       }
        PyMem_Free(test_list);
 
        result = construct_test_conv_result(conv_data.out_info,
@@ -1003,7 +1147,7 @@
        {
                discard_const_p(char, "run_pamtest"),
                (PyCFunction) pypamtest_run_pamtest,
-               METH_VARARGS,
+               METH_VARARGS | METH_KEYWORDS,
                RunPamTest__doc__,
        },
 
@@ -1114,6 +1258,34 @@
        if (ret == -1) {
                RETURN_ON_ERROR;
        }
+
+       ret = PyModule_AddIntConstant(m,
+                                     "PAMTEST_FLAG_DELETE_CRED",
+                                     PAM_DELETE_CRED);
+       if (ret == -1) {
+               RETURN_ON_ERROR;
+       }
+
+       ret = PyModule_AddIntConstant(m,
+                                     "PAMTEST_FLAG_ESTABLISH_CRED",
+                                     PAM_ESTABLISH_CRED);
+       if (ret == -1) {
+               RETURN_ON_ERROR;
+       }
+
+       ret = PyModule_AddIntConstant(m,
+                                     "PAMTEST_FLAG_REINITIALIZE_CRED",
+                                     PAM_REINITIALIZE_CRED);
+       if (ret == -1) {
+               RETURN_ON_ERROR;
+       }
+
+       ret = PyModule_AddIntConstant(m,
+                                     "PAMTEST_FLAG_REFRESH_CRED",
+                                     PAM_REFRESH_CRED);
+       if (ret == -1) {
+               RETURN_ON_ERROR;
+       }
 
        pypam_object.type_obj = &pypamtest_test_case;
        if (PyType_Ready(pypam_object.type_obj) < 0) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pam_wrapper-1.1.3/tests/test_pam_wrapper.c 
new/pam_wrapper-1.1.4/tests/test_pam_wrapper.c
--- old/pam_wrapper-1.1.3/tests/test_pam_wrapper.c      2020-03-24 
13:41:14.000000000 +0100
+++ new/pam_wrapper-1.1.4/tests/test_pam_wrapper.c      2021-10-28 
10:37:33.000000000 +0200
@@ -267,7 +267,7 @@
        ZERO_STRUCT(conv_data);
        conv_data.in_echo_off = trinity_authtoks;
 
-       perr = run_pamtest("matrix", "trinity", &conv_data, tests);
+       perr = run_pamtest("matrix", "trinity", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 }
 
@@ -287,7 +287,7 @@
        ZERO_STRUCT(conv_data);
        conv_data.in_echo_off = empty_authtoks;
 
-       perr = run_pamtest("matrix", "trinity", &conv_data, tests);
+       perr = run_pamtest("matrix", "trinity", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 }
 
@@ -308,7 +308,7 @@
        ZERO_STRUCT(conv_data);
        conv_data.in_echo_off = trinity_authtoks;
 
-       perr = run_pamtest("matrix", "trinity", &conv_data, tests);
+       perr = run_pamtest("matrix", "trinity", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 }
 
@@ -321,7 +321,7 @@
 
        (void) state;   /* unused */
 
-       perr = run_pamtest("matrix", "trinity", NULL, tests);
+       perr = run_pamtest("matrix", "trinity", NULL, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 }
 
@@ -334,14 +334,17 @@
 
        (void) state;   /* unused */
 
-       perr = run_pamtest("matrix", "neo", NULL, tests);
+       perr = run_pamtest("matrix", "neo", NULL, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 }
 
 static inline void free_vlist(char **vlist)
 {
-       free(vlist[0]);
-       free(vlist[1]);
+       size_t i;
+
+       for (i = 0; vlist[i] != NULL; i++) {
+               free(vlist[i]);
+       }
        free(vlist);
 }
 
@@ -455,7 +458,7 @@
 
        (void) state;   /* unused */
 
-       perr = run_pamtest("matrix", "trinity", NULL, tests);
+       perr = run_pamtest("matrix", "trinity", NULL, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 
        v = string_in_list(tests[1].case_out.envlist, "HOMEDIR");
@@ -497,7 +500,7 @@
        ZERO_STRUCT(conv_data);
        conv_data.in_echo_off = trinity_new_authtoks;
 
-       perr = run_pamtest("matrix", "trinity", &conv_data, tests);
+       perr = run_pamtest("matrix", "trinity", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 }
 
@@ -520,7 +523,7 @@
        ZERO_STRUCT(conv_data);
        conv_data.in_echo_off = trinity_new_authtoks;
 
-       perr = run_pamtest("matrix", "trinity", &conv_data, tests);
+       perr = run_pamtest("matrix", "trinity", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 }
 
@@ -543,7 +546,7 @@
        ZERO_STRUCT(conv_data);
        conv_data.in_echo_off = trinity_new_authtoks;
 
-       perr = run_pamtest("matrix", "trinity", &conv_data, tests);
+       perr = run_pamtest("matrix", "trinity", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 }
 
@@ -559,7 +562,7 @@
 
        (void) state;   /* unused */
 
-       perr = run_pamtest("matrix", "trinity", NULL, tests);
+       perr = run_pamtest("matrix", "trinity", NULL, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 
        /* environment is clean before setcred */
@@ -770,7 +773,7 @@
        conv_data.in_echo_on = trinity_authtoks;
        conv_data.out_info = info_arr;
 
-       perr = run_pamtest("matrix_opt", "trinity_ro", &conv_data, tests);
+       perr = run_pamtest("matrix_opt", "trinity_ro", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 
        assert_string_equal(auth_info_msg, "Authentication succeeded");
@@ -799,7 +802,7 @@
        conv_data.in_echo_on = trinity_authtoks;
        conv_data.out_err = err_arr;
 
-       perr = run_pamtest("matrix_opt", "trinity_ro", &conv_data, tests);
+       perr = run_pamtest("matrix_opt", "trinity_ro", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 
        assert_string_equal(auth_err_msg, "Authentication failed");
@@ -900,7 +903,7 @@
        test_setenv("PAM_AUTHTOK_TYPE");
 #endif
 
-       perr = run_pamtest("pwrap_get_set", "trinity", NULL, tests);
+       perr = run_pamtest("pwrap_get_set", "trinity", NULL, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 
        /* PAM_SERVICE is a special case, Linux's libpam lowercases it.
@@ -948,7 +951,7 @@
        ZERO_STRUCT(conv_data);
        conv_data.in_echo_off = trinity_authtoks;
 
-       perr = run_pamtest("matrix", "trinity", &conv_data, tests);
+       perr = run_pamtest("matrix", "trinity", &conv_data, tests, NULL);
        assert_int_equal(perr, PAMTEST_ERR_OK);
 
        assert_non_null(tests[1].case_out.ph);
@@ -975,14 +978,15 @@
        ZERO_STRUCT(conv_data);
        conv_data.in_echo_off = trinity_authtoks;
 
-       perr = run_pamtest("matrix", "trinity", &conv_data, tests);
+       perr = run_pamtest("matrix", "trinity", &conv_data, tests, NULL);
        assert_int_not_equal(perr, PAMTEST_ERR_OK);
 
        failed_tc = pamtest_failed_case(tests);
        assert_ptr_equal(failed_tc, &tests[0]);
 }
 
-int main(void) {
+int main(int argc, char *argv[])
+{
        int rc;
 
        const struct CMUnitTest init_tests[] = {
@@ -1053,6 +1057,10 @@
                cmocka_unit_test(test_get_set),
        };
 
+       if (argc == 2) {
+               cmocka_set_test_filter(argv[1]);
+       }
+
        rc = cmocka_run_group_tests(init_tests, NULL, NULL);
 
        return rc;

Reply via email to