aklog: check ccache errors in get_user_realm
[openafs.git] / src / aklog / aklog.c
index 44c4554..4d53ab4 100644 (file)
  */
 
 #include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
 
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_MEMORY_H
-#include <memory.h>
-#endif
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <fcntl.h>
+#include <roken.h>
 
-#include <sys/param.h>
-#include <sys/errno.h>
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <pwd.h>
+#include <ctype.h>
 
-#include <afs/stds.h>
 #include <afs/ktc.h>
 #include <afs/token.h>
 
@@ -77,7 +56,6 @@
 #include <afs/com_err.h>
 #endif
 
-#include <afs/param.h>
 #ifdef AFS_SUN5_ENV
 #include <sys/ioccom.h>
 #endif
 #define AKLOG_BADPATH 6
 #define AKLOG_MISC 7
 
-#ifndef NULL
-#define NULL 0
-#endif
-
 #ifndef TRUE
 #define TRUE 1
 #endif
@@ -242,7 +216,9 @@ Done:
 #error "Must have either keyblock or session member of krb5_creds"
 #endif
 
-#if !defined(HAVE_KRB5_524_CONVERT_CREDS) && defined(HAVE_KRB524_CONVERT_CREDS_KDC)
+#ifdef AFS_DARWIN110_ENV
+#define HAVE_NO_KRB5_524 /* MITKerberosShim logs but returns success */
+#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
@@ -910,7 +886,7 @@ rxkad_get_token(krb5_context context, struct afsconf_cell *cell, char *realm,
     } else {
        len = strlen(username)+strlen(realmUsed)+2;
        *authuser = malloc(len);
-       afs_snprintf(*authuser, len, "%s@%s", username, realmUsed);
+       snprintf(*authuser, len, "%s@%s", username, realmUsed);
        *foreign = 1;
     }
 
@@ -2150,8 +2126,11 @@ get_user_realm(krb5_context context, char **realm)
 
     *realm = NULL;
 
-    if (!_krb425_ccache)
-        krb5_cc_default(context, &_krb425_ccache);
+    if (!_krb425_ccache) {
+       r = krb5_cc_default(context, &_krb425_ccache);
+       if (r)
+           return r;
+    }
     if (!client_principal) {
        if (client) {
            r = krb5_parse_name(context, client,  &client_principal);