Whine if single-DES keys are in use
[openafs.git] / src / ptserver / ptserver.c
index 0b473af..9db47a2 100644 (file)
@@ -146,8 +146,6 @@ struct afsconf_dir *prdir;
 extern afs_int32 depthsg;
 #endif
 
-char *pr_realmName;
-
 int restricted = 0;
 int rxMaxMTU = -1;
 int rxBind = 0;
@@ -192,6 +190,25 @@ pr_rxstat_userok(struct rx_call *call)
     return afsconf_SuperUser(prdir, call, NULL);
 }
 
+/**
+ * Return true if this name is a member of the local realm.
+ */
+int
+pr_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;
+}
+
+
 enum optionsList {
     OPT_database,
     OPT_access,
@@ -337,6 +354,11 @@ main(int argc, char **argv)
     if (code)
        PT_EXIT(1);
 
+    cmd_OptionAsString(opts, OPT_config, &configDir);
+
+    cmd_OpenConfigFile(AFSDIR_SERVER_CONFIG_FILE_FILEPATH);
+    cmd_SetCommandName("ptserver");
+
     if (cmd_OptionAsList(opts, OPT_access, &list) == 0) {
        prp_user_default = prp_access_mask(list->data);
        if (list->next == NULL || list->next->data == NULL) {
@@ -363,16 +385,15 @@ main(int argc, char **argv)
        free(interface);
     }
 
-    cmd_OptionAsString(opts, OPT_config, &configDir);
     cmd_OptionAsInt(opts, OPT_debug, &LogLevel);
     cmd_OptionAsString(opts, OPT_database, &pr_dbaseName);
     cmd_OptionAsString(opts, OPT_logfile, &logFile);
 
     if (cmd_OptionAsInt(opts, OPT_threads, &lwps) == 0) {
-       if (lwps > 16) {        /* maximum of 16 */
+       if (lwps > 64) {        /* maximum of 64 */
            printf("Warning: '-p %d' is too big; using %d instead\n",
-                  lwps, 16);
-           lwps = 16;
+                  lwps, 64);
+           lwps = 64;
        } else if (lwps < 3) {  /* minimum of 3 */
            printf("Warning: '-p %d' is too small; using %d instead\n",
                   lwps, 3);
@@ -447,7 +468,9 @@ main(int argc, char **argv)
        afs_com_err(whoami, code, "Couldn't get server list");
        PT_EXIT(2);
     }
-    pr_realmName = info.name;
+
+    /* initialize audit user check */
+    osi_audit_set_user_check(prdir, pr_IsLocalRealmMatch);
 
     /* initialize ubik */
     ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate, prdir);
@@ -469,10 +492,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);
@@ -487,6 +510,16 @@ main(int argc, char **argv)
        }
     }
 
+    /* Disable jumbograms */
+    rx_SetNoJumbo();
+
+    if (rxMaxMTU != -1) {
+       if (rx_SetMaxMTU(rxMaxMTU) != 0) {
+           printf("rxMaxMTU %d is invalid\n", rxMaxMTU);
+           PT_EXIT(1);
+       }
+    }
+
     code =
        ubik_ServerInitByInfo(myHost, htons(AFSCONF_PROTPORT), &info, clones,
                              pr_dbaseName, &dbase);
@@ -494,22 +527,13 @@ main(int argc, char **argv)
        afs_com_err(whoami, code, "Ubik init failed");
        PT_EXIT(2);
     }
+
 #if defined(SUPERGROUPS)
     pt_hook_write();
 #endif
 
     afsconf_BuildServerSecurityObjects(prdir, &securityClasses, &numClasses);
 
-    /* Disable jumbograms */
-    rx_SetNoJumbo();
-
-    if (rxMaxMTU != -1) {
-       if (rx_SetMaxMTU(rxMaxMTU) != 0) {
-           printf("rxMaxMTU %d is invalid\n", rxMaxMTU);
-           PT_EXIT(1);
-       }
-    }
-
     tservice =
        rx_NewServiceHost(host, 0, PRSRV, "Protection Server", securityClasses,
                          numClasses, PR_ExecuteRequest);
@@ -544,6 +568,9 @@ main(int argc, char **argv)
                   "1.0",
 #endif
                   "Starting AFS", FSLog);
+    if (afsconf_GetLatestKey(prdir, NULL, NULL) == 0) {
+       LogDesWarning();
+    }
 
     rx_StartServer(1);
     osi_audit(PTS_FinishEvent, -1, AUD_END);