aklog: Return token when performing 524 conversion
[openafs.git] / src / aklog / aklog.c
index df81a75..ba6d7ad 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>
 
 #include <afs/com_err.h>
 #endif
 
-#include <afs/param.h>
 #ifdef AFS_SUN5_ENV
 #include <sys/ioccom.h>
 #endif
 
-/* Prevent inclusion of des.h to avoid conflicts with des types */
-#define NO_DES_H_INCLUDE
-
 #include <afs/auth.h>
 #include <afs/cellconfig.h>
 #include <afs/vice.h>
 #define AKLOG_BADPATH 6
 #define AKLOG_MISC 7
 
-#ifndef NULL
-#define NULL 0
-#endif
-
 #ifndef TRUE
 #define TRUE 1
 #endif
@@ -338,8 +309,10 @@ 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);
-#else
+#elif defined(HAVE_ERROR_MESSAGE)
            str = error_message(code);
+#else
+           ; /* IRIX apparently has neither: use the string we have */
 #endif
        }
        fputs(str, stderr);
@@ -620,6 +593,11 @@ rxkad_get_ticket(krb5_context context, char *realm,
        fprintf(stderr, "%s: Couldn't get %s AFS tickets:\n",
                progname, cell->name);
        afs_com_err(progname, status, "while getting AFS tickets");
+#ifdef KRB5_CC_NOT_KTYPE
+       if (status == KRB5_CC_NOT_KTYPE) {
+           fprintf(stderr, "allow_weak_enctypes may be required in the Kerberos configuration\n");
+       }
+#endif
        status = AKLOG_KERBEROS;
        goto out;
     }
@@ -845,6 +823,9 @@ rxkad_get_converted_token(krb5_context context, krb5_creds *v5cred,
     *tokenPtr = token;
     *userPtr = strdup(username);
 
+    *tokenPtr = token;
+    *userPtr = strdup(username);
+
     return 0;
 }
 #endif
@@ -906,7 +887,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;
     }
 
@@ -1501,12 +1482,12 @@ main(int argc, char *argv[])
      * krb5_allow_weak_crypto is MIT Kerberos 1.8.  krb5_enctype_enable is
      * Heimdal.
      */
-#if defined(HAVE_KRB5_ALLOW_WEAK_CRYPTO)
-    krb5_allow_weak_crypto(context, 1);
-#elif defined(HAVE_KRB5_ENCTYPE_ENABLE)
+#if defined(HAVE_KRB5_ENCTYPE_ENABLE)
     i = krb5_enctype_valid(context, ETYPE_DES_CBC_CRC);
     if (i)
         krb5_enctype_enable(context, ETYPE_DES_CBC_CRC);
+#elif defined(HAVE_KRB5_ALLOW_WEAK_CRYPTO)
+    krb5_allow_weak_crypto(context, 1);
 #endif
 
     /* Initialize list of cells to which we have authenticated */
@@ -1963,8 +1944,8 @@ get_credv5_akimpersonate(krb5_context context,
 
         if(buf_len != buf_size) {
             afs_com_err(progname, code,
-                   "%d != %d while encoding ticket (internal ASN.1 encoder error",
-                   buf_len, buf_size);
+                   "%u != %u while encoding ticket (internal ASN.1 encoder error",
+                   (unsigned int)buf_len, (unsigned int)buf_size);
             goto cleanup;
         }
         what = "krb5_crypto_init";