Hello community, here is the log from the commit of package pam_wrapper for openSUSE:Factory checked in at 2018-02-23 15:29:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/pam_wrapper (Old) and /work/SRC/openSUSE:Factory/.pam_wrapper.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "pam_wrapper" Fri Feb 23 15:29:49 2018 rev:6 rq:579098 version:1.0.5 Changes: -------- --- /work/SRC/openSUSE:Factory/pam_wrapper/pam_wrapper.changes 2018-02-14 10:51:57.988939957 +0100 +++ /work/SRC/openSUSE:Factory/.pam_wrapper.new/pam_wrapper.changes 2018-02-23 15:29:52.718347933 +0100 @@ -1,0 +2,12 @@ +Thu Feb 22 15:56:44 UTC 2018 - [email protected] + +- Update to version 1.0.5 + * Added support to build python2 and python3 module at the same time + * Improved pam test directory creating + * Fixed python 2.6 compatibilty + * Fixed some build issues on FreeBSD + * Fix build on OpenBSD + * Fix a resource leak +- Removed pam_wrapper-1.0.3-build-python2-and-python3-modules.patch + +------------------------------------------------------------------- Old: ---- pam_wrapper-1.0.3-build-python2-and-python3-modules.patch pam_wrapper-1.0.3.tar.gz New: ---- pam_wrapper-1.0.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ pam_wrapper.spec ++++++ --- /var/tmp/diff_new_pack.YyWOin/_old 2018-02-23 15:29:53.546318019 +0100 +++ /var/tmp/diff_new_pack.YyWOin/_new 2018-02-23 15:29:53.546318019 +0100 @@ -24,7 +24,7 @@ ############################# NOTE ################################## Name: pam_wrapper -Version: 1.0.3 +Version: 1.0.5 Release: 0 Summary: A tool to test PAM applications and PAM modules @@ -35,9 +35,6 @@ Source0: https://ftp.samba.org/pub/cwrap/%{name}-%{version}.tar.gz Source1: %{name}-rpmlintrc -# PATCH-FIX-UPSTREAM Build python2 and python3 modules if possible -Patch0: pam_wrapper-1.0.3-build-python2-and-python3-modules.patch - BuildRequires: cmake BuildRequires: doxygen BuildRequires: libcmocka-devel @@ -119,8 +116,6 @@ %prep %setup -q -%patch0 -p1 - %build %cmake \ -DUNIT_TESTING=ON ++++++ pam_wrapper-1.0.3.tar.gz -> pam_wrapper-1.0.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/0001-cmake-Build-python2-and-python3-modules-if-possible.patch new/pam_wrapper-1.0.5/0001-cmake-Build-python2-and-python3-modules-if-possible.patch --- old/pam_wrapper-1.0.3/0001-cmake-Build-python2-and-python3-modules-if-possible.patch 1970-01-01 01:00:00.000000000 +0100 +++ new/pam_wrapper-1.0.5/0001-cmake-Build-python2-and-python3-modules-if-possible.patch 2018-02-13 10:52:10.000000000 +0100 @@ -0,0 +1,236 @@ +From 9beb9f9aaa223864128fd8222f0f92ba8ae697b7 Mon Sep 17 00:00:00 2001 +From: Andreas Schneider <[email protected]> +Date: Wed, 22 Nov 2017 15:27:44 +0100 +Subject: [PATCH 1/2] cmake: Improve PAM_WRAPPER_LOACATION + +Signed-off-by: Andreas Schneider <[email protected]> +Reviewed-by: Ralph Boehme <[email protected]> +--- + src/CMakeLists.txt | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 713625b..76a87d6 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -74,8 +74,4 @@ if (PYTHONLIBS_FOUND) + endif() + + # This needs to be at the end +-if (POLICY CMP0026) +- cmake_policy(SET CMP0026 OLD) +-endif() +-get_target_property(PAM_WRAPPER_LOCATION pam_wrapper LOCATION) +-set(PAM_WRAPPER_LOCATION ${PAM_WRAPPER_LOCATION} PARENT_SCOPE) ++set(PAM_WRAPPER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}pam_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE) +-- +2.16.1 + + +From 5c36d4284918a3fcc1c58f29f01ca64c65a66fa7 Mon Sep 17 00:00:00 2001 +From: Andreas Schneider <[email protected]> +Date: Mon, 12 Feb 2018 12:01:22 +0100 +Subject: [PATCH 2/2] cmake: Build python2 and python3 modules if possible + +Signed-off-by: Andreas Schneider <[email protected]> +Reviewed-by: Ralph Boehme <[email protected]> +--- + CMakeLists.txt | 5 ----- + src/CMakeLists.txt | 4 +--- + src/python/CMakeLists.txt | 15 ++------------- + src/python/python2/CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ + src/python/python3/CMakeLists.txt | 33 +++++++++++++++++++++++++++++++++ + tests/CMakeLists.txt | 29 ++++++++++++++++++++++------- + tests/pypamtest_test.py | 5 ++++- + 7 files changed, 95 insertions(+), 29 deletions(-) + create mode 100644 src/python/python2/CMakeLists.txt + create mode 100644 src/python/python3/CMakeLists.txt + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f03a137..af00610 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -46,11 +46,6 @@ macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source buil + set(CMAKE_THREAD_PREFER_PTHREADS ON) + find_package(Threads) + +-find_package(PythonInterp) +-set(Python_ADDITIONAL_VERSIONS 2.6 2.7 3.3 3.4 3.6) +-find_package(PythonLibs) +-find_package(PythonSiteLibs) +- + # config.h checks + include(ConfigureChecks.cmake) + configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 76a87d6..e3a1efd 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -69,9 +69,7 @@ install(TARGETS pamtest + ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) + + add_subdirectory(modules) +-if (PYTHONLIBS_FOUND) +- add_subdirectory(python) +-endif() ++add_subdirectory(python) + + # This needs to be at the end + set(PAM_WRAPPER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}pam_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE) +diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt +index cbee2a6..3394a84 100644 +--- a/src/python/CMakeLists.txt ++++ b/src/python/CMakeLists.txt +@@ -1,15 +1,4 @@ + project(pypamtest C) + +-include_directories(${CMAKE_BINARY_DIR}) +-include_directories(${pam_wrapper-headers_DIR}) +-include_directories(${PYTHON_INCLUDE_DIR}) +- +-python_add_module(pypamtest pypamtest.c) +-target_link_libraries(pypamtest pamtest ${PYTHON_LIBRARY}) +- +-install( +- TARGETS +- pypamtest +- DESTINATION +- ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB} +-) ++add_subdirectory(python2) ++add_subdirectory(python3) +diff --git a/src/python/python2/CMakeLists.txt b/src/python/python2/CMakeLists.txt +new file mode 100644 +index 0000000..faceec3 +--- /dev/null ++++ b/src/python/python2/CMakeLists.txt +@@ -0,0 +1,33 @@ ++project(python2-pamtest C) ++ ++unset(PYTHON_EXECUTABLE CACHE) ++unset(PYTHON_INCLUDE_DIR CACHE) ++unset(PYTHON_LIBRARY CACHE) ++unset(PYTHON_SITELIB CACHE) ++unset(PYTHONLIBS_FOUND CACHE) ++unset(PYTHONLIBS_VERSION_STRING CACHE) ++ ++set(Python_ADDITIONAL_VERSIONS 2.7 2.6) ++find_package(PythonLibs) ++find_package(PythonInterp) ++find_package(PythonSiteLibs) ++ ++if (PYTHONLIBS_FOUND) ++ set(PYTHON2_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "PYTHON2_EXECUTABLE") ++ set(PYTHON2_INCLUDE_DIR ${PYTHON_INCLUDE_DIR}) ++ set(PYTHON2_LIBRARY ${PYTHON_LIBRARY}) ++ set(PYTHON2_SITELIB ${PYTHON_SITELIB}) ++ ++ include_directories(${CMAKE_BINARY_DIR}) ++ include_directories(${pam_wrapper-headers_DIR}) ++ include_directories(${PYTHON2_INCLUDE_DIR}) ++ ++ python_add_module(python2-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c) ++ target_link_libraries(python2-pamtest pamtest ${PYTHON2_LIBRARY}) ++ set_target_properties(python2-pamtest PROPERTIES OUTPUT_NAME "pypamtest") ++ ++ install(TARGETS ++ python2-pamtest ++ DESTINATION ++ ${CMAKE_INSTALL_PREFIX}/${PYTHON2_SITELIB}) ++endif() +diff --git a/src/python/python3/CMakeLists.txt b/src/python/python3/CMakeLists.txt +new file mode 100644 +index 0000000..1e1599b +--- /dev/null ++++ b/src/python/python3/CMakeLists.txt +@@ -0,0 +1,33 @@ ++project(python3-pamtest C) ++ ++unset(PYTHON_EXECUTABLE CACHE) ++unset(PYTHON_INCLUDE_DIR CACHE) ++unset(PYTHON_LIBRARY CACHE) ++unset(PYTHON_SITELIB CACHE) ++unset(PYTHONLIBS_FOUND CACHE) ++unset(PYTHONLIBS_VERSION_STRING CACHE) ++ ++set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6) ++find_package(PythonLibs) ++find_package(PythonInterp) ++find_package(PythonSiteLibs) ++ ++if (PYTHONLIBS_FOUND) ++ set(PYTHON3_LIBRARY ${PYTHON_LIBRARY}) ++ set(PYTHON3_INCLUDE_DIR ${PYTHON_INCLUDE_DIR}) ++ set(PYTHON3_SITELIB ${PYTHON_SITELIB}) ++ set(PYTHON3_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "PYTHON3_EXECUTABLE") ++ ++ include_directories(${CMAKE_BINARY_DIR}) ++ include_directories(${pam_wrapper-headers_DIR}) ++ include_directories(${PYTHON3_INCLUDE_DIR}) ++ ++ python_add_module(python3-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c) ++ target_link_libraries(python3-pamtest pamtest ${PYTHON3_LIBRARY}) ++ set_target_properties(python3-pamtest PROPERTIES OUTPUT_NAME "pypamtest") ++ ++ install(TARGETS ++ python3-pamtest ++ DESTINATION ++ ${CMAKE_INSTALL_PREFIX}/${PYTHON3_SITELIB}) ++endif() +diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt +index 30f0eb2..997c15e 100644 +--- a/tests/CMakeLists.txt ++++ b/tests/CMakeLists.txt +@@ -47,11 +47,26 @@ set_property( + PROPERTY + ENVIRONMENT ${TEST_ENVIRONMENT}) + +-if (PYTHONLIBS_FOUND) +- add_test(pypamtest_test ${CMAKE_CURRENT_SOURCE_DIR}/pypamtest_test.py) +- set_property( +- TEST +- pypamtest_test +- PROPERTY +- ENVIRONMENT ${TEST_ENVIRONMENT}) ++if (PYTHON2_EXECUTABLE) ++ add_test(NAME ++ py2pamtest_test ++ COMMAND ++ ${PYTHON2_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pypamtest_test.py) ++ ++ set_property(TEST ++ py2pamtest_test ++ PROPERTY ++ ENVIRONMENT ${TEST_ENVIRONMENT}) ++endif() ++ ++if (PYTHON3_EXECUTABLE) ++ add_test(NAME ++ py3pamtest_test ++ COMMAND ++ ${PYTHON3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pypamtest_test.py) ++ ++ set_property(TEST ++ py3pamtest_test ++ PROPERTY ++ ENVIRONMENT ${TEST_ENVIRONMENT}) + endif() +diff --git a/tests/pypamtest_test.py b/tests/pypamtest_test.py +index 2c74c0b..32ef65d 100755 +--- a/tests/pypamtest_test.py ++++ b/tests/pypamtest_test.py +@@ -16,7 +16,10 @@ class PyPamTestCase(unittest.TestCase): + class PyPamTestImport(unittest.TestCase): + def setUp(self): + " Make sure we load the in-tree module " +- self.modpath = os.path.join(os.getcwd(), "../src/python") ++ if sys.hexversion >= 0x3000000: ++ self.modpath = os.path.join(os.getcwd(), "../src/python/python3") ++ else: ++ self.modpath = os.path.join(os.getcwd(), "../src/python/python2") + self.system_path = sys.path[:] + sys.path = [ self.modpath ] + +-- +2.16.1 + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/CMakeLists.txt new/pam_wrapper-1.0.5/CMakeLists.txt --- old/pam_wrapper-1.0.3/CMakeLists.txt 2017-04-06 13:42:21.000000000 +0200 +++ new/pam_wrapper-1.0.5/CMakeLists.txt 2018-02-22 16:46:19.000000000 +0100 @@ -8,7 +8,7 @@ set(APPLICATION_VERSION_MAJOR "1") set(APPLICATION_VERSION_MINOR "0") -set(APPLICATION_VERSION_PATCH "3") +set(APPLICATION_VERSION_PATCH "5") set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}") @@ -19,10 +19,10 @@ # Increment AGE. Set REVISION to 0 # If the source code was changed, but there were no interface changes: # Increment REVISION. -set(LIBRARY_VERSION "0.0.2") +set(LIBRARY_VERSION "0.0.3") set(LIBRARY_SOVERSION "0") -set(PAMTEST_LIBRARY_VERSION "0.0.2") +set(PAMTEST_LIBRARY_VERSION "0.0.3") set(PAMTEST_LIBRARY_SOVERSION "0") # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked @@ -46,11 +46,6 @@ set(CMAKE_THREAD_PREFER_PTHREADS ON) find_package(Threads) -find_package(PythonInterp) -set(Python_ADDITIONAL_VERSIONS 2.6 2.7 3.3 3.4 3.6) -find_package(PythonLibs) -find_package(PythonSiteLibs) - # config.h checks include(ConfigureChecks.cmake) configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/ChangeLog new/pam_wrapper-1.0.5/ChangeLog --- old/pam_wrapper-1.0.3/ChangeLog 2017-04-06 13:42:21.000000000 +0200 +++ new/pam_wrapper-1.0.5/ChangeLog 2018-02-22 16:46:19.000000000 +0100 @@ -1,6 +1,16 @@ ChangeLog ========== +version 1.0.5 (released 2018-02-22) + * Added support to build python2 and python3 module at the same time + * Improved pam test directory creating + * Fixed python 2.6 compatibilty + * Fixed some build issues on FreeBSD + +version 1.0.4 (released 2017-05-15) + * Fix build on OpenBSD + * Fix a resource leak + version 1.0.3 (released 2017-04-06) * Fixed some build issues with strict compiler flags * Logging to syslog is disabled by default diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/src/CMakeLists.txt new/pam_wrapper-1.0.5/src/CMakeLists.txt --- old/pam_wrapper-1.0.3/src/CMakeLists.txt 2016-01-08 13:19:50.000000000 +0100 +++ new/pam_wrapper-1.0.5/src/CMakeLists.txt 2018-02-13 08:55:46.000000000 +0100 @@ -69,13 +69,7 @@ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) add_subdirectory(modules) -if (PYTHONLIBS_FOUND) - add_subdirectory(python) -endif() +add_subdirectory(python) # This needs to be at the end -if (POLICY CMP0026) - cmake_policy(SET CMP0026 OLD) -endif() -get_target_property(PAM_WRAPPER_LOCATION pam_wrapper LOCATION) -set(PAM_WRAPPER_LOCATION ${PAM_WRAPPER_LOCATION} PARENT_SCOPE) +set(PAM_WRAPPER_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}pam_wrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" PARENT_SCOPE) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/src/pam_wrapper.c new/pam_wrapper-1.0.5/src/pam_wrapper.c --- old/pam_wrapper-1.0.3/src/pam_wrapper.c 2017-04-06 13:42:21.000000000 +0200 +++ new/pam_wrapper-1.0.5/src/pam_wrapper.c 2018-02-22 16:46:19.000000000 +0100 @@ -34,6 +34,7 @@ #include <libgen.h> #include <signal.h> #include <limits.h> +#include <ctype.h> #include <ftw.h> @@ -508,6 +509,7 @@ return pwrap.libpam.symbols._libpam_pam_strerror.f(discard_const_p(pam_handle_t, pamh), errnum); } +#ifdef HAVE_PAM_VSYSLOG static void libpam_pam_vsyslog(const pam_handle_t *pamh, int priority, const char *fmt, @@ -520,6 +522,7 @@ fmt, args); } +#endif /* HAVE_PAM_VSYSLOG */ /********************************************************* * PWRAP INIT @@ -551,7 +554,8 @@ if (mode == 0) { rc = fstat(srcfd, &sb); if (rc != 0) { - return -1; + rc = -1; + goto out; } mode = sb.st_mode; } @@ -757,13 +761,15 @@ char tmp_config_dir[] = "/tmp/pam.X"; size_t len = strlen(tmp_config_dir); const char *env; - uint32_t i; + struct stat sb; int rc; + unsigned i; char pam_library[128] = { 0 }; char libpam_path[1024] = { 0 }; ssize_t ret; FILE *pidfile; char pidfile_path[1024] = { 0 }; + char letter; if (!pam_wrapper_enabled()) { return; @@ -773,33 +779,36 @@ return; } - PWRAP_LOG(PWRAP_LOG_DEBUG, "Initialize pam_wrapper"); - - for (i = 0; i < 36; i++) { - struct stat sb; - char c; - - if (i < 10) { - c = (char)(i + 48); - } else { - c = (char)(i + 87); + /* + * The name is selected to match/replace /etc/pam.d + * We start from a random alphanum trying letters until + * an available directory is found. + */ + letter = 48 + (getpid() % 70); + for (i = 0; i < 127; i++) { + if (isalpha(letter) || isdigit(letter)) { + tmp_config_dir[len - 1] = letter; + + rc = lstat(tmp_config_dir, &sb); + if (rc == 0) { + PWRAP_LOG(PWRAP_LOG_TRACE, + "Check if pam_wrapper dir %s is a " + "stale directory", + tmp_config_dir); + pwrap_clean_stale_dirs(tmp_config_dir); + } else if (rc < 0) { + if (errno != ENOENT) { + continue; + } + break; /* found */ + } } - tmp_config_dir[len - 1] = c; - rc = lstat(tmp_config_dir, &sb); - if (rc == 0) { - PWRAP_LOG(PWRAP_LOG_TRACE, - "Check if pam_wrapper dir %s is a " - "stale directory", - tmp_config_dir); - pwrap_clean_stale_dirs(tmp_config_dir); - continue; - } else if (errno == ENOENT) { - break; - } + letter++; + letter %= 127; } - if (i == 36) { + if (i == 127) { PWRAP_LOG(PWRAP_LOG_ERROR, "Failed to find a possible path to create " "pam_wrapper config dir: %s", @@ -807,6 +816,10 @@ exit(1); } + PWRAP_LOG(PWRAP_LOG_DEBUG, "Initialize pam_wrapper"); + + pwrap_clean_stale_dirs(tmp_config_dir); + pwrap.config_dir = strdup(tmp_config_dir); if (pwrap.config_dir == NULL) { PWRAP_LOG(PWRAP_LOG_ERROR, @@ -1484,6 +1497,7 @@ errnum); } +#if defined(HAVE_PAM_VSYSLOG) || defined(HAVE_PAM_SYSLOG) static void pwrap_pam_vsyslog(const pam_handle_t *pamh, int priority, const char *fmt, @@ -1500,11 +1514,13 @@ PWRAP_LOG(PWRAP_LOG_TRACE, "pwrap_pam_vsyslog called"); +#ifdef HAVE_PAM_VSYSLOG d = getenv("PAM_WRAPPER_USE_SYSLOG"); if (d != NULL && d[0] == '1') { libpam_pam_vsyslog(pamh, priority, fmt, args); return; } +#endif /* HAVE_PAM_VSYSLOG */ switch(priority) { case 0: /* LOG_EMERG */ @@ -1530,6 +1546,7 @@ pwrap_vlog(dbglvl, syslog_str, fmt, args); } +#endif /* defined(HAVE_PAM_VSYSLOG) || defined(HAVE_PAM_SYSLOG) */ #ifdef HAVE_PAM_VSYSLOG void pam_vsyslog(const pam_handle_t *pamh, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/src/python/CMakeLists.txt new/pam_wrapper-1.0.5/src/python/CMakeLists.txt --- old/pam_wrapper-1.0.3/src/python/CMakeLists.txt 2016-01-18 11:11:16.000000000 +0100 +++ new/pam_wrapper-1.0.5/src/python/CMakeLists.txt 2018-02-13 08:55:46.000000000 +0100 @@ -1,15 +1,4 @@ project(pypamtest C) -include_directories(${CMAKE_BINARY_DIR}) -include_directories(${pam_wrapper-headers_DIR}) -include_directories(${PYTHON_INCLUDE_DIR}) - -python_add_module(pypamtest pypamtest.c) -target_link_libraries(pypamtest pamtest ${PYTHON_LIBRARY}) - -install( - TARGETS - pypamtest - DESTINATION - ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB} -) +add_subdirectory(python2) +add_subdirectory(python3) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/src/python/pypamtest.c new/pam_wrapper-1.0.5/src/python/pypamtest.c --- old/pam_wrapper-1.0.3/src/python/pypamtest.c 2017-04-06 09:20:44.000000000 +0200 +++ new/pam_wrapper-1.0.5/src/python/pypamtest.c 2017-11-23 11:51:16.000000000 +0100 @@ -24,8 +24,8 @@ #define PYTHON_MODULE_NAME "pypamtest" #ifndef discard_const_p -#if defined(__intptr_t_defined) || defined(HAVE_INTPTR_T) -# define discard_const_p(type, ptr) ((type *)((intptr_t)(ptr))) +#if defined(__intptr_t_defined) || defined(HAVE_UINTPTR_T) +# define discard_const_p(type, ptr) ((type *)((uintptr_t)(ptr))) #else # define discard_const_p(type, ptr) ((type *)(ptr)) #endif @@ -67,9 +67,9 @@ *** helper functions **********************************************************/ -static const char *repr_fmt = "{ pam_operation [%d] " - "expected_rv [%d] " - "flags [%d] }"; +#define REPR_FMT "{ pam_operation [%d] " \ + "expected_rv [%d] " \ + "flags [%d] }" static char *py_strdup(const char *string) { @@ -267,7 +267,7 @@ size_t num_tests) { PyObject *obj = NULL; - /* repr_fmt is fixed and contains just %d expansions, so this is safe */ + /* REPR_FMT contains just %d expansions, so this is safe */ char test_repr[256] = { '\0' }; union { char *str; @@ -286,7 +286,7 @@ if (perr == PAMTEST_ERR_CASE) { failed = _pamtest_failed_case(tests, num_tests); if (failed) { - snprintf(test_repr, sizeof(test_repr), repr_fmt, + snprintf(test_repr, sizeof(test_repr), REPR_FMT, failed->pam_operation, failed->expected_rv, failed->flags); @@ -422,7 +422,7 @@ */ static PyObject *TestCase_repr(TestCaseObject *self) { - return PyUnicode_FromFormat(repr_fmt, + return PyUnicode_FromFormat(REPR_FMT, self->pam_operation, self->expected_rv, self->flags); @@ -1004,12 +1004,14 @@ *** Initialize the module **********************************************************/ +#if PY_VERSION_HEX >= 0x02070000 /* >= 2.7.0 */ PyDoc_STRVAR(PamTestError__doc__, "pypamtest specific exception\n\n" "This exception is raised if the _pamtest() function fails. If _pamtest() " "returns PAMTEST_ERR_CASE (a test case returns unexpected error code), then " "the exception also details which test case failed." ); +#endif #if IS_PYTHON3 PyMODINIT_FUNC PyInit_pypamtest(void) @@ -1034,10 +1036,17 @@ pypamtest_module_methods); #endif +#if PY_VERSION_HEX >= 0x02070000 /* >= 2.7.0 */ PyExc_PamTestError = PyErr_NewExceptionWithDoc(discard_const_p(char, "pypamtest.PamTestError"), PamTestError__doc__, PyExc_EnvironmentError, NULL); +#else /* < 2.7.0 */ + PyExc_PamTestError = PyErr_NewException(discard_const_p(char, "pypamtest.PamTestError"), + PyExc_EnvironmentError, + NULL); +#endif + if (PyExc_PamTestError == NULL) { RETURN_ON_ERROR; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/src/python/python2/CMakeLists.txt new/pam_wrapper-1.0.5/src/python/python2/CMakeLists.txt --- old/pam_wrapper-1.0.3/src/python/python2/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/pam_wrapper-1.0.5/src/python/python2/CMakeLists.txt 2018-02-13 08:55:46.000000000 +0100 @@ -0,0 +1,33 @@ +project(python2-pamtest C) + +unset(PYTHON_EXECUTABLE CACHE) +unset(PYTHON_INCLUDE_DIR CACHE) +unset(PYTHON_LIBRARY CACHE) +unset(PYTHON_SITELIB CACHE) +unset(PYTHONLIBS_FOUND CACHE) +unset(PYTHONLIBS_VERSION_STRING CACHE) + +set(Python_ADDITIONAL_VERSIONS 2.7 2.6) +find_package(PythonLibs) +find_package(PythonInterp) +find_package(PythonSiteLibs) + +if (PYTHONLIBS_FOUND) + set(PYTHON2_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "PYTHON2_EXECUTABLE") + set(PYTHON2_INCLUDE_DIR ${PYTHON_INCLUDE_DIR}) + set(PYTHON2_LIBRARY ${PYTHON_LIBRARY}) + set(PYTHON2_SITELIB ${PYTHON_SITELIB}) + + include_directories(${CMAKE_BINARY_DIR}) + include_directories(${pam_wrapper-headers_DIR}) + include_directories(${PYTHON2_INCLUDE_DIR}) + + python_add_module(python2-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c) + target_link_libraries(python2-pamtest pamtest ${PYTHON2_LIBRARY}) + set_target_properties(python2-pamtest PROPERTIES OUTPUT_NAME "pypamtest") + + install(TARGETS + python2-pamtest + DESTINATION + ${CMAKE_INSTALL_PREFIX}/${PYTHON2_SITELIB}) +endif() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/src/python/python3/CMakeLists.txt new/pam_wrapper-1.0.5/src/python/python3/CMakeLists.txt --- old/pam_wrapper-1.0.3/src/python/python3/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/pam_wrapper-1.0.5/src/python/python3/CMakeLists.txt 2018-02-13 08:55:46.000000000 +0100 @@ -0,0 +1,33 @@ +project(python3-pamtest C) + +unset(PYTHON_EXECUTABLE CACHE) +unset(PYTHON_INCLUDE_DIR CACHE) +unset(PYTHON_LIBRARY CACHE) +unset(PYTHON_SITELIB CACHE) +unset(PYTHONLIBS_FOUND CACHE) +unset(PYTHONLIBS_VERSION_STRING CACHE) + +set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6) +find_package(PythonLibs) +find_package(PythonInterp) +find_package(PythonSiteLibs) + +if (PYTHONLIBS_FOUND) + set(PYTHON3_LIBRARY ${PYTHON_LIBRARY}) + set(PYTHON3_INCLUDE_DIR ${PYTHON_INCLUDE_DIR}) + set(PYTHON3_SITELIB ${PYTHON_SITELIB}) + set(PYTHON3_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "PYTHON3_EXECUTABLE") + + include_directories(${CMAKE_BINARY_DIR}) + include_directories(${pam_wrapper-headers_DIR}) + include_directories(${PYTHON3_INCLUDE_DIR}) + + python_add_module(python3-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c) + target_link_libraries(python3-pamtest pamtest ${PYTHON3_LIBRARY}) + set_target_properties(python3-pamtest PROPERTIES OUTPUT_NAME "pypamtest") + + install(TARGETS + python3-pamtest + DESTINATION + ${CMAKE_INSTALL_PREFIX}/${PYTHON3_SITELIB}) +endif() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/tests/CMakeLists.txt new/pam_wrapper-1.0.5/tests/CMakeLists.txt --- old/pam_wrapper-1.0.3/tests/CMakeLists.txt 2015-12-10 21:13:37.000000000 +0100 +++ new/pam_wrapper-1.0.5/tests/CMakeLists.txt 2018-02-13 08:55:46.000000000 +0100 @@ -47,11 +47,26 @@ PROPERTY ENVIRONMENT ${TEST_ENVIRONMENT}) -if (PYTHONLIBS_FOUND) - add_test(pypamtest_test ${CMAKE_CURRENT_SOURCE_DIR}/pypamtest_test.py) - set_property( - TEST - pypamtest_test - PROPERTY - ENVIRONMENT ${TEST_ENVIRONMENT}) +if (PYTHON2_EXECUTABLE) + add_test(NAME + py2pamtest_test + COMMAND + ${PYTHON2_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pypamtest_test.py) + + set_property(TEST + py2pamtest_test + PROPERTY + ENVIRONMENT ${TEST_ENVIRONMENT}) +endif() + +if (PYTHON3_EXECUTABLE) + add_test(NAME + py3pamtest_test + COMMAND + ${PYTHON3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pypamtest_test.py) + + set_property(TEST + py3pamtest_test + PROPERTY + ENVIRONMENT ${TEST_ENVIRONMENT}) endif() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pam_wrapper-1.0.3/tests/pypamtest_test.py new/pam_wrapper-1.0.5/tests/pypamtest_test.py --- old/pam_wrapper-1.0.3/tests/pypamtest_test.py 2015-12-10 16:38:34.000000000 +0100 +++ new/pam_wrapper-1.0.5/tests/pypamtest_test.py 2018-02-13 08:55:46.000000000 +0100 @@ -16,7 +16,10 @@ class PyPamTestImport(unittest.TestCase): def setUp(self): " Make sure we load the in-tree module " - self.modpath = os.path.join(os.getcwd(), "../src/python") + if sys.hexversion >= 0x3000000: + self.modpath = os.path.join(os.getcwd(), "../src/python/python3") + else: + self.modpath = os.path.join(os.getcwd(), "../src/python/python2") self.system_path = sys.path[:] sys.path = [ self.modpath ]
