Add printf format checks to afs_com_err()
[openafs.git] / src / kauth / admin_tools.c
index 4e9b4c2..adc7e3c 100644 (file)
@@ -15,8 +15,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <afs/stds.h>
 #include <afs/debug.h>
@@ -29,7 +27,9 @@ RCSID
 
 #include <stdio.h>
 #include <rx/rx.h>
+#include <rx/rxkad.h>
 #include <lock.h>
+#define UBIK_LEGACY_CALLITER 1
 #include <ubik.h>
 #ifndef AFS_NT40_ENV
 #include <pwd.h>
@@ -39,10 +39,13 @@ RCSID
 #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 */
 
@@ -57,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)
@@ -68,7 +71,7 @@ DefaultCell(void)
        return 0;
     code = ka_ExpandCell(0, cell, 0 /*local */ );
     if (code) {
-       com_err(whoami, code, "Can't expand cell name");
+       afs_com_err(whoami, code, "Can't expand cell name");
     }
     return code;
 }
@@ -88,7 +91,7 @@ DumpUser(char *user, char *arock, int showadmin, int showkey, char *inst)
 
     code = ka_ParseLoginName(user, name, instance, 0);
     if (code) {
-       com_err(whoami, code, "parsing user's name '%s'", user);
+       afs_com_err(whoami, code, "parsing user's name '%s'", user);
        return KABADCMD;
     }
 
@@ -97,7 +100,7 @@ DumpUser(char *user, char *arock, int showadmin, int showkey, char *inst)
     code =
        ubik_Call(KAM_GetEntry, conn, 0, name, inst, KAMAJORVERSION, &tentry);
     if (code) {
-       com_err(whoami, code, "getting information for %s.%s", name, inst);
+       afs_com_err(whoami, code, "getting information for %s.%s", name, inst);
        return code;
     }
     if (tentry.minor_version != KAMINORVERSION)
@@ -234,7 +237,7 @@ DumpUser(char *user, char *arock, int showadmin, int showkey, char *inst)
 }
 
 int
-ListUsers(struct cmd_syndesc *as, char *arock)
+ListUsers(struct cmd_syndesc *as, void *arock)
 {
     struct kaident name;
     afs_int32 index;
@@ -254,7 +257,7 @@ ListUsers(struct cmd_syndesc *as, char *arock)
            ubik_Call(KAM_ListEntry, conn, 0, index, &next_index, &count,
                      &name);
        if (code) {
-           com_err(whoami, code, "calling KAM_ListEntry");
+           afs_com_err(whoami, code, "calling KAM_ListEntry");
            break;
        }
        if (!next_index)
@@ -273,7 +276,7 @@ ListUsers(struct cmd_syndesc *as, char *arock)
 
 
 int
-ExamineUser(struct cmd_syndesc *as, char *arock)
+ExamineUser(struct cmd_syndesc *as, void *arock)
 {
     int showkey = (as->parms[1].items != NULL);
     return DumpUser(as->parms[0].items->data, arock, 0, showkey, NULL);
@@ -300,7 +303,7 @@ handle_errors(int code,             /* error code to handle */
        }
     }
 
-    printf(" : [%s] %s", error_table_name(code), error_message(code));
+    printf(" : [%s] %s", afs_error_table_name(code), afs_error_message(code));
     switch (code) {
     case UNOQUORUM:
        printf(", wait one second\n");
@@ -318,7 +321,7 @@ handle_errors(int code,             /* error code to handle */
 }
 
 int
-CreateUser(struct cmd_syndesc *as, char *arock)
+CreateUser(struct cmd_syndesc *as, void *arock)
 {
     int code;
     char name[MAXKTCNAMELEN];
@@ -331,7 +334,7 @@ CreateUser(struct cmd_syndesc *as, char *arock)
 
     code = ka_ParseLoginName(as->parms[0].items->data, name, instance, 0);
     if (code) {
-       com_err(whoami, code, "parsing user's name '%s'",
+       afs_com_err(whoami, code, "parsing user's name '%s'",
                as->parms[0].items->data);
        return KABADCMD;
     }
@@ -348,7 +351,7 @@ CreateUser(struct cmd_syndesc *as, char *arock)
 }
 
 int
-DeleteUser(struct cmd_syndesc *as, char *arock)
+DeleteUser(struct cmd_syndesc *as, void *arock)
 {
     int code;
     char name[MAXKTCNAMELEN];
@@ -359,7 +362,7 @@ DeleteUser(struct cmd_syndesc *as, char *arock)
     OKlist[0].code = 0;
     code = ka_ParseLoginName(as->parms[0].items->data, name, instance, 0);
     if (code) {
-       com_err(whoami, code, "parsing user's name '%s'",
+       afs_com_err(whoami, code, "parsing user's name '%s'",
                as->parms[0].items->data);
        return KABADCMD;
     }
@@ -409,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++;
@@ -431,7 +434,7 @@ parse_flags(char *name, char *inst, char *str, afs_int32 * flags)
                ubik_Call(KAM_GetEntry, conn, 0, name, inst, KAMAJORVERSION,
                          &tentry);
            if (code) {
-               com_err(whoami, code,
+               afs_com_err(whoami, code,
                        "could get current flag value for %s.%s", name, inst);
                return -1;
            }
@@ -512,12 +515,12 @@ ka_islocked(char *name, char *instance, afs_uint32 * when)
     do {
        tempwhen = 0;
        code =
-           ubik_CallIter(KAM_LockStatus, conn, UPUBIKONLY, &count, name,
-                         instance, &tempwhen, /*spares */ 0, 0, 0,
-                         0);
+           ubik_CallIter(KAM_LockStatus, conn, UPUBIKONLY, &count, (long) name,
+                         (long) instance, (long) &tempwhen, 0, 0, 0,
+                         0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        if (code) {
            if (seriouserror(code))
-               com_err(whoami, code, "");
+               afs_com_err(whoami, code, NULL);
        } else if (tempwhen) {  /* user is locked */
            if (!*when || tempwhen < *when) {
                *when = tempwhen;
@@ -532,7 +535,7 @@ ka_islocked(char *name, char *instance, afs_uint32 * when)
 }
 
 int
-Unlock(struct cmd_syndesc *as, char *arock)
+Unlock(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code, rcode = 0;
     afs_int32 count;
@@ -542,22 +545,22 @@ Unlock(struct cmd_syndesc *as, char *arock)
 
     code = ka_ParseLoginName(as->parms[0].items->data, name, instance, 0);
     if (code) {
-       com_err(whoami, code, "parsing user's name '%s'",
+       afs_com_err(whoami, code, "parsing user's name '%s'",
                as->parms[0].items->data);
        return KABADCMD;
     }
 
     count = 0;
     do {
-       code = ubik_CallIter(KAM_Unlock, conn, 0, &count, name, instance,
-                            /*spares */ 0, 0, 0, 0);
+       code = ubik_CallIter(KAM_Unlock, conn, 0, &count, (long) name, (long) instance,
+                            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
        if (code && (code != UNOSERVERS)) {
            server = 0;
            if (conn && conn->conns[count - 1]
                && conn->conns[count - 1]->peer) {
                server = conn->conns[count - 1]->peer->host;
            }
-           com_err(whoami, code,
+           afs_com_err(whoami, code,
                    "so %s.%s may still be locked (on server %d.%d.%d.%d)",
                    name, instance, ((server >> 24) & 0xFF),
                    ((server >> 16) & 0xFF), ((server >> 8) & 0xFF),
@@ -573,7 +576,7 @@ Unlock(struct cmd_syndesc *as, char *arock)
 }
 
 int
-SetFields(struct cmd_syndesc *as, char *arock)
+SetFields(struct cmd_syndesc *as, void *arock)
 {
     int code;
     char name[MAXKTCNAMELEN];
@@ -589,7 +592,7 @@ SetFields(struct cmd_syndesc *as, char *arock)
 
     code = ka_ParseLoginName(as->parms[0].items->data, name, instance, 0);
     if (code) {
-       com_err(whoami, code, "parsing user's name '%s'",
+       afs_com_err(whoami, code, "parsing user's name '%s'",
                as->parms[0].items->data);
        return KABADCMD;
     }
@@ -729,13 +732,13 @@ SetFields(struct cmd_syndesc *as, char *arock)
        return KABADCMD;
     }
     if (code)
-       com_err(whoami, code, "calling KAM_SetFields for %s.%s", name,
+       afs_com_err(whoami, code, "calling KAM_SetFields for %s.%s", name,
                instance);
     return code;
 }
 
 int
-StringToKey(struct cmd_syndesc *as, char *arock)
+StringToKey(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
     char realm[MAXKTCREALMLEN];
@@ -744,13 +747,13 @@ StringToKey(struct cmd_syndesc *as, char *arock)
     if (as->parms[1].items) {
        code = ka_ExpandCell(as->parms[1].items->data, realm, 0 /*local */ );
        if (code) {
-           com_err(whoami, code,
+           afs_com_err(whoami, code,
                    "expanding %s as cell name, attempting to continue",
                    as->parms[1].items->data);
        }
        ucstring(realm, realm, sizeof(realm));
     } else {
-       if (code = DefaultCell())
+       if ((code = DefaultCell()))
            return code;
        ucstring(realm, cell, sizeof(realm));
     }
@@ -761,7 +764,7 @@ StringToKey(struct cmd_syndesc *as, char *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);
@@ -772,7 +775,7 @@ StringToKey(struct cmd_syndesc *as, char *arock)
 }
 
 int
-SetPassword(struct cmd_syndesc *as, char *arock)
+SetPassword(struct cmd_syndesc *as, void *arock)
 {
     int code;
     char name[MAXKTCNAMELEN];
@@ -783,7 +786,7 @@ SetPassword(struct cmd_syndesc *as, char *arock)
 
     code = ka_ParseLoginName(as->parms[0].items->data, name, instance, realm);
     if (code) {
-       com_err(whoami, code, "parsing user's name '%s'",
+       afs_com_err(whoami, code, "parsing user's name '%s'",
                as->parms[0].items->data);
        return KABADCMD;
     }
@@ -824,7 +827,7 @@ SetPassword(struct cmd_syndesc *as, char *arock)
     code = ubik_Call(KAM_SetPassword, conn, 0, name, instance, kvno, key);
 #endif
     if (code)
-       com_err(whoami, code, "so can't set password for %s.%s", name,
+       afs_com_err(whoami, code, "so can't set password for %s.%s", name,
                instance);
     return code;
 }
@@ -849,7 +852,7 @@ PrintName(char *name, char *inst, char *acell, int buflen, char *buf)
     if (left) {
       bad_name:
        code = KABADNAME;
-       com_err(whoami, code, "PrintName: principal name was '%s'.'%s'@'%s'",
+       afs_com_err(whoami, code, "PrintName: principal name was '%s'.'%s'@'%s'",
                name, inst, acell);
        return code;
     }
@@ -919,7 +922,7 @@ ListTicket(struct ktc_principal *server, int verbose)
     /* get the ticket info itself */
     code = ktc_GetToken(server, &token, sizeof(token), &client);
     if (code) {
-       com_err(whoami, code, "failed to get token info for server %s",
+       afs_com_err(whoami, code, "failed to get token info for server %s",
                PrintedPrincipal(server));
        return code;
     }
@@ -963,8 +966,8 @@ ListTicket(struct ktc_principal *server, int verbose)
     return 0;
 }
 
-static
-GetTicket(struct cmd_syndesc *as, char *arock)
+static int
+GetTicket(struct cmd_syndesc *as, void *arock)
 {
     int code;
     struct ktc_principal server;
@@ -980,18 +983,18 @@ GetTicket(struct cmd_syndesc *as, char *arock)
        ka_ParseLoginName(as->parms[0].items->data, server.name,
                          server.instance, server.cell);
     if (code) {
-       com_err(whoami, code, "parsing user's name '%s'",
+       afs_com_err(whoami, code, "parsing user's name '%s'",
                as->parms[0].items->data);
        return KABADCMD;
     }
     if (server.cell[0] == 0) {
-       if (code = DefaultCell())
+       if ((code = DefaultCell()))
            return code;
        strcpy(server.cell, cell);
     } else {
        code = ka_ExpandCell(server.cell, server.cell, 0 /*local */ );
        if (code) {
-           com_err(whoami, code, "Can't expand cell name");
+           afs_com_err(whoami, code, "Can't expand cell name");
            return code;
        }
     }
@@ -1001,7 +1004,7 @@ GetTicket(struct cmd_syndesc *as, char *arock)
        ka_GetServerToken(server.name, server.instance, server.cell, life,
                          &token, /*new */ 1, /*dosetpag */ 0);
     if (code)
-       com_err(whoami, code, "getting ticket for %s",
+       afs_com_err(whoami, code, "getting ticket for %s",
                PrintedPrincipal(&server));
     else {
        code = ListTicket(&server, /*verbose */ 1);
@@ -1009,8 +1012,8 @@ GetTicket(struct cmd_syndesc *as, char *arock)
     return code;
 }
 
-static
-GetPassword(struct cmd_syndesc *as, char *arock)
+static int
+GetPassword(struct cmd_syndesc *as, void *arock)
 {
     int code;
     char name[MAXKTCNAMELEN];
@@ -1021,7 +1024,7 @@ GetPassword(struct cmd_syndesc *as, char *arock)
     code = ka_ParseLoginName(as->parms[0].items->data, name, 0, 0);
     if (code) {
       abort:
-       com_err(whoami, code,
+       afs_com_err(whoami, code,
                "getting %s's password via loopback connection to GetPassword",
                name);
        /* if we got a timeout, print a clarification, too */
@@ -1062,21 +1065,21 @@ GetPassword(struct cmd_syndesc *as, char *arock)
 }
 
 int
-GetRandomKey(struct cmd_syndesc *as, char *arock)
+GetRandomKey(struct cmd_syndesc *as, void *arock)
 {
     int code;
     struct ktc_encryptionKey key;
 
     code = ubik_Call(KAM_GetRandomKey, conn, 0, &key);
     if (code)
-       com_err(whoami, code, "so can't get random key");
+       afs_com_err(whoami, code, "so can't get random key");
     else {
        int i;
        printf("Key: ");
        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)
@@ -1088,7 +1091,7 @@ GetRandomKey(struct cmd_syndesc *as, char *arock)
 }
 
 int
-Statistics(struct cmd_syndesc *as, char *arock)
+Statistics(struct cmd_syndesc *as, void *arock)
 {
     int code;
     kasstats statics;
@@ -1111,7 +1114,8 @@ Statistics(struct cmd_syndesc *as, char *arock)
     printf("Hash table utilization = %f%%\n",
           (double)dynamics.hashTableUtilization / 100.0);
     ka_timestr(dynamics.start_time, bob, KA_TIMESTR_LEN);
-    printf("From host %lx started at %s:\n", dynamics.host, bob);
+    printf("From host %lx started at %s:\n", 
+          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);
@@ -1141,7 +1145,7 @@ Statistics(struct cmd_syndesc *as, char *arock)
 }
 
 int
-DebugInfo(struct cmd_syndesc *as, char *arock)
+DebugInfo(struct cmd_syndesc *as, void *arock)
 {
     int code;
     struct ka_debugInfo info;
@@ -1159,11 +1163,11 @@ DebugInfo(struct cmd_syndesc *as, char *arock)
        if (code) {
            struct afsconf_cell cellinfo;
 
-           com_err(whoami, code, "couldn't find host %s in cell %s",
+           afs_com_err(whoami, code, "couldn't find host %s in cell %s",
                    as->parms[0].items->data, cell);
            code = ka_GetServers(cell, &cellinfo);
            if (code)
-               com_err(whoami, code, "getting servers in cell %s", cell);
+               afs_com_err(whoami, code, "getting servers in cell %s", cell);
            else {
                printf("Servers in cell %s, are:\n", cell);
                for (i = 0; i < cellinfo.numServers; i++)
@@ -1177,7 +1181,7 @@ DebugInfo(struct cmd_syndesc *as, char *arock)
        code = ubik_Call(KAM_Debug, conn, 0, KAMAJORVERSION, 0, &info);
 
     if (code) {
-       com_err(whoami, code, "call to Debug failed");
+       afs_com_err(whoami, code, "call to Debug failed");
        return code;
     }
     now = time(0);
@@ -1201,7 +1205,8 @@ DebugInfo(struct cmd_syndesc *as, char *arock)
             timeOffset, now - start);
     }
     ka_timestr(info.startTime, bob, KA_TIMESTR_LEN);
-    printf("From host %lx started %sat %s:\n", info.host,
+    printf("From host %lx started %sat %s:\n", 
+          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);
@@ -1215,8 +1220,9 @@ DebugInfo(struct cmd_syndesc *as, char *arock)
     printf("Next autoCPW at %s or in %d updates.\n", bob,
           info.updatesRemaining);
     if (info.cheader_lock || info.keycache_lock)
-       printf("locks: cheader %08lx, keycache %08lx\n", info.cheader_lock,
-              info.keycache_lock);
+       printf("locks: cheader %08lx, keycache %08lx\n", 
+               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,
@@ -1237,21 +1243,21 @@ DebugInfo(struct cmd_syndesc *as, char *arock)
 }
 
 int
-Interactive(struct cmd_syndesc *as, char *arock)
+Interactive(struct cmd_syndesc *as, void *arock)
 {
     finished = 0;
     return 0;
 }
 
 int
-Quit(struct cmd_syndesc *as, char *arock)
+Quit(struct cmd_syndesc *as, void *arock)
 {
     finished = 1;
     return 0;
 }
 
 int
-MyAfterProc(struct cmd_syndesc *as)
+MyAfterProc(struct cmd_syndesc *as, void *arock)
 {
     if (!strcmp(as->name, "help"))
        return 0;
@@ -1274,18 +1280,18 @@ char newCell[MAXKTCREALMLEN];
 afs_int32 serverList[MAXSERVERS];
 
 int
-NoAuth(struct cmd_syndesc *as, char *arock)
+NoAuth(struct cmd_syndesc *as, void *arock)
 {
     noauth = 1;
     return 0;
 }
 
 static int
-MyBeforeProc(struct cmd_syndesc *as, char *arock)
+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;
@@ -1332,7 +1338,7 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
                ka_ParseLoginName(as->parms[12].items->data, name, instance,
                                  newCell);
            if (code) {
-               com_err(whoami, code, "parsing user's name '%s'",
+               afs_com_err(whoami, code, "parsing user's name '%s'",
                        as->parms[12].items->data);
                return code;
            }
@@ -1363,7 +1369,7 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
        }
        code = ka_ExpandCell(newCell, newCell, 0 /*local */ );
        if (code) {
-           com_err(whoami, code, "Can't expand cell name");
+           afs_com_err(whoami, code, "Can't expand cell name");
            return code;
        }
        strcpy(cell, newCell);
@@ -1378,7 +1384,7 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
                ap[i] = ip->data;
            code = ubik_ParseClientList(i, ap, serverList);
            if (code) {
-               com_err(whoami, code, "could not parse server list");
+               afs_com_err(whoami, code, "could not parse server list");
                return code;
            }
            ka_ExplicitCell(cell, serverList);
@@ -1412,7 +1418,7 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
                else if (strlen(passwd) == 0)
                    code = KANULLPASSWORD;
                if (code) {
-                   com_err(whoami, code, "reading password");
+                   afs_com_err(whoami, code, "reading password");
                    return code;
                }
            }
@@ -1421,7 +1427,7 @@ MyBeforeProc(struct cmd_syndesc *as, char *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 */ );
@@ -1453,7 +1459,7 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
                    reason = "Authentication Server was unavailable";
                    break;
                default:
-                   reason = (char *)error_message(code);
+                   reason = (char *)afs_error_message(code);
                }
                fprintf(stderr,
                        "%s: Auth. as %s to AuthServer failed: %s\nProceeding w/o authentication\n",
@@ -1474,7 +1480,7 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
                                    /*Don't need pwd expiration info here */
                    );
                if (acode && (acode != code))   /* codes are usually the same */
-                   com_err(whoami, code,
+                   afs_com_err(whoami, code,
                            "getting Authentication token for %s",
                            PrintedName(name, instance, cell));
            }
@@ -1485,15 +1491,15 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
     pToken = ((token.ticketLen == 0) ? 0 : &token);
     code = ka_AuthServerConn(cell, KA_MAINTENANCE_SERVICE, pToken, &conn);
     if (code && pToken) {
-       com_err(whoami, code,
+       afs_com_err(whoami, code,
                "connecting to AuthServer: now trying w/o authentication");
        code = ka_AuthServerConn(cell, KA_MAINTENANCE_SERVICE, 0, &conn);
        if (code)
-           com_err(whoami, code,
+           afs_com_err(whoami, code,
                    "making unauthenticated connection to AuthServer");
     }
     if (code) {
-       com_err(whoami, code,
+       afs_com_err(whoami, code,
                "Couldn't establish connection to Authentication Server");
        return code;
     }
@@ -1518,7 +1524,7 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
                    else if (strlen(password) == 0)
                        code = KANULLPASSWORD;
                    if (code) {
-                       com_err(whoami, code, "prompting for %s", p + 1);
+                       afs_com_err(whoami, code, "prompting for %s", p + 1);
                        return code;
                    }
                    ip = (struct cmd_item *)malloc(sizeof(struct cmd_item));
@@ -1538,8 +1544,8 @@ MyBeforeProc(struct cmd_syndesc *as, char *arock)
 
 /* These are some helpful command that deal with the cache managers tokens. */
 
-static
-ForgetTicket(struct cmd_syndesc *as, char *arock)
+static int
+ForgetTicket(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
 
@@ -1552,7 +1558,7 @@ ForgetTicket(struct cmd_syndesc *as, char *arock)
            ka_ParseLoginName(name, server.name, server.instance,
                              server.cell);
        if (code) {
-           com_err(whoami, code, "couldn't interpret name '%s'", name);
+           afs_com_err(whoami, code, "couldn't interpret name '%s'", name);
            return code;
        }
        if (server.cell[0] == 0) {
@@ -1562,13 +1568,13 @@ ForgetTicket(struct cmd_syndesc *as, char *arock)
        } else {
            code = ka_ExpandCell(server.cell, server.cell, 0 /*local */ );
            if (code) {
-               com_err(whoami, code, "Can't expand cell name");
+               afs_com_err(whoami, code, "Can't expand cell name");
                return code;
            }
        }
        code = ktc_ForgetToken(&server);
        if (code) {
-           com_err(whoami, code, "couldn't remove tokens for %s",
+           afs_com_err(whoami, code, "couldn't remove tokens for %s",
                    PrintedPrincipal(&server));
            return code;
        }
@@ -1579,21 +1585,21 @@ ForgetTicket(struct cmd_syndesc *as, char *arock)
        }
        code = ktc_ForgetAllTokens();
        if (code) {
-           com_err(whoami, code, "couldn't delete all tokens");
+           afs_com_err(whoami, code, "couldn't delete all tokens");
            return code;
        }
     }
 #endif
     code = ktc_ForgetAllTokens();
     if (code) {
-       com_err(whoami, code, "couldn't delete all tokens");
+       afs_com_err(whoami, code, "couldn't delete all tokens");
        return code;
     }
     return 0;
 }
 
-static
-ListTickets(struct cmd_syndesc *as, char *arock)
+static int
+ListTickets(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code = 0;
     int index, newIndex;
@@ -1608,17 +1614,17 @@ ListTickets(struct cmd_syndesc *as, char *arock)
            ka_ParseLoginName(name, server.name, server.instance,
                              server.cell);
        if (code) {
-           com_err(whoami, code, "couldn't interpret name '%s'", name);
+           afs_com_err(whoami, code, "couldn't interpret name '%s'", name);
            return code;
        }
        if (server.cell[0] == 0) {
-           if (code = DefaultCell())
+           if ((code = DefaultCell()))
                return code;
            strcpy(server.cell, cell);
        } else {
            code = ka_ExpandCell(server.cell, server.cell, 0 /*local */ );
            if (code) {
-               com_err(whoami, code, "Can't expand cell name");
+               afs_com_err(whoami, code, "Can't expand cell name");
                return code;
            }
        }
@@ -1666,14 +1672,15 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
     cmd_SetBeforeProc(MyBeforeProc, NULL);
     cmd_SetAfterProc(MyAfterProc, NULL);
 
-    ts = cmd_CreateSyntax("interactive", Interactive, 0,
+    ts = cmd_CreateSyntax("interactive", Interactive, NULL,
                          "enter interactive mode");
     add_std_args(ts);
 
-    ts = cmd_CreateSyntax("noauthentication", NoAuth, 0,
+    ts = cmd_CreateSyntax("noauthentication", NoAuth, NULL,
                          "connect to AuthServer w/o using token");
 
-    ts = cmd_CreateSyntax("list", ListUsers, 0, "list all users in database");
+    ts = cmd_CreateSyntax("list", ListUsers, NULL, 
+                         "list all users in database");
     cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
                "show detailed info about each user");
     cmd_AddParm(ts, "-showadmin", CMD_FLAG, CMD_OPTIONAL,
@@ -1683,26 +1690,26 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
     add_std_args(ts);
     cmd_CreateAlias(ts, "ls");
 
-    ts = cmd_CreateSyntax("examine", ExamineUser, 0,
+    ts = cmd_CreateSyntax("examine", ExamineUser, NULL,
                          "examine the entry for a user");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of user");
     cmd_AddParm(ts, "-showkey", CMD_FLAG, CMD_OPTIONAL,
                "show the user's actual key rather than the checksum");
     add_std_args(ts);
 
-    ts = cmd_CreateSyntax("create", CreateUser, 0,
+    ts = cmd_CreateSyntax("create", CreateUser, NULL,
                          "create an entry for a user");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of user");
     cmd_AddParm(ts, "-initial_password", CMD_SINGLE, CMD_OPTIONAL,
                "initial password");
     add_std_args(ts);
 
-    ts = cmd_CreateSyntax("delete", DeleteUser, 0, "delete a user");
+    ts = cmd_CreateSyntax("delete", DeleteUser, NULL, "delete a user");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of user");
     add_std_args(ts);
     cmd_CreateAlias(ts, "rm");
 
-    ts = cmd_CreateSyntax("setfields", SetFields, 0,
+    ts = cmd_CreateSyntax("setfields", SetFields, NULL,
                          "set various fields in a user's entry");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of user");
     cmd_AddParm(ts, "-flags", CMD_SINGLE, CMD_OPTIONAL,
@@ -1727,18 +1734,18 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
     cmd_CreateAlias(ts, "sf");
 
 
-    ts = cmd_CreateSyntax("unlock", Unlock, 0,
+    ts = cmd_CreateSyntax("unlock", Unlock, NULL,
                          "Enable authentication ID after max failed attempts exceeded");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "authentication ID");
     add_std_args(ts);
 
 
-    ts = cmd_CreateSyntax("stringtokey", StringToKey, 0,
+    ts = cmd_CreateSyntax("stringtokey", StringToKey, NULL,
                          "convert a string to a key");
     cmd_AddParm(ts, "-string", CMD_SINGLE, 0, "password string");
     cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
 
-    ts = cmd_CreateSyntax("setpassword", SetPassword, 0,
+    ts = cmd_CreateSyntax("setpassword", SetPassword, NULL,
                          "set a user's password");
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of user");
     cmd_AddParm(ts, "-new_password", CMD_SINGLE, CMD_OPTIONAL,
@@ -1752,7 +1759,7 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
 #endif
 
     /* set a user's key */
-    ts = cmd_CreateSyntax("setkey", SetPassword, 0, (char *)CMD_HIDDEN);
+    ts = cmd_CreateSyntax("setkey", SetPassword, NULL, (char *)CMD_HIDDEN);
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of user");
     cmd_Seek(ts, 2);
     cmd_AddParm(ts, "-new_key", CMD_SINGLE, 0, "eight byte new key");
@@ -1761,7 +1768,7 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
     add_std_args(ts);
 
     /* get a user's password */
-    ts = cmd_CreateSyntax("getpassword", GetPassword, 0, (char *)CMD_HIDDEN);
+    ts = cmd_CreateSyntax("getpassword", GetPassword, NULL, (char *)CMD_HIDDEN);
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of user");
     /* don't take standard args */
     /* add_std_args (ts); */
@@ -1770,27 +1777,27 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
 #endif
 
     /* get a random key */
-    ts = cmd_CreateSyntax("getrandomkey", GetRandomKey, 0,
+    ts = cmd_CreateSyntax("getrandomkey", GetRandomKey, NULL,
                          (char *)CMD_HIDDEN);
     add_std_args(ts);
 
     /* get a ticket for a specific server */
-    ts = cmd_CreateSyntax("getticket", GetTicket, 0, (char *)CMD_HIDDEN);
+    ts = cmd_CreateSyntax("getticket", GetTicket, NULL, (char *)CMD_HIDDEN);
     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "name of server");
     cmd_AddParm(ts, "-lifetime", CMD_SINGLE, CMD_OPTIONAL, "ticket lifetime");
     add_std_args(ts);
 
-    ts = cmd_CreateSyntax("statistics", Statistics, 0,
+    ts = cmd_CreateSyntax("statistics", Statistics, NULL,
                          "show statistics for AuthServer");
     add_std_args(ts);
 
     /* show debugging info from AuthServer */
-    ts = cmd_CreateSyntax("debuginfo", DebugInfo, 0, (char *)CMD_HIDDEN);
+    ts = cmd_CreateSyntax("debuginfo", DebugInfo, NULL, (char *)CMD_HIDDEN);
     cmd_AddParm(ts, "-hostname", CMD_SINGLE, CMD_OPTIONAL,
                "authentication server host name");
     add_std_args(ts);
 
-    ts = cmd_CreateSyntax("forgetticket", ForgetTicket, 0,
+    ts = cmd_CreateSyntax("forgetticket", ForgetTicket, NULL,
                          "delete user's tickets");
 #ifdef notdef
     cmd_AddParm(ts, "-name", CMD_SINGLE, (CMD_OPTIONAL | CMD_HIDE),
@@ -1798,13 +1805,13 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
 #endif
     cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all tickets");
 
-    ts = cmd_CreateSyntax("listtickets", ListTickets, 0,
+    ts = cmd_CreateSyntax("listtickets", ListTickets, NULL,
                          "show all cache manager tickets");
     cmd_AddParm(ts, "-name", CMD_SINGLE, CMD_OPTIONAL, "name of server");
     cmd_AddParm(ts, "-long", CMD_FLAG, CMD_OPTIONAL,
                "show session key and ticket");
 
-    ts = cmd_CreateSyntax("quit", Quit, 0, "exit program");
+    ts = cmd_CreateSyntax("quit", Quit, NULL, "exit program");
 
     finished = 1;
     conn = 0;                  /* no connection yet */
@@ -1813,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;
     }
 
@@ -1833,7 +1840,7 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
        code =
            cmd_ParseLine(line, argv, &argc, sizeof(argv) / sizeof(argv[0]));
        if (code) {
-           com_err(whoami, code, "parsing line: '%s'", line);
+           afs_com_err(whoami, code, "parsing line: '%s'", line);
            return code;
        }
        code = cmd_Dispatch(argc, argv);