krb5 commit: Set klog com_err context for each KDC request

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/3e1f1c281f977b253934a641753d09b261c84cdb
commit 3e1f1c281f977b253934a641753d09b261c84cdb
Author: Greg Hudson <[email protected]>
Date:   Fri Jan 5 16:27:19 2018 -0500

    Set klog com_err context for each KDC request
    
    In setup_server_realm(), set the error context for the klog com_err
    hook so that com_err() can retrieve error messages using the per-realm
    context.
    
    ticket: 8630

 src/kdc/main.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/kdc/main.c b/src/kdc/main.c
index 919320d..e1ee3a9 100644
--- a/src/kdc/main.c
+++ b/src/kdc/main.c
@@ -127,14 +127,16 @@ setup_server_realm(struct server_handle *handle, krb5_principal sprinc)
         return NULL;
 
     if (kdc_numrealms > 1) {
-        if (!(newrealm = find_realm_data(handle, sprinc->realm.data,
-                                         (krb5_ui_4) sprinc->realm.length)))
-            return NULL;
-        else
-            return newrealm;
+        newrealm = find_realm_data(handle, sprinc->realm.data,
+                                   sprinc->realm.length);
+    } else {
+        newrealm = kdc_realmlist[0];
     }
-    else
-        return kdc_realmlist[0];
+    if (newrealm != NULL) {
+        krb5_klog_set_context(newrealm->realm_context);
+        shandle.kdc_err_context = newrealm->realm_context;
+    }
+    return newrealm;
 }
 
 static void
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.