Log binding ip address and port during startup
[openafs.git] / src / budb / server.c
index c6e11f5..08d7a4f 100644 (file)
@@ -45,6 +45,7 @@ int parseServerList(struct cmd_item *);
 char lcell[MAXKTCREALMLEN];
 afs_uint32 myHost = 0;
 int helpOption;
+static struct logOptions logopts;
 
 /* server's global configuration information. This is exported to other
  * files/routines
@@ -173,6 +174,9 @@ initializeArgHandler(void)
 
     cmd_AddParm(cptr, "-audit-interface", CMD_SINGLE, CMD_OPTIONAL,
                "audit interface (file or sysvmq)");
+
+    cmd_AddParm(cptr, "-transarc-logs", CMD_FLAG, CMD_OPTIONAL,
+               "enable Transarc style logging");
 }
 
 int
@@ -250,6 +254,11 @@ argHandler(struct cmd_syndesc *as, void *arock)
            BUDB_EXIT(-1);
        }
     }
+    /* -transarc-logs */
+    if (as->parms[11].items != 0) {
+       logopts.lopt_rotateOnOpen = 1;
+       logopts.lopt_rotateStyle = logRotate_old;
+    }
 
     /* -auditlog */
     /* needs to be after -audit-interface, so we osi_audit_interface
@@ -322,13 +331,13 @@ truncateDatabase(void)
 {
     char *path;
     afs_int32 code = 0;
-    int fd;
+    int fd,r;
 
-    asprintf(&path, "%s%s%s",
-            globalConfPtr->databaseDirectory,
-            globalConfPtr->databaseName,
-            globalConfPtr->databaseExtension);
-    if (path == NULL)
+    r = asprintf(&path, "%s%s%s",
+                globalConfPtr->databaseDirectory,
+                globalConfPtr->databaseName,
+                globalConfPtr->databaseExtension);
+    if (r < 0 || path == NULL)
        ERROR(-1);
 
     fd = open(path, O_RDWR, 0755);
@@ -361,7 +370,9 @@ main(int argc, char **argv)
     struct afsconf_cell *cellinfo = NULL;
     time_t currentTime;
     afs_int32 code = 0;
+    char hoststr[16];
     afs_uint32 host = ntohl(INADDR_ANY);
+    int r;
 
     char  clones[MAXHOSTSPERCELL];
 
@@ -399,6 +410,10 @@ main(int argc, char **argv)
     memset(&cellinfo_s, 0, sizeof(cellinfo_s));
     memset(clones, 0, sizeof(clones));
 
+    memset(&logopts, 0, sizeof(logopts));
+    logopts.lopt_dest = logDest_file;
+    logopts.lopt_filename = AFSDIR_SERVER_BUDBLOG_FILEPATH;
+
     osi_audit_init();
     osi_audit(BUDB_StartEvent, 0, AUD_END);
 
@@ -441,7 +456,7 @@ main(int argc, char **argv)
        BUDB_EXIT(0);
 
     /* open the log file */
-    OpenLog(AFSDIR_SERVER_BUDBLOG_FILEPATH);
+    OpenLog(&logopts);
 
     /* open the cell's configuration directory */
     LogDebug(4, "opening %s\n", globalConfPtr->cellConfigdir);
@@ -495,9 +510,9 @@ main(int argc, char **argv)
 
     LogError(0, "Will allocate %d ubik buffers\n", ubik_nBuffers);
 
-    asprintf(&dbNamePtr, "%s%s", globalConfPtr->databaseDirectory,
-            globalConfPtr->databaseName);
-    if (dbNamePtr == 0)
+    r = asprintf(&dbNamePtr, "%s%s", globalConfPtr->databaseDirectory,
+                globalConfPtr->databaseName);
+    if (r < 0 || dbNamePtr == 0)
        ERROR(-1);
 
     rx_SetRxDeadTime(60);      /* 60 seconds inactive before timeout */
@@ -517,10 +532,18 @@ main(int argc, char **argv)
         }
         if (ccode == 1) {
             host = SHostAddrs[0];
-           rx_InitHost(host, htons(AFSCONF_BUDBPORT));
        }
     }
 
+    Log("buserver binding rx to %s:%d\n",
+        afs_inet_ntoa_r(host, hoststr), AFSCONF_BUDBPORT);
+    code = rx_InitHost(host, htons(AFSCONF_BUDBPORT));
+    if (code) {
+       LogError(code, "rx init failed\n");
+       afs_com_err(whoami, code, "rx init failed");
+       ERROR(code);
+    }
+
     /* Disable jumbograms */
     rx_SetNoJumbo();