audit-consolidate-open-20081217
[openafs.git] / src / ptserver / ptserver.c
index bda4e05..09eb7dc 100644 (file)
@@ -160,6 +160,7 @@ extern int afsconf_CheckAuth();
 int pr_realmNameLen;
 char *pr_realmName;
 
+int debuglevel = 0;
 int restricted = 0;
 int rxMaxMTU = -1;
 int rxBind = 0;
@@ -280,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 */
@@ -327,35 +335,10 @@ main(int argc, char **argv)
        }
 #endif
        else if (strncmp(arg, "-auditlog", alen) == 0) {
-           int tempfd, flags;
-           FILE *auditout;
-           char oldName[MAXPATHLEN];
            char *fileName = argv[++a];
 
-#ifndef AFS_NT40_ENV
-           struct stat statbuf;
-
-           if ((lstat(fileName, &statbuf) == 0) 
-               && (S_ISFIFO(statbuf.st_mode))) {
-               flags = O_WRONLY | O_NONBLOCK;
-           } else 
-#endif
-           {
-               strcpy(oldName, fileName);
-               strcat(oldName, ".old");
-               renamefile(fileName, oldName);
-               flags = O_WRONLY | O_TRUNC | O_CREAT;
-           }
-           tempfd = open(fileName, flags, 0666);
-           if (tempfd > -1) {
-               auditout = fdopen(tempfd, "a");
-               if (auditout) {
-                   osi_audit_file(auditout);
-                   osi_audit(PTS_StartEvent, 0, AUD_END);
-               } else
-                   printf("Warning: auditlog %s not writable, ignored.\n", fileName);
-           } else
-               printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+            osi_audit_file(fileName);
+            osi_audit(PTS_StartEvent, 0, AUD_END);
        }
        else if (!strncmp(arg, "-rxmaxmtu", alen)) {
            if ((a + 1) >= argc) {
@@ -378,7 +361,7 @@ 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] "
@@ -388,7 +371,7 @@ main(int argc, char **argv)
                   "[-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] "
@@ -398,7 +381,7 @@ 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] "
@@ -408,7 +391,7 @@ main(int argc, char **argv)
                   "[-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] "
@@ -507,7 +490,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];
@@ -516,7 +498,6 @@ main(int argc, char **argv)
                                           AFSDIR_SERVER_NETINFO_FILEPATH,
                                           AFSDIR_SERVER_NETRESTRICT_FILEPATH);
        } else 
-#endif
        {
            ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
        }
@@ -566,8 +547,7 @@ main(int argc, char **argv)
     rx_SetMaxProcs(tservice, lwps);
     if (rxkadDisableDotCheck) {
         rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
-                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK,
-                                    NULL);
+                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
     }
 
     tservice =