Add printf format checks to afs_com_err()
[openafs.git] / src / kauth / admin_tools.c
index 4f6c7cb..adc7e3c 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <stdio.h>
 #include <rx/rx.h>
+#include <rx/rxkad.h>
 #include <lock.h>
 #define UBIK_LEGACY_CALLITER 1
 #include <ubik.h>
 #include <afs/cmd.h>
 #include <afs/com_err.h>
 #include <afs/afsutil.h>
+#include <des.h>
+#include <des_prototypes.h>
 
 #include "kauth.h"
 #include "kautils.h"
 #include "kaport.h"
+#include "kkids.h"
 
 #define CMD_PARSER_AMBIG_FIX 1 /* allow ambiguous aliases */
 
@@ -56,7 +60,7 @@ static char myName[510];      /* almost like whoami save with path and without : */
 static int finished;
 static int zero_argc;
 static char **zero_argv;
-afs_uint32 ka_islocked();
+afs_uint32 ka_islocked(char *, char *, afs_uint32 *);
 
 afs_int32
 DefaultCell(void)
@@ -408,11 +412,11 @@ parse_flags(char *name, char *inst, char *str, afs_int32 * flags)
     str = lcstring(bitspec, str, sizeof(bitspec));
     if (isdigit(*str)) {
        if (strncmp(str, "0x", 2) == 0) /* 0x => hex */
-           sscanf(str, "0x%lx", &f);
+           sscanf(str, "0x%lx", (long unsigned int *) &f);
        else if (*str == '0')   /* assume octal */
-           sscanf(str, "%lo", &f);
+           sscanf(str, "%lo", (long unsigned int *) &f);
        else                    /* just assume hex */
-           sscanf(str, "%lx", &f);
+           sscanf(str, "%lx", (long unsigned int *) &f);
     } else {
        if (*str == '=') {
            str++;
@@ -516,7 +520,7 @@ ka_islocked(char *name, char *instance, afs_uint32 * when)
                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        if (code) {
            if (seriouserror(code))
-               afs_com_err(whoami, code, "");
+               afs_com_err(whoami, code, NULL);
        } else if (tempwhen) {  /* user is locked */
            if (!*when || tempwhen < *when) {
                *when = tempwhen;
@@ -749,7 +753,7 @@ StringToKey(struct cmd_syndesc *as, void *arock)
        }
        ucstring(realm, realm, sizeof(realm));
     } else {
-       if (code = DefaultCell())
+       if ((code = DefaultCell()))
            return code;
        ucstring(realm, cell, sizeof(realm));
     }
@@ -760,7 +764,7 @@ StringToKey(struct cmd_syndesc *as, void *arock)
     ka_PrintBytes((char *)&key, sizeof(key));
     printf("'.\n");
 
-    des_string_to_key(as->parms[0].items->data, &key);
+    des_string_to_key(as->parms[0].items->data, ktc_to_cblockptr(&key));
 
     printf("Converting %s with the DES string to key yields key='",
           as->parms[0].items->data);
@@ -962,7 +966,7 @@ ListTicket(struct ktc_principal *server, int verbose)
     return 0;
 }
 
-static
+static int
 GetTicket(struct cmd_syndesc *as, void *arock)
 {
     int code;
@@ -984,7 +988,7 @@ GetTicket(struct cmd_syndesc *as, void *arock)
        return KABADCMD;
     }
     if (server.cell[0] == 0) {
-       if (code = DefaultCell())
+       if ((code = DefaultCell()))
            return code;
        strcpy(server.cell, cell);
     } else {
@@ -1008,7 +1012,7 @@ GetTicket(struct cmd_syndesc *as, void *arock)
     return code;
 }
 
-static
+static int
 GetPassword(struct cmd_syndesc *as, void *arock)
 {
     int code;
@@ -1075,7 +1079,7 @@ GetRandomKey(struct cmd_syndesc *as, void *arock)
        ka_PrintBytes((char *)&key, sizeof(key));
        printf(" (");
        for (i = 0; i < sizeof(key); i++) {
-           printf("%0.2x", ((char *)&key)[i] & 0xff);
+           printf("%.2x", ((char *)&key)[i] & 0xff);
            if (i == 3)
                printf(" ");
            else if (i != 7)
@@ -1111,7 +1115,7 @@ Statistics(struct cmd_syndesc *as, void *arock)
           (double)dynamics.hashTableUtilization / 100.0);
     ka_timestr(dynamics.start_time, bob, KA_TIMESTR_LEN);
     printf("From host %lx started at %s:\n", 
-          afs_cast_uint32(dynamics.host), bob);
+          afs_printable_uint32_lu(dynamics.host), bob);
 
 #define print_stat(name) if (dynamics.name.requests) printf ("  of %d requests for %s, %d were aborted.\n", dynamics.name.requests, # name, dynamics.name.aborts)
     print_stat(Authenticate);
@@ -1202,7 +1206,7 @@ DebugInfo(struct cmd_syndesc *as, void *arock)
     }
     ka_timestr(info.startTime, bob, KA_TIMESTR_LEN);
     printf("From host %lx started %sat %s:\n", 
-          afs_cast_uint32(info.host),
+          afs_printable_uint32_lu(info.host),
           (info.noAuth ? "w/o authorization " : ""), bob);
     ka_timestr(info.lastTrans, bob, KA_TIMESTR_LEN);
     printf("Last trans was %s at %s\n", info.lastOperation, bob);
@@ -1217,8 +1221,8 @@ DebugInfo(struct cmd_syndesc *as, void *arock)
           info.updatesRemaining);
     if (info.cheader_lock || info.keycache_lock)
        printf("locks: cheader %08lx, keycache %08lx\n", 
-               afs_cast_uint32(info.cheader_lock),
-               afs_cast_uint32(info.keycache_lock));
+               afs_printable_uint32_lu(info.cheader_lock),
+               afs_printable_uint32_lu(info.keycache_lock));
     printf("Last authentication for %s, last admin user was %s\n",
           info.lastAuth, info.lastAdmin);
     printf("Last TGS op was a %s ticket was for %s\n", info.lastTGSServer,
@@ -1285,9 +1289,9 @@ NoAuth(struct cmd_syndesc *as, void *arock)
 static int
 MyBeforeProc(struct cmd_syndesc *as, void *arock)
 {
-    extern struct passwd *getpwuid();
     struct ktc_encryptionKey key;
-    struct ktc_principal auth_server, auth_token, client;
+    struct ktc_principal auth_server, client;
+    struct ktc_token auth_token;
     char realm[MAXKTCREALMLEN];
 
     struct ktc_token token, *pToken;
@@ -1423,7 +1427,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
                ka_GetAdminToken(name, instance, cell, &key, KA_SIXHOURS,
                                 &token, 0 /* !new */ );
            if (code == KABADREQUEST) {
-               des_string_to_key(passwd, &key);
+               des_string_to_key(passwd, ktc_to_cblockptr(&key));
                code =
                    ka_GetAdminToken(name, instance, cell, &key, KA_SIXHOURS,
                                     &token, 0 /* !new */ );
@@ -1540,7 +1544,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
 
 /* These are some helpful command that deal with the cache managers tokens. */
 
-static
+static int
 ForgetTicket(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
@@ -1594,7 +1598,7 @@ ForgetTicket(struct cmd_syndesc *as, void *arock)
     return 0;
 }
 
-static
+static int
 ListTickets(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0;
@@ -1614,7 +1618,7 @@ ListTickets(struct cmd_syndesc *as, void *arock)
            return code;
        }
        if (server.cell[0] == 0) {
-           if (code = DefaultCell())
+           if ((code = DefaultCell()))
                return code;
            strcpy(server.cell, cell);
        } else {
@@ -1816,7 +1820,7 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
 
     strcpy(whoami, "kas");
 
-    if (code = cmd_Dispatch(cmd_argc, cmd_argv)) {
+    if ((code = cmd_Dispatch(cmd_argc, cmd_argv))) {
        return code;
     }