ubik: Allow servers to have more than 3 seclayers
[openafs.git] / src / kauth / kaserver.c
index cce632e..a058dc4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
@@ -10,6 +10,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#include <roken.h>
 
 #include <afs/stds.h>
 #include <sys/types.h>
@@ -45,6 +46,7 @@
 #include <ubik.h>
 #include <sys/stat.h>
 #include "kauth.h"
+#include "kauth_internal.h"
 #include "kautils.h"
 #include "kaserver.h"
 #include "kadatabase.h"
@@ -52,7 +54,7 @@
 
 struct kadstats dynamic_statistics;
 struct ubik_dbase *KA_dbase;
-afs_int32 myHost = 0;
+afs_uint32 myHost = 0;
 afs_int32 verbose_track = 1;
 afs_int32 krb4_cross = 0;
 afs_int32 rxBind = 0;
@@ -102,8 +104,8 @@ initialize_dstats(void)
 }
 
 static int
-convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_int32 *myHost,
-                    afs_int32 *serverList)
+convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_uint32 *myHost,
+                    afs_uint32 *serverList)
 {
     int i;
     char hostname[64];
@@ -116,7 +118,7 @@ convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_int32 *myHost,
        ViceLog(0, ("kaserver: couldn't get address of this host.\n"));
        exit(1);
     }
-    memcpy(myHost, th->h_addr, sizeof(afs_int32));
+    memcpy(myHost, th->h_addr, sizeof(afs_uint32));
 
     for (i = 0; i < cellinfo->numServers; i++)
        if (cellinfo->hostAddr[i].sin_addr.s_addr != *myHost) {
@@ -149,7 +151,7 @@ main(int argc, char *argv[])
 {
     afs_int32 code;
     char *whoami = argv[0];
-    afs_int32 serverList[MAXSERVERS];
+    afs_uint32 serverList[MAXSERVERS];
     struct afsconf_cell cellinfo;
     char *cell;
     const char *cellservdb, *dbpath, *lclpath;
@@ -172,8 +174,8 @@ main(int argc, char *argv[])
 
 #ifdef AFS_AIX32_ENV
     /*
-     * The following signal action for AIX is necessary so that in case of a 
-     * crash (i.e. core is generated) we can include the user's data section 
+     * The following signal action for AIX is necessary so that in case of a
+     * crash (i.e. core is generated) we can include the user's data section
      * in the core dump. Unfortunately, by default, only a partial core is
      * generated which, in many cases, isn't too useful.
      */
@@ -189,7 +191,7 @@ main(int argc, char *argv[])
 
     if (argc == 0) {
       usage:
-       printf("Usage: kaserver [-noAuth] [-fastKeys] [-database <dbpath>] "
+       printf("Usage: kaserver [-noAuth] [-database <dbpath>] "
               "[-auditlog <log path>] [-audit-interface <file|sysvmq>] "
               "[-rxbind] [-localfiles <lclpath>] [-minhours <n>] "
               "[-servers <serverlist>] [-crossrealm] "
@@ -245,7 +247,7 @@ main(int argc, char *argv[])
                printf("Invalid audit interface '%s'\n", interface);
                exit(1);
            }
-           
+
        } else if (strcmp(arg, "-localfiles") == 0)
            lclpath = argv[++a];
        else if (strcmp(arg, "-servers") == 0)
@@ -307,7 +309,7 @@ main(int argc, char *argv[])
 #else
     /* NT & HPUX do not have dbm package support. So we can only do some
      * text logging. So open the AuthLog file for logging and redirect
-     * stdin and stdout to it 
+     * stdin and stdout to it
      */
     OpenLog(AFSDIR_SERVER_KALOG_FILEPATH);
     SetupLogSignals();
@@ -322,7 +324,7 @@ main(int argc, char *argv[])
 
     code =
        afsconf_GetExtendedCellInfo(KA_conf, cell, AFSCONF_KAUTHSERVICE,
-                                   &cellinfo, &clones);
+                                   &cellinfo, clones);
     if (servers) {
        if ((code = ubik_ParseServerList(argc, argv, &myHost, serverList))) {
            afs_com_err(whoami, code, "Couldn't parse server list");
@@ -344,9 +346,11 @@ main(int argc, char *argv[])
 
     /* initialize ubik */
     if (level == rxkad_clear)
-       ubik_CRXSecurityProc = afsconf_ClientAuth;
+       ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate,
+                                   KA_conf);
     else if (level == rxkad_crypt)
-       ubik_CRXSecurityProc = afsconf_ClientAuthSecure;
+       ubik_SetClientSecurityProcs(afsconf_ClientAuthSecure,
+                                   afsconf_UpToDate, KA_conf);
     else {
        ViceLog(0, ("Unsupported security level %d\n", level));
        exit(5);
@@ -354,24 +358,23 @@ main(int argc, char *argv[])
     ViceLog(0,
            ("Using level %s for Ubik connections.\n",
             (level == rxkad_crypt ? "crypt" : "clear")));
-    ubik_CRXSecurityRock = (char *)KA_conf;
-    ubik_SRXSecurityProc = afsconf_ServerAuth;
-    ubik_SRXSecurityRock = (char *)KA_conf;
-    ubik_CheckRXSecurityProc = afsconf_CheckAuth;
-    ubik_CheckRXSecurityRock = (char *)KA_conf;
+
+    ubik_SetServerSecurityProcs(afsconf_BuildServerSecurityObjects,
+                               afsconf_CheckAuth,
+                               KA_conf);
 
     ubik_nBuffers = 80;
 
     if (rxBind) {
        afs_int32 ccode;
-        if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
+        if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
             AFSDIR_SERVER_NETINFO_FILEPATH) {
             char reason[1024];
             ccode = parseNetFiles(SHostAddrs, NULL, NULL,
                                            ADDRSPERSITE, reason,
                                            AFSDIR_SERVER_NETINFO_FILEPATH,
                                            AFSDIR_SERVER_NETRESTRICT_FILEPATH);
-        } else 
+        } else
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
         }
@@ -384,11 +387,11 @@ main(int argc, char *argv[])
     if (servers)
        code =
            ubik_ServerInit(myHost, htons(AFSCONF_KAUTHPORT), serverList,
-                           (char *)dbpath, &KA_dbase);
+                           dbpath, &KA_dbase);
     else
        code =
            ubik_ServerInitByInfo(myHost, htons(AFSCONF_KAUTHPORT), &cellinfo,
-                                 clones, (char *)dbpath, &KA_dbase);
+                                 clones, dbpath, &KA_dbase);
 
     if (code) {
        afs_com_err(whoami, code, "Ubik init failed");
@@ -401,7 +404,7 @@ main(int argc, char *argv[])
     rx_SetNoJumbo();
 
     tservice =
-       rx_NewServiceHost(host, 0, KA_AUTHENTICATION_SERVICE, 
+       rx_NewServiceHost(host, 0, KA_AUTHENTICATION_SERVICE,
                          "AuthenticationService", sca, 1, KAA_ExecuteRequest);
     if (tservice == (struct rx_service *)0) {
        ViceLog(0, ("Could not create Authentication rx service\n"));
@@ -410,7 +413,7 @@ main(int argc, char *argv[])
     rx_SetMinProcs(tservice, 1);
     rx_SetMaxProcs(tservice, 1);
 
-    
+
     tservice =
        rx_NewServiceHost(host, 0, KA_TICKET_GRANTING_SERVICE, "TicketGrantingService",
                      sca, 1, KAT_ExecuteRequest);