summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGünther Deschner <gdeschner@redhat.com>2013-03-08 12:42:06 +0100
committerGünther Deschner <gdeschner@redhat.com>2013-04-22 13:06:42 +0200
commit774703bb90c50b7e8b0f8b36e8abc69c5338b61b (patch)
treedabf7f6ef7bfe79e6dde5479089e73af1d03f9ab
parent9f6f785c2c4f5e4bf94a7131f35c7e925871d4b9 (diff)
downloadgss-proxy-774703bb90c50b7e8b0f8b36e8abc69c5338b61b.tar.gz
gss-proxy-774703bb90c50b7e8b0f8b36e8abc69c5338b61b.tar.xz
gss-proxy-774703bb90c50b7e8b0f8b36e8abc69c5338b61b.zip
Use gssproxy.idl generated code for debugging.
-rw-r--r--proxy/Makefile.am4
-rw-r--r--proxy/configure.ac7
-rw-r--r--proxy/src/gp_rpc_print.c88
-rw-r--r--proxy/src/gp_rpc_print.h48
-rw-r--r--proxy/src/gp_rpc_process.c73
5 files changed, 203 insertions, 17 deletions
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index ea16bed..46a57b4 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -72,6 +72,7 @@ AM_CPPFLAGS = \
$(POPT_CFLAGS) \
$(GSSAPI_CFLAGS) \
$(INI_CFLAGS) \
+ $(NDR_GSSPROXY_CFLAGS) \
-DLIBDIR=\"$(libdir)\" \
-DVARDIR=\"$(localstatedir)\" \
-DSHLIBEXT=\"$(SHLIBEXT)\" \
@@ -80,7 +81,7 @@ AM_CPPFLAGS = \
EXTRA_DIST = build/config.rpath
-GSS_PROXY_LIBS = $(POPT_LIBS) $(KRB5_LIBS) $(VERTO_LIBS) $(INI_LIBS) $(GSSAPI_LIBS) $(GSSRPC_LIBS)
+GSS_PROXY_LIBS = $(POPT_LIBS) $(KRB5_LIBS) $(VERTO_LIBS) $(INI_LIBS) $(GSSAPI_LIBS) $(GSSRPC_LIBS) $(NDR_GSSPROXY_LIBS)
if BUILD_SELINUX
GSS_PROXY_LIBS += $(SELINUX_LIBS)
@@ -149,6 +150,7 @@ gssproxy_SOURCES = \
src/gp_creds.c \
$(GP_RPCGEN_OBJ) \
src/gp_rpc_process.c \
+ src/gp_rpc_print.c \
src/gp_conv.c \
src/gp_export.c \
src/gp_debug.c \
diff --git a/proxy/configure.ac b/proxy/configure.ac
index 9fa6ef9..77384f2 100644
--- a/proxy/configure.ac
+++ b/proxy/configure.ac
@@ -82,6 +82,13 @@ if test x$have_libverto = x; then
AC_MSG_ERROR([Could not find VERTO headers])
fi
+PKG_CHECK_MODULES([NDR_GSSPROXY], [ndr_gssproxy >= 0.0.1], [have_libndr_gssproxy=1], [have_libndr_gssproxy=])
+if test x$have_libndr_gssproxy = x; then
+ AC_MSG_WARN([Could not find NDR GSSPROXY headers])
+else
+ AC_DEFINE_UNQUOTED(HAVE_NDR_GSSPROXY, 1, [Build with NDR_GSSPROXY debugging])
+fi
+
#Check for iniparser
have_iniparser=
AC_CHECK_HEADERS([iniparser.h],
diff --git a/proxy/src/gp_rpc_print.c b/proxy/src/gp_rpc_print.c
new file mode 100644
index 0000000..0d05698
--- /dev/null
+++ b/proxy/src/gp_rpc_print.c
@@ -0,0 +1,88 @@
+/*
+ GSS-PROXY
+
+ Copyright (C) 2011 Red Hat, Inc.
+ Copyright (C) 2011 Simo Sorce <simo.sorce@redhat.com>
+ Copyright (C) 2013 Guenther Deschner <guenther.deschner@redhat.com>
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include "config.h"
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "gp_debug.h"
+#include "gp_rpc_print.h"
+
+extern int gp_debug;
+
+#ifdef HAVE_NDR_GSSPROXY
+
+#include <gen_ndr/ndr_gssproxy.h>
+
+#define GP_PRINT_FUNC(name) \
+void gp_print_ ## name(uint32_t flags, uint32_t opcode, void *data) \
+{\
+ char *s = NULL; \
+ TALLOC_CTX *mem_ctx; \
+ void *in, *out; \
+ if (!gp_debug) { return; } \
+ mem_ctx = talloc_init("gp_print_" # name); \
+ if (mem_ctx == NULL) { return; }; \
+ switch (flags) { \
+ case GP_PRINT_IN: \
+ in = data; \
+ s = NDR_PRINT_STRUCT_STRING(mem_ctx, gssx_arg_ ## name, in); \
+ if (s) { \
+ GPDEBUG("%s\n", s); \
+ } \
+ break; \
+ case GP_PRINT_OUT: \
+ out = data; \
+ s = NDR_PRINT_STRUCT_STRING(mem_ctx, gssx_res_ ## name, out); \
+ if (s) { \
+ GPDEBUG("%s\n", s); \
+ } \
+ break; \
+ default: \
+ break; \
+ } \
+ talloc_free(mem_ctx); \
+}
+#else
+#define GP_PRINT_FUNC(name) \
+void gp_print_ ## name(uint32_t flags, uint32_t opcode, void *data) {}
+#endif /* HAVE_NDR_GSSPROXY */
+
+GP_PRINT_FUNC(acquire_cred)
+GP_PRINT_FUNC(init_sec_context)
+GP_PRINT_FUNC(accept_sec_context)
+GP_PRINT_FUNC(indicate_mechs)
+GP_PRINT_FUNC(release_handle)
+GP_PRINT_FUNC(import_and_canon_name)
+GP_PRINT_FUNC(get_call_context)
+GP_PRINT_FUNC(export_cred)
+GP_PRINT_FUNC(import_cred)
+GP_PRINT_FUNC(store_cred)
+GP_PRINT_FUNC(get_mic)
+GP_PRINT_FUNC(verify_mic)
+GP_PRINT_FUNC(wrap)
+GP_PRINT_FUNC(unwrap)
+GP_PRINT_FUNC(wrap_size_limit)
diff --git a/proxy/src/gp_rpc_print.h b/proxy/src/gp_rpc_print.h
new file mode 100644
index 0000000..8a7a782
--- /dev/null
+++ b/proxy/src/gp_rpc_print.h
@@ -0,0 +1,48 @@
+/*
+ GSS-PROXY
+
+ Copyright (C) 2011 Red Hat, Inc.
+ Copyright (C) 2011 Simo Sorce <simo.sorce@redhat.com>
+ Copyright (C) 2013 Guenther Deschner <guenther.deschner@redhat.com>
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#define GP_PRINT_IN 1
+#define GP_PRINT_OUT 2
+
+#define GP_PRINT_PROTO(name) \
+void gp_print_ ## name(uint32_t flags, uint32_t opcode, void *data);
+
+GP_PRINT_PROTO(indicate_mechs)
+GP_PRINT_PROTO(acquire_cred)
+GP_PRINT_PROTO(init_sec_context)
+GP_PRINT_PROTO(accept_sec_context)
+GP_PRINT_PROTO(indicate_mechs)
+GP_PRINT_PROTO(release_handle)
+GP_PRINT_PROTO(import_and_canon_name)
+GP_PRINT_PROTO(get_call_context)
+GP_PRINT_PROTO(export_cred)
+GP_PRINT_PROTO(import_cred)
+GP_PRINT_PROTO(store_cred)
+GP_PRINT_PROTO(get_mic)
+GP_PRINT_PROTO(verify_mic)
+GP_PRINT_PROTO(wrap)
+GP_PRINT_PROTO(unwrap)
+GP_PRINT_PROTO(wrap_size_limit)
diff --git a/proxy/src/gp_rpc_process.c b/proxy/src/gp_rpc_process.c
index 460c546..a15c0bd 100644
--- a/proxy/src/gp_rpc_process.c
+++ b/proxy/src/gp_rpc_process.c
@@ -24,8 +24,10 @@
*/
#include "gp_rpc_process.h"
+#include "gp_rpc_print.h"
typedef int (*gp_exec_fn)(gp_exec_std_args);
+typedef void (*gp_print_fn)(uint32_t flags, uint32_t proc, void *data);
struct gp_rpc_fn_set {
uint32_t proc;
@@ -33,118 +35,135 @@ struct gp_rpc_fn_set {
xdrproc_t arg_fn;
xdrproc_t res_fn;
gp_exec_fn exec_fn;
+ gp_print_fn print_fn;
} gp_xdr_set[] = {
{
0,
"NULLPROC",
(xdrproc_t)xdr_void,
(xdrproc_t)xdr_void,
- NULL
+ NULL,
+ NULL,
},
{
GSSX_INDICATE_MECHS,
"GSSX_INDICATE_MECHS",
(xdrproc_t)xdr_gssx_arg_indicate_mechs,
(xdrproc_t)xdr_gssx_res_indicate_mechs,
- gp_indicate_mechs
+ gp_indicate_mechs,
+ gp_print_indicate_mechs
},
{
GSSX_GET_CALL_CONTEXT,
"GSSX_GET_CALL_CONTEXT",
(xdrproc_t)xdr_gssx_arg_get_call_context,
(xdrproc_t)xdr_gssx_res_get_call_context,
- gp_get_call_context
+ gp_get_call_context,
+ gp_print_get_call_context
},
{
GSSX_IMPORT_AND_CANON_NAME,
"GSSX_IMPORT_AND_CANON_NAME",
(xdrproc_t)xdr_gssx_arg_import_and_canon_name,
(xdrproc_t)xdr_gssx_res_import_and_canon_name,
- gp_import_and_canon_name
+ gp_import_and_canon_name,
+ gp_print_import_and_canon_name
},
{
GSSX_EXPORT_CRED,
"GSSX_EXPORT_CRED",
(xdrproc_t)xdr_gssx_arg_export_cred,
(xdrproc_t)xdr_gssx_res_export_cred,
- gp_export_cred
+ gp_export_cred,
+ gp_print_export_cred
},
{
GSSX_IMPORT_CRED,
"GSSX_IMPORT_CRED",
(xdrproc_t)xdr_gssx_arg_import_cred,
(xdrproc_t)xdr_gssx_res_import_cred,
- gp_import_cred
+ gp_import_cred,
+ gp_print_export_cred
},
{
GSSX_ACQUIRE_CRED,
"GSSX_ACQUIRE_CRED",
(xdrproc_t)xdr_gssx_arg_acquire_cred,
(xdrproc_t)xdr_gssx_res_acquire_cred,
- gp_acquire_cred
+ gp_acquire_cred,
+ gp_print_acquire_cred
},
{
GSSX_STORE_CRED,
"GSSX_STORE_CRED",
(xdrproc_t)xdr_gssx_arg_store_cred,
(xdrproc_t)xdr_gssx_res_store_cred,
- gp_store_cred
+ gp_store_cred,
+ gp_print_store_cred
},
{
GSSX_INIT_SEC_CONTEXT,
"GSSX_INIT_SEC_CONTEXT",
(xdrproc_t)xdr_gssx_arg_init_sec_context,
(xdrproc_t)xdr_gssx_res_init_sec_context,
- gp_init_sec_context
+ gp_init_sec_context,
+ gp_print_init_sec_context
},
{
GSSX_ACCEPT_SEC_CONTEXT,
"GSSX_ACCEPT_SEC_CONTEXT",
(xdrproc_t)xdr_gssx_arg_accept_sec_context,
(xdrproc_t)xdr_gssx_res_accept_sec_context,
- gp_accept_sec_context
+ gp_accept_sec_context,
+ gp_print_accept_sec_context
},
{
GSSX_RELEASE_HANDLE,
"GSSX_RELEASE_HANDLE",
(xdrproc_t)xdr_gssx_arg_release_handle,
(xdrproc_t)xdr_gssx_res_release_handle,
- gp_release_handle
+ gp_release_handle,
+ gp_print_release_handle
},
{
GSSX_GET_MIC,
"GSSX_GET_MIC",
(xdrproc_t)xdr_gssx_arg_get_mic,
(xdrproc_t)xdr_gssx_res_get_mic,
- gp_get_mic
+ gp_get_mic,
+ gp_print_get_mic
},
{
GSSX_VERIFY,
"GSSX_VERIFY",
(xdrproc_t)xdr_gssx_arg_verify_mic,
(xdrproc_t)xdr_gssx_res_verify_mic,
- gp_verify_mic
+ gp_verify_mic,
+ gp_print_verify_mic
},
{
GSSX_WRAP,
"GSSX_WRAP",
(xdrproc_t)xdr_gssx_arg_wrap,
(xdrproc_t)xdr_gssx_res_wrap,
- gp_wrap
+ gp_wrap,
+ gp_print_wrap
},
{
GSSX_UNWRAP,
"GSSX_UNWRAP",
(xdrproc_t)xdr_gssx_arg_unwrap,
(xdrproc_t)xdr_gssx_res_unwrap,
- gp_unwrap
+ gp_unwrap,
+ gp_print_unwrap
},
{
GSSX_WRAP_SIZE_LIMIT,
"GSSX_WRAP_SIZE_LIMIT",
(xdrproc_t)xdr_gssx_arg_wrap_size_limit,
(xdrproc_t)xdr_gssx_res_wrap_size_limit,
- gp_wrap_size_limit
+ gp_wrap_size_limit,
+ gp_print_wrap_size_limit
}
};
@@ -368,6 +387,22 @@ static void gp_rpc_free_xdrs(int proc,
xdr_free(gp_xdr_set[proc].res_fn, (char *)res);
}
+static void gp_rpc_print_arg(uint32_t proc,
+ union gp_rpc_arg *arg)
+{
+ if (gp_xdr_set[proc].print_fn != NULL) {
+ gp_xdr_set[proc].print_fn(GP_PRINT_IN, proc, (char *)arg);
+ }
+}
+
+void gp_rpc_print_res(uint32_t proc,
+ union gp_rpc_res *res)
+{
+ if (gp_xdr_set[proc].print_fn != NULL) {
+ gp_xdr_set[proc].print_fn(GP_PRINT_OUT, proc, (char *)res);
+ }
+}
+
int gp_rpc_process_call(struct gssproxy_ctx *gpctx,
struct gp_service *gpsvc,
uint8_t *inbuf, size_t inlen,
@@ -394,6 +429,9 @@ int gp_rpc_process_call(struct gssproxy_ctx *gpctx,
/* decode request */
ret = gp_rpc_decode_call(&xdr_call_ctx, &xid, &proc, &arg, &acc, &rej);
if (!ret) {
+
+ gp_rpc_print_arg(proc, &arg);
+
/* execute request */
ret = gp_rpc_execute(gpctx, gpsvc, proc, &arg, &res);
if (ret) {
@@ -405,6 +443,9 @@ int gp_rpc_process_call(struct gssproxy_ctx *gpctx,
/* encode reply */
ret = gp_rpc_encode_reply(&xdr_reply_ctx, xid, proc, &res, ret, acc, rej);
if (ret == 0) {
+
+ gp_rpc_print_res(proc, &res);
+
/* return encoded buffer */
ret = gp_rpc_return_buffer(&xdr_reply_ctx,
reply_buffer, outbuf, outlen);