vlserver-checksignal-returns-voidstar-20080401
[openafs.git] / src / vlserver / vlserver.c
index 9d1a9f1..7bcdfb6 100644 (file)
@@ -17,6 +17,7 @@ RCSID
 #include <sys/types.h>
 #include <signal.h>
 #include <sys/stat.h>
+#include <string.h>
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
 #endif
@@ -36,14 +37,6 @@ RCSID
 #endif
 #include <stdio.h>
 
-#ifdef HAVE_STRING_H
-#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
-
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
@@ -67,10 +60,16 @@ afs_uint32 HostAddress[MAXSERVERID + 1];
 extern int afsconf_CheckAuth();
 extern int afsconf_ServerAuth();
 
-static CheckSignal();
+static void *CheckSignal(void*);
 int LogLevel = 0;
 int smallMem = 0;
 int rxJumbograms = 1;          /* default is to send and receive jumbo grams */
+int rxMaxMTU = -1;
+afs_int32 rxBind = 0;
+int rxkadDisableDotCheck = 0;
+
+#define ADDRSPERSITE 16         /* Same global is in rx/rx_user.c */
+afs_uint32 SHostAddrs[ADDRSPERSITE];
 
 static void
 CheckSignal_Signal()
@@ -78,15 +77,15 @@ CheckSignal_Signal()
     IOMGR_SoftSig(CheckSignal, 0);
 }
 
-static
-CheckSignal()
+static void *
+CheckSignal(void *unused)
 {
     register int i, errorcode;
     struct ubik_trans *trans;
 
     if (errorcode =
        Init_VLdbase(&trans, LOCKREAD, VLGETSTATS - VL_LOWEST_OPCODE))
-       return errorcode;
+       return (void *)errorcode;
     VLog(0, ("Dump name hash table out\n"));
     for (i = 0; i < HASHSIZE; i++) {
        HashNDump(trans, i);
@@ -95,7 +94,7 @@ CheckSignal()
     for (i = 0; i < HASHSIZE; i++) {
        HashIdDump(trans, i);
     }
-    return (ubik_EndTrans(trans));
+    return ((void *)ubik_EndTrans(trans));
 }                              /*CheckSignal */
 
 
@@ -143,6 +142,7 @@ main(argc, argv)
     extern int rx_extraPackets;
     char commandLine[150];
     char clones[MAXHOSTSPERCELL];
+    afs_uint32 host = ntohl(INADDR_ANY);
 
 #ifdef AFS_AIX32_ENV
     /*
@@ -160,6 +160,8 @@ main(argc, argv)
     sigaction(SIGABRT, &nsa, NULL);
     sigaction(SIGSEGV, &nsa, NULL);
 #endif
+    osi_audit_init();
+
     /* Parse command line */
     for (index = 1; index < argc; index++) {
        if (strcmp(argv[index], "-noauth") == 0) {
@@ -176,6 +178,24 @@ main(argc, argv)
        } else if (strcmp(argv[index], "-nojumbo") == 0) {
            rxJumbograms = 0;
 
+       } else if (strcmp(argv[index], "-rxbind") == 0) {
+           rxBind = 1;
+       } else if (strcmp(argv[index], "-allow-dotted-principals") == 0) {
+           rxkadDisableDotCheck = 1;
+       } else if (!strcmp(argv[index], "-rxmaxmtu")) {
+           if ((index + 1) >= argc) {
+               fprintf(stderr, "missing argument for -rxmaxmtu\n"); 
+               return -1; 
+           }
+           rxMaxMTU = atoi(argv[++i]);
+           if ((rxMaxMTU < RX_MIN_PACKET_SIZE) || 
+               (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
+               printf("rxMaxMTU %d invalid; must be between %d-%d\n",
+                      rxMaxMTU, RX_MIN_PACKET_SIZE, 
+                      RX_MAX_PACKET_DATA_SIZE);
+               return -1;
+           }
+
        } else if (strcmp(argv[index], "-smallmem") == 0) {
            smallMem = 1;
 
@@ -228,12 +248,14 @@ main(argc, argv)
            /* support help flag */
 #ifndef AFS_NT40_ENV
            printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
+                  "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
                   "[-auditlog <log path>] "
                   "[-syslog[=FACILITY]] "
                   "[-enable_peer_stats] [-enable_process_stats] "
                   "[-help]\n");
 #else
            printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
+                  "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
                   "[-auditlog <log path>] "
                   "[-enable_peer_stats] [-enable_process_stats] "
                   "[-help]\n");
@@ -285,7 +307,7 @@ main(argc, argv)
     }
     memcpy(&myHost, th->h_addr, sizeof(afs_int32));
 
-#if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV) && !defined(AFS_DJGPP_ENV)
+#if !defined(AFS_HPUX_ENV) && !defined(AFS_NT40_ENV)
     signal(SIGXCPU, CheckSignal_Signal);
 #endif
     /* get list of servers */
@@ -304,6 +326,27 @@ main(argc, argv)
     if (noAuth)
        afsconf_SetNoAuthFlag(tdir, 1);
 
+    if (rxBind) {
+       afs_int32 ccode;
+#ifndef AFS_NT40_ENV
+        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 
+#endif 
+       {
+            ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
+        }
+        if (ccode == 1) {
+            host = SHostAddrs[0];
+           rx_InitHost(host, htons(AFSCONF_VLDBPORT));
+       }
+    }
+
     ubik_nBuffers = 512;
     ubik_CRXSecurityProc = afsconf_ClientAuth;
     ubik_CRXSecurityRock = (char *)tdir;
@@ -321,6 +364,9 @@ main(argc, argv)
     if (!rxJumbograms) {
        rx_SetNoJumbo();
     }
+    if (rxMaxMTU != -1) {
+       rx_SetMaxMTU(rxMaxMTU);
+    }
     rx_SetRxDeadTime(50);
 
     memset(HostAddress, 0, sizeof(HostAddress));
@@ -329,8 +375,9 @@ main(argc, argv)
     sc[0] = rxnull_NewServerSecurityObject();
     sc[1] = (struct rx_securityClass *)0;
     sc[2] = rxkad_NewServerSecurityObject(0, tdir, afsconf_GetKey, NULL);
+
     tservice =
-       rx_NewService(0, USER_SERVICE_ID, "Vldb server", sc, 3,
+       rx_NewServiceHost(host, 0, USER_SERVICE_ID, "Vldb server", sc, 3,
                      VL_ExecuteRequest);
     if (tservice == (struct rx_service *)0) {
        printf("vlserver: Could not create VLDB_SERVICE rx service\n");
@@ -341,8 +388,14 @@ main(argc, argv)
        lwps = 4;
     rx_SetMaxProcs(tservice, lwps);
 
+    if (rxkadDisableDotCheck) {
+        rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
+                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK,
+                                    NULL);
+    }
+
     tservice =
-       rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 3,
+       rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats", sc, 3,
                      RXSTATS_ExecuteRequest);
     if (tservice == (struct rx_service *)0) {
        printf("vlserver: Could not create rpc stats rx service\n");
@@ -364,4 +417,6 @@ main(argc, argv)
     rx_SetRxStatUserOk(vldb_rxstat_userok);
 
     rx_StartServer(1);         /* Why waste this idle process?? */
+
+    return 0; /* not reachable */
 }