aklog: Fix error message fallback for Heimdal
[openafs.git] / src / aklog / aklog.c
index d78ff7b..ce64768 100644 (file)
@@ -216,12 +216,11 @@ Done:
 #error "Must have either keyblock or session member of krb5_creds"
 #endif
 
-#ifdef AFS_DARWIN110_ENV
-#define HAVE_NO_KRB5_524 /* MITKerberosShim logs but returns success */
+/* MITKerberosShim logs but returns success */
+#if !defined(HAVE_KRB5_524_CONV_PRINCIPAL) || defined(AFS_DARWIN110_ENV) || (!defined(HAVE_KRB5_524_CONVERT_CREDS) && !defined(HAVE_KRB524_CONVERT_CREDS_KDC))
+#define HAVE_NO_KRB5_524
 #elif !defined(HAVE_KRB5_524_CONVERT_CREDS) && defined(HAVE_KRB524_CONVERT_CREDS_KDC)
 #define krb5_524_convert_creds krb524_convert_creds_kdc
-#elif !defined(HAVE_KRB5_524_CONVERT_CREDS) && !defined(HAVE_KRB524_CONVERT_CREDS_KDC)
-#define HAVE_NO_KRB5_524
 #endif
 
 #if USING_HEIMDAL
@@ -311,8 +310,11 @@ redirect_errors(const char *who, afs_int32 code, const char *fmt, va_list ap)
        if (strncmp(str, "unknown", strlen("unknown")) == 0) {
 #ifdef HAVE_KRB5_SVC_GET_MSG
            krb5_svc_get_msg(code,&str);
-#elif defined(HAVE_ERROR_MESSAGE)
-           str = error_message(code);
+#elif defined(HAVE_KRB5_GET_ERROR_MESSAGE)
+           krb5_context context;
+           krb5_init_context(&context);
+           str = krb5_get_error_message(context, code);
+           krb5_free_context(context);
 #else
            ; /* IRIX apparently has neither: use the string we have */
 #endif
@@ -345,7 +347,7 @@ copy_cellinfo(cellinfo_t *cellinfo)
 {
     cellinfo_t *new_cellinfo;
 
-    if ((new_cellinfo = (cellinfo_t *)malloc(sizeof(cellinfo_t))))
+    if ((new_cellinfo = malloc(sizeof(cellinfo_t))))
        memcpy(new_cellinfo, cellinfo, sizeof(cellinfo_t));
 
     return ((char *)new_cellinfo);