aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jakub.hrozek@posteo.se>2015-10-01 21:30:14 +0200
committerAndreas Schneider <asn@samba.org>2015-12-10 13:31:19 +0100
commit4dbb1a9cc98879295035cb6ea71750c7084d21b7 (patch)
treec5fd8b20446c71065691cc976c3f09bfb4babde2
parentb9fae84d1cdaa7a7f8518329b3bedf9da7297f44 (diff)
downloadpam_wrapper-4dbb1a9cc98879295035cb6ea71750c7084d21b7.tar.gz
pam_wrapper-4dbb1a9cc98879295035cb6ea71750c7084d21b7.tar.xz
pam_wrapper-4dbb1a9cc98879295035cb6ea71750c7084d21b7.zip
pwrap: wrap pam_syslog
-rw-r--r--src/pam_wrapper.c47
-rw-r--r--tests/test_pam_wrapper.c17
2 files changed, 64 insertions, 0 deletions
diff --git a/src/pam_wrapper.c b/src/pam_wrapper.c
index 9db8f82..9a5595b 100644
--- a/src/pam_wrapper.c
+++ b/src/pam_wrapper.c
@@ -197,6 +197,11 @@ typedef int (*__libpam_pam_vprompt)(pam_handle_t *pamh,
typedef const char * (*__libpam_pam_strerror)(pam_handle_t *pamh, int errnum);
+typedef void (*__libpam_pam_vsyslog)(const pam_handle_t *pamh,
+ int priority,
+ const char *fmt,
+ va_list args);
+
#define PWRAP_SYMBOL_ENTRY(i) \
union { \
__libpam_##i f; \
@@ -221,6 +226,7 @@ struct pwrap_libpam_symbols {
PWRAP_SYMBOL_ENTRY(pam_set_data);
PWRAP_SYMBOL_ENTRY(pam_vprompt);
PWRAP_SYMBOL_ENTRY(pam_strerror);
+ PWRAP_SYMBOL_ENTRY(pam_vsyslog);
};
struct pwrap {
@@ -470,6 +476,19 @@ static const char *libpam_pam_strerror(pam_handle_t *pamh, int errnum)
return pwrap.libpam.symbols._libpam_pam_strerror.f(pamh, errnum);
}
+static void libpam_pam_vsyslog(const pam_handle_t *pamh,
+ int priority,
+ const char *fmt,
+ va_list args)
+{
+ pwrap_bind_symbol_libpam(pam_vsyslog);
+
+ pwrap.libpam.symbols._libpam_pam_vsyslog.f(pamh,
+ priority,
+ fmt,
+ args);
+}
+
/*********************************************************
* PWRAP INIT
*********************************************************/
@@ -1182,6 +1201,34 @@ const char *pam_strerror(pam_handle_t *pamh, int errnum)
return pwrap_pam_strerror(pamh, errnum);
}
+static void pwrap_pam_vsyslog(const pam_handle_t *pamh,
+ int priority,
+ const char *fmt,
+ va_list args)
+{
+ PWRAP_LOG(PWRAP_LOG_TRACE, "pwrap_pam_vsyslog called");
+ libpam_pam_vsyslog(pamh, priority, fmt, args);
+}
+
+void pam_vsyslog(const pam_handle_t *pamh,
+ int priority,
+ const char *fmt,
+ va_list args)
+{
+ pwrap_pam_vsyslog(pamh, priority, fmt, args);
+}
+
+void pam_syslog(const pam_handle_t *pamh,
+ int priority,
+ const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ pwrap_pam_vsyslog(pamh, priority, fmt, args);
+ va_end(args);
+}
+
/****************************
* DESTRUCTOR
***************************/
diff --git a/tests/test_pam_wrapper.c b/tests/test_pam_wrapper.c
index 9960fb9..d856b48 100644
--- a/tests/test_pam_wrapper.c
+++ b/tests/test_pam_wrapper.c
@@ -11,6 +11,7 @@
#include <errno.h>
#include <unistd.h>
#include <limits.h>
+#include <syslog.h>
#include <security/pam_appl.h>
#include <security/pam_ext.h>
@@ -573,6 +574,19 @@ static void test_pam_authenticate_db_opt(void **state)
assert_int_equal(rv, PAM_SUCCESS);
}
+static void test_pam_vsyslog(void **state)
+{
+ struct pwrap_test_ctx *test_ctx;
+ int rv;
+
+ test_ctx = (struct pwrap_test_ctx *) *state;
+ rv = pam_start("pwrap_pam", "testuser",
+ &test_ctx->conv, &test_ctx->ph);
+ assert_int_equal(rv, PAM_SUCCESS);
+
+ pam_syslog(test_ctx->ph, LOG_INFO, "This is pam_wrapper test\n");
+}
+
int main(void) {
int rc;
@@ -619,6 +633,9 @@ int main(void) {
cmocka_unit_test_setup_teardown(test_pam_authenticate_db_opt,
setup_ctx_only,
teardown),
+ cmocka_unit_test_setup_teardown(test_pam_vsyslog,
+ setup_noconv,
+ teardown),
};
rc = cmocka_run_group_tests(init_tests, NULL, NULL);