krb5 commit: Add helper to change extended error message code

Greg Hudson ghudson at MIT.EDU
Wed May 7 12:56:48 EDT 2014


https://github.com/krb5/krb5/commit/59c8600dcbee09dd9b4bf68b9b97c6fa95e9f6d2
commit 59c8600dcbee09dd9b4bf68b9b97c6fa95e9f6d2
Author: Greg Hudson <ghudson at mit.edu>
Date:   Mon Apr 28 12:25:01 2014 -0400

    Add helper to change extended error message code
    
    k5_change_error_message_code allows an extended error message to be
    used when an error code is remapped.

 src/include/k5-int.h         |    3 +++
 src/lib/krb5/krb/kerrs.c     |   10 ++++++++++
 src/lib/krb5/libkrb5.exports |    1 +
 src/lib/krb5_32.def          |    3 +++
 4 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/include/k5-int.h b/src/include/k5-int.h
index fbb8665..096cd14 100644
--- a/src/include/k5-int.h
+++ b/src/include/k5-int.h
@@ -2254,6 +2254,9 @@ krb5_error_code krb5int_parse_enctype_list(krb5_context context,
 
 krb5_boolean k5_etypes_contains(const krb5_enctype *list, krb5_enctype etype);
 
+void k5_change_error_message_code(krb5_context ctx, krb5_error_code oldcode,
+                                  krb5_error_code newcode);
+
 #ifdef DEBUG_ERROR_LOCATIONS
 #define krb5_set_error_message(ctx, code, ...)                          \
     krb5_set_error_message_fl(ctx, code, __FILE__, __LINE__, __VA_ARGS__)
diff --git a/src/lib/krb5/krb/kerrs.c b/src/lib/krb5/krb/kerrs.c
index 99db926..f3e6c94 100644
--- a/src/lib/krb5/krb/kerrs.c
+++ b/src/lib/krb5/krb/kerrs.c
@@ -180,3 +180,13 @@ k5_restore_ctx_error(krb5_context ctx, struct errinfo *in)
     }
     return code;
 }
+
+/* If ctx contains an extended error message for oldcode, change it to be an
+ * extended error message for newcode. */
+void
+k5_change_error_message_code(krb5_context ctx, krb5_error_code oldcode,
+                             krb5_error_code newcode)
+{
+    if (ctx != NULL && ctx->err.msg != NULL && ctx->err.code == oldcode)
+        ctx->err.code = newcode;
+}
diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports
index b03e73a..06ca9fc 100644
--- a/src/lib/krb5/libkrb5.exports
+++ b/src/lib/krb5/libkrb5.exports
@@ -107,6 +107,7 @@ initialize_kv5m_error_table
 initialize_prof_error_table
 k5_build_conf_principals
 k5_ccselect_free_context
+k5_change_error_message_code
 k5_etypes_contains
 k5_expand_path_tokens
 k5_expand_path_tokens_extra
diff --git a/src/lib/krb5_32.def b/src/lib/krb5_32.def
index dd0a16c..3530ae1 100644
--- a/src/lib/krb5_32.def
+++ b/src/lib/krb5_32.def
@@ -452,3 +452,6 @@ EXPORTS
 	krb5_responder_pkinit_challenge_free		@423
 	krb5_auth_con_setpermetypes			@424 ; PRIVATE GSSAPI
 	krb5_rd_req_decoded				@425 ; PRIVATE GSSAPI
+
+; new in 1.13
+	k5_change_error_message_code			@426 ; PRIVATE GSSAPI


More information about the cvs-krb5 mailing list