summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <David.Woodhouse@intel.com>2014-08-08 23:54:38 +0100
committerSimo Sorce <simo@redhat.com>2014-08-10 14:29:37 -0400
commit85c6588f364228343fe74f20b4667e8c063e5845 (patch)
tree575847ffcd8c13ddef7a32da67a5c372c7354ccd
parent5795f577aeb3a39f51bda9a3840a441ca2237307 (diff)
downloadgss-ntlmssp-85c6588f364228343fe74f20b4667e8c063e5845.tar.gz
gss-ntlmssp-85c6588f364228343fe74f20b4667e8c063e5845.tar.xz
gss-ntlmssp-85c6588f364228343fe74f20b4667e8c063e5845.zip
Add gssntlm_display_status()
-rw-r--r--Makefile.am1
-rw-r--r--src/gss_err.c66
-rw-r--r--src/gss_ntlmssp.h8
-rw-r--r--src/gss_spi.c11
4 files changed, 86 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index f2bdbb5..047f0d7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -72,6 +72,7 @@ GN_MECHGLUE_OBJ = \
src/crypto.c \
src/ntlm_crypto.c \
src/ntlm.c \
+ src/gss_err.c \
src/gss_spi.c \
src/gss_names.c \
src/gss_creds.c \
diff --git a/src/gss_err.c b/src/gss_err.c
new file mode 100644
index 0000000..dd43a49
--- /dev/null
+++ b/src/gss_err.c
@@ -0,0 +1,66 @@
+/* Copyright (C) 2014 GSS-NTLMSSP contributors, see COPYING for license */
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include <gssapi/gssapi.h>
+#include <gssapi/gssapi_ext.h>
+
+#include "gss_ntlmssp.h"
+
+#define UNKNOWN_ERROR "Unknown Error"
+
+uint32_t gssntlm_display_status(uint32_t *minor_status,
+ uint32_t status_value,
+ int status_type,
+ gss_OID mech_type,
+ uint32_t *message_context,
+ gss_buffer_t status_string)
+{
+ /* if you can't say it in ~6 lines of text we don't bother */
+ char buf[512];
+ int err;
+
+ if (!minor_status || !status_string) {
+ *minor_status = EINVAL;
+ return GSS_S_CALL_INACCESSIBLE_READ;
+ }
+
+ *minor_status = 0;
+ status_string->length = 0;
+ status_string->value = NULL;
+
+ if (!status_value) {
+ /* There must have been *some* error. No point saying 'Success' */
+ goto done;
+ }
+
+ errno = 0;
+ err = strerror_r(status_value, buf, 400);
+ /* The XSI-compliant strerror_r() function returns 0 on success.
+ * On error, a (positive) error number is returned (since glibc
+ * 2.13), or -1 is returned and errno is set to indicate the
+ * error (glibc versions before 2.13). */
+ if (err == -1) err = errno;
+ switch (err) {
+ case ERANGE:
+ /* Screw it, they can have a truncated version */
+ case 0:
+ status_string->value = strdup(buf);
+ break;
+ default:
+ break;
+ }
+
+done:
+ if (!status_string->value) {
+ status_string->value = strdup(UNKNOWN_ERROR);
+ if (!status_string->value) {
+ *minor_status = ENOMEM;
+ return GSS_S_FAILURE;
+ }
+ }
+ status_string->length = strlen(status_string->value);
+ return GSS_S_COMPLETE;
+}
diff --git a/src/gss_ntlmssp.h b/src/gss_ntlmssp.h
index 8bd16ef..68dde38 100644
--- a/src/gss_ntlmssp.h
+++ b/src/gss_ntlmssp.h
@@ -389,4 +389,12 @@ uint32_t gssntlm_export_cred(uint32_t *minor_status,
uint32_t gssntlm_import_cred(uint32_t *minor_status,
gss_buffer_t token,
gss_cred_id_t *cred_handle);
+
+
+uint32_t gssntlm_display_status(uint32_t *minor_status,
+ uint32_t status_value,
+ int status_type,
+ gss_OID mech_type,
+ uint32_t *message_context,
+ gss_buffer_t status_string);
#endif /* _GSS_NTLMSSP_H_ */
diff --git a/src/gss_spi.c b/src/gss_spi.c
index ccb0bea..cb4b5a0 100644
--- a/src/gss_spi.c
+++ b/src/gss_spi.c
@@ -397,3 +397,14 @@ OM_uint32 gss_import_cred(OM_uint32 *minor_status,
{
return gssntlm_import_cred(minor_status, token, cred_handle);
}
+
+OM_uint32 gss_display_status(OM_uint32 *minor_status,
+ OM_uint32 status_value,
+ int status_type,
+ gss_OID mech_type,
+ OM_uint32 *message_context,
+ gss_buffer_t status_string)
+{
+ return gssntlm_display_status(minor_status, status_value, status_type,
+ mech_type, message_context, status_string);
+}