dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone
Blob Blame History Raw
From ab6ee9104826e286e0c67c9176c08b9a239e0622 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek@redhat.com>
Date: Tue, 26 Jul 2016 12:13:43 +0200
Subject: [PATCH 85/86] SIMPLE: Make the DP handlers testable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

To make it possible to call the whole DP handler in the unit test, not
just the evaluator part.

Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
---
 Makefile.am                              |  1 +
 src/providers/simple/simple_access.c     |  5 ++--
 src/providers/simple/simple_access_pvt.h | 43 ++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 2 deletions(-)
 create mode 100644 src/providers/simple/simple_access_pvt.h

diff --git a/Makefile.am b/Makefile.am
index cefd9a43442fc19933f1e373d4f2ed4bb3ba3201..ee9b48c666a44781b582ba5d83102b705e898f29 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -665,6 +665,7 @@ dist_noinst_HEADERS = \
     src/providers/fail_over_srv.h \
     src/util/child_common.h \
     src/providers/simple/simple_access.h \
+    src/providers/simple/simple_access_pvt.h \
     src/providers/krb5/krb5_auth.h \
     src/providers/krb5/krb5_common.h \
     src/providers/krb5/krb5_utils.h \
diff --git a/src/providers/simple/simple_access.c b/src/providers/simple/simple_access.c
index 577e8354e9b574764734248b2bde4ef06c6fb4fc..521beee84833b47b547bd1045c24e3384aa4d9a5 100644
--- a/src/providers/simple/simple_access.c
+++ b/src/providers/simple/simple_access.c
@@ -22,6 +22,7 @@
 #include <security/pam_modules.h>
 
 #include "providers/simple/simple_access.h"
+#include "providers/simple/simple_access_pvt.h"
 #include "util/sss_utf8.h"
 #include "providers/backend.h"
 #include "db/sysdb.h"
@@ -176,7 +177,7 @@ struct simple_access_handler_state {
 
 static void simple_access_handler_done(struct tevent_req *subreq);
 
-static struct tevent_req *
+struct tevent_req *
 simple_access_handler_send(TALLOC_CTX *mem_ctx,
                            struct simple_ctx *simple_ctx,
                            struct pam_data *pd,
@@ -265,7 +266,7 @@ done:
     tevent_req_done(req);
 }
 
-static errno_t
+errno_t
 simple_access_handler_recv(TALLOC_CTX *mem_ctx,
                        struct tevent_req *req,
                        struct pam_data **_data)
diff --git a/src/providers/simple/simple_access_pvt.h b/src/providers/simple/simple_access_pvt.h
new file mode 100644
index 0000000000000000000000000000000000000000..c133e1c5531be35861178e0b23aa7a09db9f7703
--- /dev/null
+++ b/src/providers/simple/simple_access_pvt.h
@@ -0,0 +1,43 @@
+/*
+   SSSD
+
+   Simple access control
+
+   Copyright (C) Sumit Bose <sbose@redhat.com> 2010
+
+   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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __SIMPLE_ACCESS_PVT_H__
+#define __SIMPLE_ACCESS_PVT_H__
+
+#include "providers/data_provider/dp.h"
+
+/* We only 'export' the functions in a private header file to be able to call
+ * them from unit tests
+ */
+struct tevent_req *
+simple_access_handler_send(TALLOC_CTX *mem_ctx,
+                           struct simple_ctx *simple_ctx,
+                           struct pam_data *pd,
+                           struct dp_req_params *params);
+
+errno_t
+simple_access_handler_recv(TALLOC_CTX *mem_ctx,
+                           struct tevent_req *req,
+                           struct pam_data **_data);
+
+int simple_access_obtain_filter_lists(struct simple_ctx *ctx);
+
+#endif /* __SIMPLE_ACCESS_PVT_H__ */
-- 
2.4.11