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
cmd_SetBeforeProc(MyBeforeProc, NULL);
- cptr = cmd_CreateSyntax(NULL, argHandler, NULL, "Backup database server");
+ cptr = cmd_CreateSyntax(NULL, argHandler, NULL, 0, "Backup database server");
cmd_AddParm(cptr, "-database", CMD_SINGLE, CMD_OPTIONAL,
"database directory");
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
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
{
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);
{
char *whoami = argv[0];
char *dbNamePtr = 0;
- struct afsconf_cell cellinfo;
+ struct afsconf_cell cellinfo_s;
+ 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];
sigaction(SIGSEGV, &nsa, NULL);
sigaction(SIGABRT, &nsa, NULL);
#endif
+
+ 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);
strcpy(cellConfDir, AFSDIR_SERVER_ETC_DIRPATH);
globalConfPtr->cellConfigdir = cellConfDir;
- /* open the log file */
-/*
- globalConfPtr->log = fopen(DEFAULT_LOGNAME,"a");
- if ( globalConfPtr->log == NULL )
- {
- printf("Can't open log file %s - aborting\n", DEFAULT_LOGNAME);
- BUDB_EXIT(-1);
- }
-*/
-
srandom(1);
#ifdef AFS_PTHREAD_ENV
BUDB_EXIT(0);
/* open the log file */
- globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a");
- if (globalConfPtr->log == NULL) {
- printf("Can't open log file %s - aborting\n",
- AFSDIR_SERVER_BUDBLOG_FILEPATH);
- BUDB_EXIT(-1);
- }
-
- /* keep log closed so can remove it */
-
- fclose(globalConfPtr->log);
+ OpenLog(&logopts);
/* open the cell's configuration directory */
LogDebug(4, "opening %s\n", globalConfPtr->cellConfigdir);
ERROR(BUDB_NOCELLS);
}
+ if (afsconf_CountKeys(BU_conf) == 0) {
+ LogError(0, "WARNING: No encryption keys found! "
+ "All authenticated accesses will fail. "
+ "Run akeyconvert or asetkey to import encryption keys.\n");
+ }
+
code = afsconf_GetLocalCell(BU_conf, lcell, sizeof(lcell));
if (code) {
LogError(0, "** Can't determine local cell name!\n");
* list from the cell's database
*/
+ cellinfo = &cellinfo_s;
+
LogDebug(1, "Using server list from %s cell database.\n", lcell);
- code = afsconf_GetExtendedCellInfo (BU_conf, lcell, 0, &cellinfo,
+ code = afsconf_GetExtendedCellInfo (BU_conf, lcell, 0, cellinfo,
clones);
+ if (code) {
+ LogError(0, "Can't read cell information\n");
+ ERROR(code);
+ }
+
code =
- convert_cell_to_ubik(&cellinfo, &globalConfPtr->myHost,
+ convert_cell_to_ubik(cellinfo, &globalConfPtr->myHost,
globalConfPtr->serverList);
if (code)
ERROR(code);
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 */
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);
+ ccode = afsconf_ParseNetFiles(SHostAddrs, NULL, NULL,
+ ADDRSPERSITE, reason,
+ AFSDIR_SERVER_NETINFO_FILEPATH,
+ AFSDIR_SERVER_NETRESTRICT_FILEPATH);
} else
{
ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
}
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();
- code = ubik_ServerInitByInfo (globalConfPtr->myHost,
- htons(AFSCONF_BUDBPORT),
- &cellinfo,
- clones,
- dbNamePtr, /* name prefix */
- &BU_dbase);
+ if (cellinfo) {
+ code = ubik_ServerInitByInfo(globalConfPtr->myHost,
+ htons(AFSCONF_BUDBPORT),
+ cellinfo,
+ clones,
+ dbNamePtr, /* name prefix */
+ &BU_dbase);
+ } else {
+ code = ubik_ServerInit(globalConfPtr->myHost, htons(AFSCONF_BUDBPORT),
+ globalConfPtr->serverList,
+ dbNamePtr, /* name prefix */
+ &BU_dbase);
+ }
if (code) {
LogError(code, "Ubik init failed\n");
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) {
- vfprintf(globalConfPtr->log, fmt, ap);
- fflush(globalConfPtr->log);
- fclose(globalConfPtr->log);
- }
+ va_list ap;
+ va_start(ap, fmt);
+ vFSLog(fmt, ap);
+ va_end(ap);
}
- va_end(ap);
-}
-
-static char *
-TimeStamp(time_t t)
-{
- struct tm *lt;
- static char timestamp[20];
-
- lt = localtime(&t);
- strftime(timestamp, 20, "%m/%d/%Y %H:%M:%S", lt);
- return timestamp;
}
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));
-
- vfprintf(globalConfPtr->log, fmt, ap);
- fflush(globalConfPtr->log);
- fclose(globalConfPtr->log);
- }
+ vFSLog(fmt, ap);
va_end(ap);
}
LogError(long code, char *fmt, ... )
{
va_list ap;
- time_t now;
+ int len;
+ char buffer[1024];
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));
-
- if (code)
- fprintf(globalConfPtr->log, "%s: %s\n", afs_error_table_name(code),
- afs_error_message(code));
- vfprintf(globalConfPtr->log, fmt, ap );
- fflush(globalConfPtr->log);
- fclose(globalConfPtr->log);
+ len = vsnprintf(buffer, sizeof(buffer), fmt, ap);
+ va_end(ap);
+ if (len >= 1024) {
+ len = 1023;
+ buffer[1023] = '\0';
}
-}
-
-
-/* ----------------
- * debug
- * ----------------
- */
-
-void
-LogNetDump(struct dump *dumpPtr)
-{
- struct dump hostDump;
- extern buServerConfP globalConfPtr;
-
- dump_ntoh(dumpPtr, &hostDump);
-
- globalConfPtr->log = fopen(AFSDIR_SERVER_BUDBLOG_FILEPATH, "a");
- if (globalConfPtr->log != NULL) {
- printDump(globalConfPtr->log, &hostDump);
- fclose(globalConfPtr->log);
+ /* Be consistent with (unintentional?) historic behavior. */
+ if (code) {
+ FSLog("%s: %s\n", afs_error_table_name(code), afs_error_message(code));
+ WriteLogBuffer(buffer, len);
+ } else {
+ FSLog("%s", buffer);
}
}
-