Squash pthreaded ubik warnings
[openafs.git] / src / budb / server.c
index 57e3447..63e538a 100644 (file)
@@ -10,8 +10,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -47,6 +45,7 @@ RCSID
 #include "budb_errs.h"
 #include "database.h"
 #include "error_macros.h"
+#include "budb_internal.h"
 #include "globals.h"
 #include "afs/audit.h"
 
@@ -54,6 +53,8 @@ struct ubik_dbase *BU_dbase;
 struct afsconf_dir *BU_conf;   /* for getting cell info */
 
 int argHandler(struct cmd_syndesc *, void *);
+int truncateDatabase(void);
+int parseServerList(struct cmd_item *);
 
 char lcell[MAXKTCREALMLEN];
 afs_int32 myHost = 0;
@@ -79,26 +80,23 @@ int lwps   = 3;
 afs_uint32 SHostAddrs[ADDRSPERSITE];
 
 #if defined(AFS_PTHREAD_ENV)
-char *
+static int
 threadNum(void)
 {
-    return pthread_getspecific(rx_thread_id_key);
+    return (intptr_t)pthread_getspecific(rx_thread_id_key);
 }
 #endif
 
 /* check whether caller is authorized to manage RX statistics */
 int
-BU_rxstat_userok(call)
-     struct rx_call *call;
+BU_rxstat_userok(struct rx_call *call)
 {
     return afsconf_SuperUser(BU_conf, call, NULL);
 }
 
 int
-convert_cell_to_ubik(cellinfo, myHost, serverList)
-     struct afsconf_cell *cellinfo;
-     afs_int32 *myHost;
-     afs_int32 *serverList;
+convert_cell_to_ubik(struct afsconf_cell *cellinfo, afs_int32 *myHost, 
+                    afs_int32 *serverList)
 {
     int i;
     char hostname[64];
@@ -139,7 +137,7 @@ MyBeforeProc(register struct cmd_syndesc *as, void *arock)
  */
 
 void
-initializeArgHandler()
+initializeArgHandler(void)
 {
     struct cmd_syndesc *cptr;
 
@@ -177,6 +175,8 @@ initializeArgHandler()
     cmd_AddParm(cptr, "-rxbind", CMD_FLAG, CMD_OPTIONAL,
                "bind the Rx socket (primary interface only)");
 
+    cmd_AddParm(cptr, "-audit-interface", CMD_SINGLE, CMD_OPTIONAL,
+               "audit interface (file or sysvmq)");
 }
 
 int
@@ -228,11 +228,7 @@ argHandler(struct cmd_syndesc *as, void *arock)
     else
        ubik_nBuffers = 0;
 
-    if (as->parms[7].items != 0) {
-       char *fileName = as->parms[7].items->data;
-
-        osi_audit_file(fileName);
-    }
+    /* param 7 (-auditlog) handled below */
 
     /* user provided the number of threads    */
     if (as->parms[8].items != 0) {
@@ -254,13 +250,32 @@ argHandler(struct cmd_syndesc *as, void *arock)
        rxBind = 1;
     }
 
+    /* -audit-interface */
+    if (as->parms[10].items != 0) {
+       char *interface = as->parms[10].items->data;
+
+       if (osi_audit_interface(interface)) {
+           printf("Invalid audit interface '%s'\n", interface);
+           BUDB_EXIT(-1);
+       }
+    }
+
+    /* -auditlog */
+    /* needs to be after -audit-interface, so we osi_audit_interface
+     * before we osi_audit_file */
+    if (as->parms[7].items != 0) {
+       char *fileName = as->parms[7].items->data;
+
+        osi_audit_file(fileName);
+    }
+
     return 0;
 }
 
 /* --- */
 
-parseServerList(itemPtr)
-     struct cmd_item *itemPtr;
+int
+parseServerList(struct cmd_item *itemPtr)
 {
     struct cmd_item *save;
     char **serverArgs;
@@ -311,7 +326,8 @@ parseServerList(itemPtr)
  *     truncates just the database file.
  */
 
-truncateDatabase()
+int
+truncateDatabase(void)
 {
     char *path;
     afs_int32 code = 0;
@@ -348,9 +364,8 @@ truncateDatabase()
 
 #include "AFS_component_version_number.c"
 
-main(argc, argv)
-     int argc;
-     char *argv[];
+int
+main(int argc, char **argv)
 {
     char *whoami = argv[0];
     char *dbNamePtr = 0;
@@ -364,11 +379,7 @@ main(argc, argv)
     struct rx_service *tservice;
     struct rx_securityClass *sca[3];
 
-    extern int afsconf_ServerAuth();
-    extern int afsconf_CheckAuth();
-
     extern int rx_stackSize;
-    extern int BUDB_ExecuteRequest();
 
 #ifdef AFS_NT40_ENV
     /* initialize winsock */
@@ -480,8 +491,8 @@ main(argc, argv)
 
        LogDebug(1, "Using server list from %s cell database.\n", lcell);
 
-       code = afsconf_GetExtendedCellInfo (BU_conf, lcell, 0, &cellinfo, 
-                                           &clones); 
+       code = afsconf_GetExtendedCellInfo (BU_conf, lcell, 0, &cellinfo,
+                                           clones);
        code =
            convert_cell_to_ubik(&cellinfo, &globalConfPtr->myHost,
                                 globalConfPtr->serverList);
@@ -491,13 +502,13 @@ main(argc, argv)
 
     /* initialize ubik */
     ubik_CRXSecurityProc = afsconf_ClientAuth;
-    ubik_CRXSecurityRock = (char *)BU_conf;
+    ubik_CRXSecurityRock = BU_conf;
 
     ubik_SRXSecurityProc = afsconf_ServerAuth;
-    ubik_SRXSecurityRock = (char *)BU_conf;
+    ubik_SRXSecurityRock = BU_conf;
 
     ubik_CheckRXSecurityProc = afsconf_CheckAuth;
-    ubik_CheckRXSecurityRock = (char *)BU_conf;
+    ubik_CheckRXSecurityRock = BU_conf;
 
     if (ubik_nBuffers == 0)
        ubik_nBuffers = 400;
@@ -596,7 +607,7 @@ main(argc, argv)
 }
 
 void
-consistencyCheckDb()
+consistencyCheckDb(void)
 {
     /* do consistency checks on structure sizes */
     if ((sizeof(struct htBlock) > BLOCKSIZE)
@@ -610,22 +621,23 @@ consistencyCheckDb()
     }
 }
 
- /*VARARGS*/
-LogDebug(level, a, b, c, d, e, f, g, h, i)
-     int level;
-     char *a, *b, *c, *d, *e, *f, *g, *h, *i;
+void
+LogDebug(int level, char *fmt, ... )
 {
+    va_list ap;
 
+    va_start(ap, fmt);
+       
     if (debugging >= level) {
        /* log normally closed so can remove it */
        globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a");
        if (globalConfPtr->log != NULL) {
-           fprintf(globalConfPtr->log, a, b, c, d, e, f, g, h, i);
+           vfprintf(globalConfPtr->log, fmt, ap);
            fflush(globalConfPtr->log);
            fclose(globalConfPtr->log);
        }
     }
-    return 0;
+    va_end(ap);
 }
 
 static char *
@@ -639,31 +651,32 @@ TimeStamp(time_t t)
     return timestamp;
 }
 
- /*VARARGS*/
-Log(a, b, c, d, e, f, g, h, i)
-     char *a, *b, *c, *d, *e, *f, *g, *h, *i;
+void
+Log(char *fmt, ...)
 {
+    va_list ap;
     time_t now;
 
+    va_start(ap, fmt);
     globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a");
     if (globalConfPtr->log != NULL) {
        now = time(0);
        fprintf(globalConfPtr->log, "%s ", TimeStamp(now));
 
-       fprintf(globalConfPtr->log, a, b, c, d, e, f, g, h, i);
+       vfprintf(globalConfPtr->log, fmt, ap);
        fflush(globalConfPtr->log);
        fclose(globalConfPtr->log);
     }
-    return 0;
+    va_end(ap);
 }
 
- /*VARARGS*/
-LogError(code, a, b, c, d, e, f, g, h, i)
-     long code;
-     char *a, *b, *c, *d, *e, *f, *g, *h, *i;
+void
+LogError(long code, char *fmt, ... )
 {
+    va_list ap;
     time_t now;
 
+    va_start(ap, fmt);
     globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a");
 
     if (globalConfPtr->log != NULL) {
@@ -673,11 +686,10 @@ LogError(code, a, b, c, d, e, f, g, h, i)
        if (code)
            fprintf(globalConfPtr->log, "%s: %s\n", afs_error_table_name(code),
                    afs_error_message(code));
-       fprintf(globalConfPtr->log, a, b, c, d, e, f, g, h, i);
+       vfprintf(globalConfPtr->log, fmt, ap );
        fflush(globalConfPtr->log);
        fclose(globalConfPtr->log);
     }
-    return 0;
 }
 
 
@@ -686,9 +698,8 @@ LogError(code, a, b, c, d, e, f, g, h, i)
  * ----------------
  */
 
-
-LogNetDump(dumpPtr)
-     struct dump *dumpPtr;
+void
+LogNetDump(struct dump *dumpPtr)
 {
     struct dump hostDump;
     extern buServerConfP globalConfPtr;
@@ -700,5 +711,5 @@ LogNetDump(dumpPtr)
        printDump(globalConfPtr->log, &hostDump);
        fclose(globalConfPtr->log);
     }
-    return 0;
 }
+