kauth: Don't ignore GetExtendedCellInfo failures
[openafs.git] / src / kauth / kaserver.c
index df5a485..2fca96a 100644 (file)
@@ -12,6 +12,7 @@
 #include <afs/stds.h>
 
 #include <roken.h>
+#include <afs/opr.h>
 
 #ifdef AFS_NT40_ENV
 #include <WINNT/afsevent.h>
@@ -54,7 +55,6 @@ struct afsconf_dir *KA_conf;  /* for getting cell info */
 int MinHours = 0;
 int npwSums = KA_NPWSUMS;      /* needs to be variable sometime */
 
-#include <stdarg.h>
 #if !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
 #undef vfprintf
 #define vfprintf(stream,fmt,args) _doprnt(fmt,args,stream)
@@ -69,6 +69,25 @@ KA_rxstat_userok(struct rx_call *call)
     return afsconf_SuperUser(KA_conf, call, NULL);
 }
 
+/**
+ * Return true if this name is a member of the local realm.
+ */
+static int
+KA_IsLocalRealmMatch(void *rock, char *name, char *inst, char *cell)
+{
+    struct afsconf_dir *dir = (struct afsconf_dir *)rock;
+    afs_int32 islocal = 0;     /* default to no */
+    int code;
+
+    code = afsconf_IsLocalRealmMatch(dir, &islocal, name, inst, cell);
+    if (code) {
+       ViceLog(0,
+               ("Failed local realm check; code=%d, name=%s, inst=%s, cell=%s\n",
+                code, name, inst, cell));
+    }
+    return islocal;
+}
+
 afs_int32
 es_Report(char *fmt, ...)
 {
@@ -207,7 +226,7 @@ main(int argc, char *argv[])
     cellservdb = AFSDIR_SERVER_ETC_DIRPATH;
     dbpath = AFSDIR_SERVER_KADB_FILEPATH;
     strcompose(default_lclpath, AFSDIR_PATH_MAX, AFSDIR_SERVER_LOCAL_DIRPATH,
-              "/", AFSDIR_KADB_FILE, NULL);
+              "/", AFSDIR_KADB_FILE, (char *)NULL);
     lclpath = default_lclpath;
 
     debugOutput = 0;
@@ -309,9 +328,13 @@ main(int argc, char *argv[])
            "Migrating to a Kerberos 5 KDC is advised.  "
            "http://www.openafs.org/no-more-des.html\n"));
 
-    code =
-       afsconf_GetExtendedCellInfo(KA_conf, cell, AFSCONF_KAUTHSERVICE,
-                                   &cellinfo, clones);
+    code = afsconf_GetExtendedCellInfo(KA_conf, cell, AFSCONF_KAUTHSERVICE,
+                                      &cellinfo, clones);
+    if (code) {
+       afs_com_err(whoami, code, "Couldn't read cell configuration");
+       exit(1);
+    }
+
     if (servers) {
        if ((code = ubik_ParseServerList(argc, argv, &myHost, serverList))) {
            afs_com_err(whoami, code, "Couldn't parse server list");
@@ -331,6 +354,9 @@ main(int argc, char *argv[])
        ViceLog(0, ("Using server list from %s cell database.\n", cell));
     }
 
+    /* initialize audit user check */
+    osi_audit_set_user_check(KA_conf, KA_IsLocalRealmMatch);
+
     /* initialize ubik */
     if (level == rxkad_clear)
        ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate,
@@ -357,10 +383,10 @@ main(int argc, char *argv[])
         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);
+            ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+                                          ADDRSPERSITE, reason,
+                                          AFSDIR_SERVER_NETINFO_FILEPATH,
+                                          AFSDIR_SERVER_NETRESTRICT_FILEPATH);
         } else
        {
             ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
@@ -371,6 +397,9 @@ main(int argc, char *argv[])
        }
     }
 
+    /* Disable jumbograms */
+    rx_SetNoJumbo();
+
     if (servers)
        code =
            ubik_ServerInit(myHost, htons(AFSCONF_KAUTHPORT), serverList,
@@ -387,9 +416,6 @@ main(int argc, char *argv[])
 
     sca[RX_SCINDEX_NULL] = rxnull_NewServerSecurityObject();
 
-    /* Disable jumbograms */
-    rx_SetNoJumbo();
-
     tservice =
        rx_NewServiceHost(host, 0, KA_AUTHENTICATION_SERVICE,
                          "AuthenticationService", sca, 1, KAA_ExecuteRequest);