.gear/pam_wrapper.spec | 135 +++++++++++++++++++++ .gear/rules | 3 + .../tags/be57e84778893d9933a9e02deaf94c5fcc79bee7 | 30 +++++ .gear/tags/list | 1 + .gear/upstream/filter-tag | 3 + .gear/upstream/remotes | 3 + .gear/upstream/transform-tag | 3 + .gitignore | 1 - ConfigureChecks.cmake | 18 ++- config.h.cmake | 2 + src/pam_wrapper.c | 32 ++++- 11 files changed, 223 insertions(+), 8 deletions(-) diff --git a/.gear/pam_wrapper.spec b/.gear/pam_wrapper.spec new file mode 100644 index 0000000..7101592 --- /dev/null +++ b/.gear/pam_wrapper.spec @@ -0,0 +1,135 @@ +Name: pam_wrapper +Version: 1.1.4 +Release: alt1 +Summary: A tool to test PAM applications and PAM modules +License: GPLv3+ +Url: http://cwrap.org/ +# git://git.samba.org/pam_wrapper.git +Source0: %name-%version.tar +Patch0: %name-%version-%release.patch +Group: Development/C +BuildRequires: cmake +BuildRequires: libcmocka-devel +BuildRequires: python3-devel +BuildRequires: pam-devel +BuildRequires: doxygen +BuildRequires: git +BuildRequires: ctest + +%description +This component of cwrap allows you to either test your PAM (Linux-PAM +and OpenPAM) application or module. + +For testing PAM applications, simple PAM module called pam_matrix is +included. If you plan to test a PAM module you can use the pamtest library, +which simplifies testing of modules. You can combine it with the cmocka +unit testing framework or you can use the provided Python bindings to +write tests for your module in Python. + +%package -n libpamtest +Summary: A tool to test PAM applications and PAM modules +License: GPLv3+ +Group:Development/C +Requires: pam_wrapper = %version-%release + +%description -n libpamtest +If you plan to test a PAM module you can use this library, which simplifies +testing of modules. + +%package -n libpamtest-devel +Summary: A tool to test PAM applications and PAM modules +License: GPLv3+ +Group: Development/C +Requires: pam_wrapper = %version-%release +Requires: libpamtest = %version-%release + + +%description -n libpamtest-devel +If you plan to develop tests for a PAM module you can use this library, +which simplifies testing of modules. This sub package includes the header +files for libpamtest. + +%package -n libpamtest-doc +Summary: The libpamtest API documentation +Group: Development/C +License: GPLv3+ + +%description -n libpamtest-doc +Documentation for libpamtest development. + +%package -n python3-module-libpamtest +Summary: A python wrapper for libpamtest +License: GPLv3+ +Group: Development/C +Requires: pam_wrapper = %version-%release +Requires: libpamtest = %version-%release + +%description -n python3-module-libpamtest +If you plan to develop python tests for a PAM module you can use this +library, which simplifies testing of modules. This subpackage includes +the header files for libpamtest + +%prep +%setup +%patch0 -p1 + +%build +%cmake \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DAPPLICATION_VERSION=%version \ + -DUNIT_TESTING=ON + +%cmake_build +%cmake_build --target doc + +%install +%cmake_install + +%check +export LD_LIBRARY_PATH=%buildroot%_libdir +%cmake_build --target test + +%files +%_libdir/libpam_wrapper.so* +%_libdir/pkgconfig/pam_wrapper.pc +%dir %_libdir/cmake/pam_wrapper +%_libdir/cmake/pam_wrapper/pam_wrapper-config-version.cmake +%_libdir/cmake/pam_wrapper/pam_wrapper-config.cmake +%_libdir/pam_wrapper/pam_chatty.so +%_libdir/pam_wrapper/pam_matrix.so +%_libdir/pam_wrapper/pam_get_items.so +%_libdir/pam_wrapper/pam_set_items.so +%_mandir/man1/pam_wrapper.1* +%_mandir/man8/pam_chatty.8* +%_mandir/man8/pam_matrix.8* +%_mandir/man8/pam_get_items.8* +%_mandir/man8/pam_set_items.8* + +%files -n libpamtest +%_libdir/libpamtest.so.* + +%files -n libpamtest-devel +%_libdir/libpamtest.so +%_libdir/pkgconfig/libpamtest.pc +%dir %_libdir/cmake/pamtest +%_libdir/cmake/pamtest/pamtest-config-relwithdebinfo.cmake +%_libdir/cmake/pamtest/pamtest-config-version.cmake +%_libdir/cmake/pamtest/pamtest-config.cmake +%_includedir/libpamtest.h + +%files -n libpamtest-doc +%doc %_cmake__builddir/doc/html + +%files -n python3-module-libpamtest +%python3_sitelibdir/pypamtest.so + +%changelog +* Mon Nov 01 2021 Evgeny Sinelnikov 1.1.4-alt1 +- new version 1.1.4 + +* Wed Apr 28 2021 Arseny Maslennikov 1.1.3-alt1.1 +- NMU: spec: adapted to new cmake macros. + +* Thu Aug 13 2020 Anton Farygin 1.1.3-alt1 +- first build for ALT (based on specfile from Fedora) + diff --git a/.gear/rules b/.gear/rules new file mode 100644 index 0000000..f9c6266 --- /dev/null +++ b/.gear/rules @@ -0,0 +1,3 @@ +tar: pam_wrapper-@version@:. +diff: pam_wrapper-@version@:. . +spec: .gear/pam_wrapper.spec diff --git a/.gear/tags/be57e84778893d9933a9e02deaf94c5fcc79bee7 b/.gear/tags/be57e84778893d9933a9e02deaf94c5fcc79bee7 new file mode 100644 index 0000000..f8d2242 --- /dev/null +++ b/.gear/tags/be57e84778893d9933a9e02deaf94c5fcc79bee7 @@ -0,0 +1,30 @@ +object d938a84d88c5882a08babfb5e10f03a9135237a3 +type commit +tag pam_wrapper-1.1.4 +tagger Andreas Schneider 1635410272 +0200 + +pam_wrapper-1.1.4 + +* 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 +-----BEGIN PGP SIGNATURE----- + +iQIzBAABCgAdFiEEjf9T4Y8qvI2PPJIjfuD8TcwBTj0FAmF6YXkACgkQfuD8TcwB +Tj1XRBAApF8syv6/V4xJbLacvGGLc3A8K9I/UaCDGscE1G9ADkqgXCKTlAdtmMnS +rOlkvpCoLmePfkqrNcXB7XtIupWGXQex1S1TBloAuEvl+Q0N/xdzKYo/jRIIFv+t ++K7skBGBI5oxzHegXtlEUbJ4pdW+8dRnFtiRcouerqCDot8pI1x12NRXtWDuEcHp +qGneHOGkfyqKsP9kuNlbn7PFSuuP0Rmpt/HX0axAnBw3PN1f9fr4uypIHAi326kt +bujSgn4wjCmQwrjr7t5CZrg/n4fyDTy6Qt6pnkcxOry8hMenNzyfXypa9BnB8J95 +2x0ZtlbKh4XEzrR7zOhO8vkMHKOsTtQ/hcGUdsZvnXax+FMg5QOeDfsJl2RegAIg +57JH/1G7JZ/WQizOITRCrMoF7mUfDVVGhtTDNYnbnbf5cbZGnLV4E1VDHvLA6fEb +zeq9aWJYcT0qFmlEibbOsGSAADtG8sGj+aFnFjaD/tGepNyk+KI9Ip0Jl99dY9Hk +a+i2xzv1aIlFJmNHetPLbAOPpWC91C5/07ZmZkToG7BQE+ifNXa8zgUZTfaAH+5/ +ncqyCcFehAdqXKOdKTr+24VNrIbohqGlDvztWW9rB9823MnJlQUefNJRQmSyXvZ/ +jDNqsulneLs6wAYVsvQVDjq1tl+pNpSU9CeTYGX3HTUwFM7zYlM= +=h9Hh +-----END PGP SIGNATURE----- diff --git a/.gear/tags/list b/.gear/tags/list new file mode 100644 index 0000000..f467c28 --- /dev/null +++ b/.gear/tags/list @@ -0,0 +1 @@ +be57e84778893d9933a9e02deaf94c5fcc79bee7 pam_wrapper-1.1.4 diff --git a/.gear/upstream/filter-tag b/.gear/upstream/filter-tag new file mode 100755 index 0000000..4153213 --- /dev/null +++ b/.gear/upstream/filter-tag @@ -0,0 +1,3 @@ +#!/bin/bash + +grep '^pam_wrapper-[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]$' diff --git a/.gear/upstream/remotes b/.gear/upstream/remotes new file mode 100644 index 0000000..81d3c7c --- /dev/null +++ b/.gear/upstream/remotes @@ -0,0 +1,3 @@ +[remote "upstream"] + fetch = +refs/heads/*:refs/remotes/upstream/* + url = git://git.samba.org/pam_wrapper.git diff --git a/.gear/upstream/transform-tag b/.gear/upstream/transform-tag new file mode 100755 index 0000000..1ea2916 --- /dev/null +++ b/.gear/upstream/transform-tag @@ -0,0 +1,3 @@ +#!/bin/bash + +sed -e 's,^pam_wrapper-,,' diff --git a/.gitignore b/.gitignore index 751772d..ad36681 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.a *.o -.* *.swp *~$ cscope.* diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index d28cf66..4778459 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -44,22 +44,34 @@ check_function_exists(snprintf HAVE_SNPRINTF) check_function_exists(getprogname HAVE_GETPROGNAME) check_function_exists(getexecname HAVE_GETEXECNAME) +check_prototype_definition(pam_getenv + "const char* pam_getenv(const pam_handle_t *pamh, const char *name)" + "NULL" + "stdio.h;sys/types.h;security/pam_appl.h;security/pam_ext.h;security/pam_modules.h" + HAVE_PAM_GETENV_CONST) + +check_prototype_definition(pam_getenvlist + "char** pam_getenvlist(const pam_handle_t *pamh)" + "NULL" + "stdio.h;sys/types.h;security/pam_appl.h;security/pam_ext.h;security/pam_modules.h" + HAVE_PAM_GETENVLIST_CONST) + check_prototype_definition(pam_vprompt "int pam_vprompt(const pam_handle_t *_pamh, int _style, char **_resp, const char *_fmt, va_list _ap)" "-1" - "stdio.h;sys/types.h;security/pam_appl.h;security/pam_modules.h" + "stdio.h;sys/types.h;security/pam_appl.h;security/pam_ext.h;security/pam_modules.h" HAVE_PAM_VPROMPT_CONST) check_prototype_definition(pam_prompt "int pam_prompt(const pam_handle_t *_pamh, int _style, char **_resp, const char *_fmt, ...)" "-1" - "stdio.h;sys/types.h;security/pam_appl.h;security/pam_modules.h" + "stdio.h;sys/types.h;security/pam_appl.h;security/pam_ext.h;security/pam_modules.h" HAVE_PAM_PROMPT_CONST) check_prototype_definition(pam_strerror "const char *pam_strerror(const pam_handle_t *_pamh, int _error_number)" "NULL" - "stdio.h;sys/types.h;security/pam_appl.h;security/pam_modules.h" + "stdio.h;sys/types.h;security/pam_appl.h;security/pam_ext.h;security/pam_modules.h" HAVE_PAM_STRERROR_CONST) # LIBRARIES diff --git a/config.h.cmake b/config.h.cmake index 7d6ee24..12b585d 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -22,6 +22,8 @@ #cmakedefine HAVE_PAM_SYSLOG 1 #cmakedefine HAVE_PAM_START_CONFDIR 1 +#cmakedefine HAVE_PAM_GETENV_CONST 1 +#cmakedefine HAVE_PAM_GETENVLIST_CONST 1 #cmakedefine HAVE_PAM_VPROMPT_CONST 1 #cmakedefine HAVE_PAM_PROMPT_CONST 1 #cmakedefine HAVE_PAM_STRERROR_CONST 1 diff --git a/src/pam_wrapper.c b/src/pam_wrapper.c index da2c738..0945b9e 100644 --- a/src/pam_wrapper.c +++ b/src/pam_wrapper.c @@ -479,18 +479,26 @@ static int libpam_pam_putenv(pam_handle_t *pamh, const char *name_value) return pwrap.libpam.symbols._libpam_pam_putenv.f(pamh, name_value); } +#ifdef HAVE_PAM_GETENV_CONST +static const char *libpam_pam_getenv(const pam_handle_t *pamh, const char *name) +#else static const char *libpam_pam_getenv(pam_handle_t *pamh, const char *name) +#endif { pwrap_bind_symbol_libpam(pam_getenv); - return pwrap.libpam.symbols._libpam_pam_getenv.f(pamh, name); + return pwrap.libpam.symbols._libpam_pam_getenv.f(discard_const_p(pam_handle_t, pamh), name); } +#ifdef HAVE_PAM_GETENVLIST_CONST +static char **libpam_pam_getenvlist(const pam_handle_t *pamh) +#else static char **libpam_pam_getenvlist(pam_handle_t *pamh) +#endif { pwrap_bind_symbol_libpam(pam_getenvlist); - return pwrap.libpam.symbols._libpam_pam_getenvlist.f(pamh); + return pwrap.libpam.symbols._libpam_pam_getenvlist.f(discard_const_p(pam_handle_t, pamh)); } static int libpam_pam_open_session(pam_handle_t *pamh, int flags) @@ -1427,24 +1435,40 @@ int pam_putenv(pam_handle_t *pamh, const char *name_value) return pwrap_pam_putenv(pamh, name_value); } +#ifdef HAVE_PAM_GETENV_CONST +static const char *pwrap_pam_getenv(const pam_handle_t *pamh, const char *name) +#else static const char *pwrap_pam_getenv(pam_handle_t *pamh, const char *name) +#endif { PWRAP_LOG(PWRAP_LOG_TRACE, "pwrap_getenv name=%s", name); - return libpam_pam_getenv(pamh, name); + return libpam_pam_getenv(discard_const_p(pam_handle_t, pamh), name); } +#ifdef HAVE_PAM_GETENV_CONST +const char *pam_getenv(const pam_handle_t *pamh, const char *name) +#else const char *pam_getenv(pam_handle_t *pamh, const char *name) +#endif { return pwrap_pam_getenv(pamh, name); } +#ifdef HAVE_PAM_GETENVLIST_CONST +static char **pwrap_pam_getenvlist(const pam_handle_t *pamh) +#else static char **pwrap_pam_getenvlist(pam_handle_t *pamh) +#endif { PWRAP_LOG(PWRAP_LOG_TRACE, "pwrap_getenvlist called"); - return libpam_pam_getenvlist(pamh); + return libpam_pam_getenvlist(discard_const_p(pam_handle_t, pamh)); } +#ifdef HAVE_PAM_GETENVLIST_CONST +char **pam_getenvlist(const pam_handle_t *pamh) +#else char **pam_getenvlist(pam_handle_t *pamh) +#endif { return pwrap_pam_getenvlist(pamh); }