netrestrict-netinfo-20081129
[openafs.git] / src / ptserver / ptserver.c
index 8878fc0..d2ee077 100644 (file)
@@ -129,13 +129,7 @@ RCSID
 #include <netdb.h>
 #include <netinet/in.h>
 #endif
-#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>
@@ -166,9 +160,11 @@ extern int afsconf_CheckAuth();
 int pr_realmNameLen;
 char *pr_realmName;
 
+int debuglevel = 0;
 int restricted = 0;
 int rxMaxMTU = -1;
 int rxBind = 0;
+int rxkadDisableDotCheck = 0;
 
 #define ADDRSPERSITE 16         /* Same global is in rx/rx_user.c */
 afs_uint32 SHostAddrs[ADDRSPERSITE];
@@ -285,6 +281,13 @@ main(int argc, char **argv)
        if ((strncmp(arg, "-database", alen) == 0)
            || (strncmp(arg, "-db", alen) == 0)) {
            pr_dbaseName = argv[++a];   /* specify a database */
+       } else if (strcmp(argv[a], "-d") == 0) {
+           if ((a + 1) >= argc) {
+               fprintf(stderr, "missing argument for -d\n"); 
+               return -1; 
+           }
+           debuglevel = atoi(argv[++a]);
+           LogLevel = debuglevel;
        } else if (strncmp(arg, "-p", alen) == 0) {
            lwps = atoi(argv[++a]);
            if (lwps > 16) {    /* maximum of 16 */
@@ -314,6 +317,9 @@ main(int argc, char **argv)
        else if (strncmp(arg, "-rxbind", alen) == 0) {
            rxBind = 1;
        }
+       else if (strncmp(arg, "-allow-dotted-principals", alen) == 0) {
+           rxkadDisableDotCheck = 1;
+       }
        else if (strncmp(arg, "-enable_peer_stats", alen) == 0) {
            rx_enablePeerRPCStats();
        } else if (strncmp(arg, "-enable_process_stats", alen) == 0) {
@@ -367,7 +373,7 @@ main(int argc, char **argv)
            rxMaxMTU = atoi(argv[++a]);
            if ((rxMaxMTU < RX_MIN_PACKET_SIZE) ||
                 (rxMaxMTU > RX_MAX_PACKET_DATA_SIZE)) {
-               printf("rxMaxMTU %d% invalid; must be between %d-%d\n",
+               printf("rxMaxMTU %d invalid; must be between %d-%d\n",
                        rxMaxMTU, RX_MIN_PACKET_SIZE,
                        RX_MAX_PACKET_DATA_SIZE);
                PT_EXIT(1);
@@ -380,17 +386,19 @@ main(int argc, char **argv)
 #ifndef AFS_NT40_ENV
            printf("Usage: ptserver [-database <db path>] "
                   "[-auditlog <log path>] "
-                  "[-syslog[=FACILITY]] "
+                  "[-syslog[=FACILITY]] [-d <debug level>] "
                   "[-p <number of processes>] [-rebuild] "
                   "[-groupdepth <depth>] "
                   "[-restricted] [-rxmaxmtu <bytes>] [-rxbind] "
+                  "[-allow-dotted-principals] "
                   "[-enable_peer_stats] [-enable_process_stats] "
                   "[-default_access default_user_access default_group_access] "
                   "[-help]\n");
 #else /* AFS_NT40_ENV */
            printf("Usage: ptserver [-database <db path>] "
-                  "[-auditlog <log path>] "
+                  "[-auditlog <log path>] [-d <debug level>] "
                   "[-p <number of processes>] [-rebuild] [-rxbind] "
+                  "[-allow-dotted-principals] "
                   "[-default_access default_user_access default_group_access] "
                   "[-restricted] [-rxmaxmtu <bytes>] [-rxbind] "
                   "[-groupdepth <depth>] " "[-help]\n");
@@ -398,18 +406,20 @@ main(int argc, char **argv)
 #else
 #ifndef AFS_NT40_ENV
            printf("Usage: ptserver [-database <db path>] "
-                  "[-auditlog <log path>] "
+                  "[-auditlog <log path>] [-d <debug level>] "
                   "[-syslog[=FACILITY]] "
                   "[-p <number of processes>] [-rebuild] "
                   "[-enable_peer_stats] [-enable_process_stats] "
                   "[-default_access default_user_access default_group_access] "
                   "[-restricted] [-rxmaxmtu <bytes>] [-rxbind] "
+                  "[-allow-dotted-principals] "
                   "[-help]\n");
 #else /* AFS_NT40_ENV */
            printf("Usage: ptserver [-database <db path>] "
-                  "[-auditlog <log path>] "
+                  "[-auditlog <log path>] [-d <debug level>] "
                   "[-default_access default_user_access default_group_access] "
                   "[-restricted] [-rxmaxmtu <bytes>] [-rxbind] "
+                  "[-allow-dotted-principals] "
                   "[-p <number of processes>] [-rebuild] " "[-help]\n");
 #endif
 #endif
@@ -505,7 +515,6 @@ main(int argc, char **argv)
 
     if (rxBind) {
        afs_int32 ccode;
-#ifndef AFS_NT40_ENV
        if (AFSDIR_SERVER_NETRESTRICT_FILEPATH || 
            AFSDIR_SERVER_NETINFO_FILEPATH) {
            char reason[1024];
@@ -514,12 +523,15 @@ main(int argc, char **argv)
                                           AFSDIR_SERVER_NETINFO_FILEPATH,
                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
        } else 
-#endif
        {
            ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
        }
        if (ccode == 1) {
            host = SHostAddrs[0];
+           /* the following call is idempotent so if/when it gets called
+            * again by the ubik init stuff, it doesn't really matter
+            * -- klm
+            */
            rx_InitHost(host, htons(AFSCONF_PROTPORT));
        }
     }
@@ -558,6 +570,10 @@ main(int argc, char **argv)
     }
     rx_SetMinProcs(tservice, 2);
     rx_SetMaxProcs(tservice, lwps);
+    if (rxkadDisableDotCheck) {
+        rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
+                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+    }
 
     tservice =
        rx_NewServiceHost(host, 0, RX_STATS_SERVICE_ID, "rpcstats", sc, 3,