all servers now take -auditlog (path), send ibm-style auditlogs there, rotate the logs like the normal server logs, and will log thread ids when it's multiprocessor. /usr/afs/local/Audit can also be used like on aix on other platforms now.
====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================
all servers now take -auditlog (path), send ibm-style auditlogs there, rotate th
e logs like the normal server logs, and will log thread ids when it's multiproce
ssor. /usr/afs/local/Audit can also be used like on aix on other platforms now.
====================
all servers now take -auditlog (path), send ibm-style auditlogs there, rotate th
e logs like the normal server logs, and will log thread ids when it's multiproce
ssor. /usr/afs/local/Audit can also be used like on aix on other platforms now.
====================
all servers now take -auditlog (path), send ibm-style auditlogs there, rotate th
e logs like the normal server logs, and will log thread ids when it's multiproce
ssor. /usr/afs/local/Audit can also be used like on aix on other platforms now.
====================
Windows build dependency changes to support the audit logs
#include <fcntl.h>
#include <stdarg.h>
+#include <string.h>
#ifdef AFS_AIX32_ENV
#include <sys/audit.h>
+#else
+#define AUDIT_OK 0
+#define AUDIT_FAIL 1
+#define AUDIT_FAIL_AUTH 2
+#define AUDIT_FAIL_ACCESS 3
+#define AUDIT_FAIL_PRIV 4
#endif /* AFS_AIX32_ENV */
#include <errno.h>
int osi_audit_all = (-1); /* Not determined yet */
int osi_echo_trail = (-1);
-#ifdef AFS_AIX_ENV /** all these functions are only defined for AIX */
+FILE *auditout = NULL;
+
+int osi_audit_check();
-#ifndef AFS_OSF_ENV
-/*
- * These variadic functions work under AIX, and not all systems (osf1)
- */
-/* ************************************************************************** */
-/* AIX requires a buffer filled with values to record with each audit event.
- * aixmakebuf creates that buffer from the variable list of values we are given.
- * ************************************************************************** */
static void
-aixmakebuf(char *audEvent, char *vaList)
+audmakebuf(char *audEvent, va_list vaList)
{
+#ifdef AFS_AIX32_ENV
int code;
+#endif
int vaEntry;
int vaInt;
afs_int32 vaLong;
char *vaStr;
char *vaLst;
- char hname[20];
struct AFSFid *vaFid;
vaEntry = va_arg(vaList, int);
break;
case AUD_LST: /* Ptr to another list */
vaLst = (char *)va_arg(vaList, int);
- aixmakebuf(audEvent, vaLst);
+ audmakebuf(audEvent, vaLst);
break;
case AUD_FID: /* AFSFid - contains 3 entries */
vaFid = (struct AFSFid *)va_arg(vaList, int);
memcpy(bufferPtr, Fids->AFSCBFids_val,
sizeof(struct AFSFid));
} else {
- struct AFSFid dummy;
*((u_int *) bufferPtr) = 0;
bufferPtr += sizeof(u_int);
memset(bufferPtr, 0, sizeof(struct AFSFid));
}
static void
-printbuf(char *audEvent, afs_int32 errCode, char *vaList)
+printbuf(FILE *out, int rec, char *audEvent, afs_int32 errCode, va_list vaList)
{
int vaEntry;
int vaInt;
afs_int32 vaLong;
char *vaStr;
char *vaLst;
- char hname[20];
struct AFSFid *vaFid;
struct AFSCBFids *vaFids;
+ int num = LogThreadNum();
- if (osi_echo_trail < 0)
- osi_audit_check();
- if (!osi_echo_trail)
- return;
-
+ /* Don't print the thread id if we recursed */
+ if ((num > -1) && (rec == 0))
+ fprintf(out, "[%d]:", num);
+
if (strcmp(audEvent, "VALST") != 0)
- printf("%s %d ", audEvent, errCode);
+ fprintf(out, "%s %d ", audEvent, errCode);
vaEntry = va_arg(vaList, int);
while (vaEntry != AUD_END) {
case AUD_STR: /* String */
vaStr = (char *)va_arg(vaList, int);
if (vaStr)
- printf("%s ", vaStr);
+ fprintf(out, "%s ", vaStr);
else
- printf("<null>", vaStr);
+ fprintf(out, "<null>");
break;
case AUD_INT: /* Integer */
vaInt = va_arg(vaList, int);
- printf("%d ", vaInt);
+ fprintf(out, "%d ", vaInt);
break;
case AUD_DATE: /* Date */
case AUD_HOST: /* Host ID */
vaLong = va_arg(vaList, afs_int32);
- printf("%u ", vaLong);
+ fprintf(out, "%u ", vaLong);
break;
case AUD_LONG: /* afs_int32 */
vaLong = va_arg(vaList, afs_int32);
- printf("%d ", vaLong);
+ fprintf(out, "%d ", vaLong);
break;
case AUD_LST: /* Ptr to another list */
vaLst = (char *)va_arg(vaList, int);
- printbuf("VALST", 0, vaLst);
+ printbuf(out, 1, "VALST", 0, vaLst);
break;
case AUD_FID: /* AFSFid - contains 3 entries */
vaFid = (struct AFSFid *)va_arg(vaList, int);
if (vaFid)
- printf("%u:%u:%u ", vaFid->Volume, vaFid->Vnode,
+ fprintf(out, "%u:%u:%u ", vaFid->Volume, vaFid->Vnode,
vaFid->Unique);
else
- printf("%u:%u:%u ", 0, 0, 0);
+ fprintf(out, "%u:%u:%u ", 0, 0, 0);
break;
case AUD_FIDS: /* array of Fids */
vaFids = (struct AFSCBFids *)va_arg(vaList, int);
if (vaFids)
vaFid = vaFids->AFSCBFids_val;
if (vaFid)
- printf("%u %u:%u:%u ", vaFids->AFSCBFids_len, vaFid->Volume,
+ fprintf(out, "%u %u:%u:%u ", vaFids->AFSCBFids_len, vaFid->Volume,
vaFid->Vnode, vaFid->Unique);
else
- printf("0 0:0:0 ");
+ fprintf(out, "0 0:0:0 ");
break;
default:
- printf("--badval-- ");
+ fprintf(out, "--badval-- ");
break;
} /* end switch */
vaEntry = va_arg(vaList, int);
} /* end while */
if (strcmp(audEvent, "VALST") != 0)
- printf("\n");
+ fprintf(out, "\n");
}
-#else
-static void
-aixmakebuf(audEvent, vaList)
- char *audEvent;
- va_list vaList;
-{
- return;
-}
-
-static void
-printbuf(char *audEvent, long errCode, va_list vaList)
-{
- return;
-}
-
-#endif
-
/* ************************************************************************** */
/* The routine that acually does the audit call.
#ifdef AFS_AIX32_ENV
afs_int32 code;
afs_int32 err;
+#endif
int result;
va_list vaList;
+#ifdef AFS_AIX32_ENV
static struct Lock audbuflock = { 0, 0, 0, 0,
#ifdef AFS_PTHREAD_ENV
PTHREAD_MUTEX_INITIALIZER,
#endif /* AFS_PTHREAD_ENV */
};
static char BUFFER[32768];
+#endif
- if (osi_audit_all < 0)
+ if ((osi_audit_all < 0) || (osi_echo_trail < 0))
osi_audit_check();
- if (!osi_audit_all)
- return;
+ if (!osi_audit_all && !auditout)
+ return 0;
switch (errCode) {
case 0:
break;
case VL_PERM: /* vlserver.h */
case BUDB_NOTPERMITTED: /* budb_errs.h */
-/* case KRB_RD_AP_UNAUTHOR : */
case BZACCESS: /* bnode.h */
case VOLSERBAD_ACCESS: /* volser.h */
result = AUDIT_FAIL_PRIV;
break;
}
+#ifdef AFS_AIX32_ENV
ObtainWriteLock(&audbuflock);
bufferPtr = BUFFER;
bufferPtr += sizeof(errCode);
va_start(vaList, errCode);
- aixmakebuf(audEvent, vaList);
+ audmakebuf(audEvent, vaList);
+#endif
- va_start(vaList, errCode);
- printbuf(audEvent, errCode, vaList);
+ if (osi_echo_trail) {
+ va_start(vaList, errCode);
+ printbuf(stdout, 0, audEvent, errCode, vaList);
+ }
+#ifdef AFS_AIX32_ENV
bufferLen = (int)((afs_int32) bufferPtr - (afs_int32) & BUFFER[0]);
code = auditlog(audEvent, result, BUFFER, bufferLen);
#ifdef notdef
}
#endif /* notdef */
ReleaseWriteLock(&audbuflock);
+#else
+ if (auditout) {
+ va_start(vaList, errCode);
+ printbuf(auditout, 0, audEvent, errCode, vaList);
+ fflush(auditout);
+ }
#endif
+
+ return 0;
}
/* ************************************************************************** */
afs_int32 hostId;
va_list vaList;
-
if (osi_audit_all < 0)
osi_audit_check();
- if (!osi_audit_all)
- return;
+ if (!osi_audit_all && !auditout)
+ return 0;
strcpy(afsName, "--Unknown--");
hostId = 0;
osi_audit("AFS_Aud_Unauth", (-1), AUD_STR, audEvent, AUD_END);
strcpy(afsName, "--UnAuth--");
} else if (secClass == 2) { /* authenticated */
- code =
- rxkad_GetServerInfo(conn, NULL, NULL, afsName, NULL, NULL,
+ char tcell[MAXKTCREALMLEN];
+ char name[MAXKTCNAMELEN];
+ char inst[MAXKTCNAMELEN];
+ char vname[256];
+ int ilen, clen;
+
+ code =
+ rxkad_GetServerInfo(conn, NULL, NULL, name, inst, tcell,
NULL);
if (code) {
osi_audit("AFS_Aud_NoAFSId", (-1), AUD_STR, audEvent,
AUD_END);
strcpy(afsName, "--NoName--");
- }
+ } else {
+ strncpy(vname, name, sizeof(vname));
+ if ((ilen = strlen(inst))) {
+ if (strlen(vname) + 1 + ilen >= sizeof(vname))
+ goto done;
+ strcat(vname, ".");
+ strcat(vname, inst);
+ }
+ if ((clen = strlen(tcell))) {
+#if defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
+ static char local_realm[AFS_REALM_SZ] = "";
+ if (!local_realm[0]) {
+ if (afs_krb_get_lrealm(local_realm, 0) != 0 /*KSUCCESS*/)
+ strncpy(local_realm, "UNKNOWN.LOCAL.REALM", AFS_REALM_SZ);
+ }
+ if (strcasecmp(local_realm, tcell)) {
+ if (strlen(vname) + 1 + clen >= sizeof(vname))
+ goto done;
+ strcat(vname, "@");
+ strcat(vname, tcell);
+ }
+#endif
+ strcpy(afsName, vname);
+ }
+ }
} else { /* Unauthenticated & unknown */
osi_audit("AFS_Aud_UnknSec", (-1), AUD_STR, audEvent,
AUD_END);
}
-
+ done:
peer = rx_PeerOf(conn); /* conn -> peer */
if (peer)
hostId = rx_HostOf(peer); /* peer -> host */
va_start(vaList, errCode);
osi_audit(audEvent, errCode, AUD_STR, afsName, AUD_HOST, hostId, AUD_LST,
vaList, AUD_END);
+
+ return 0;
}
/* ************************************************************************** */
/* Now set whether we audit all events from here on out */
osi_audit_all = onoff;
-}
-
-#else /* ! AFS_AIX_ENV */
-
-int
-osi_audit(char *audEvent, afs_int32 errCode, ...)
-{
return 0;
}
int
-osi_auditU(struct rx_call *call, char *audEvent, int errCode, ...)
+osi_audit_file(FILE *out)
{
+ auditout = out;
return 0;
}
-
-#endif
/* prototypes for audit functions */
int osi_audit(char *audEvent, afs_int32 errCode, ...);
int osi_auditU(struct rx_call *call, char *audEvent, int errCode, ...);
+int osi_audit_file(FILE *out);
bozo_isrestricted = 1;
}
#endif
+ else if (strcmp(argv[code], "-auditlog") == 0) {
+ int tempfd, flags;
+ FILE *auditout;
+ char oldName[MAXPATHLEN];
+ char *fileName = argv[++code];
+
+#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);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ }
else {
/* hack to support help flag */
#ifndef AFS_NT40_ENV
printf("Usage: bosserver [-noauth] [-log] "
+ "[-auditlog <log path>] "
"[-syslog[=FACILITY]] "
"[-enable_peer_stats] [-enable_process_stats] "
"[-nofork] " "[-help]\n");
#else
printf("Usage: bosserver [-noauth] [-log] "
+ "[-auditlog <log path>] "
"[-enable_peer_stats] [-enable_process_stats] "
"[-help]\n");
#endif
RCSID
("$Header$");
+#include <fcntl.h>
+#include <sys/stat.h>
#ifdef AFS_NT40_ENV
#include <winsock2.h>
-#include <fcntl.h>
#include <WINNT/afsevent.h>
#else
#include <netinet/in.h>
/* debugging control */
int debugging = 0;
+#if defined(AFS_PTHREAD_ENV)
+char *
+threadNum(void)
+{
+ return pthread_getspecific(rx_thread_id_key);
+}
+#endif
+
/* check whether caller is authorized to manage RX statistics */
int
BU_rxstat_userok(call)
cmd_AddParm(cptr, "-ubikbuffers", CMD_SINGLE, CMD_OPTIONAL,
"the number of ubik buffers");
+ cmd_AddParm(cptr, "-auditlog", CMD_SINGLE, CMD_OPTIONAL,
+ "audit log path");
+
}
int
else
ubik_nBuffers = 0;
+ if (as->parms[7].items != 0) {
+ int tempfd, flags;
+ FILE *auditout;
+ char oldName[MAXPATHLEN];
+ char *fileName = as->parms[7].items->data;
+#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);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ }
+
return 0;
}
srandom(1);
+#ifdef AFS_PTHREAD_ENV
+ SetLogThreadNumProgram( threadNum );
+#endif
+
/* process the user supplied args */
helpOption = 1;
code = cmd_Dispatch(argc, argv);
#include <lock.h>
#include <afs/afsutil.h>
#include <ubik.h>
+#include <sys/stat.h>
#include "kauth.h"
#include "kautils.h"
#include "kaserver.h"
if (argc == 0) {
usage:
printf("Usage: kaserver [-noAuth] [-fastKeys] [-database <dbpath>] "
+ "[-auditlog <log path>] "
"[-localfiles <lclpath>] [-minhours <n>] [-servers <serverlist>] "
"[-crossrealm]"
/*" [-enable_peer_stats] [-enable_process_stats] " */
dbpath = argv[++a];
if (strcmp(lclpath, default_lclpath) == 0)
lclpath = dbpath;
+ }
+ else if (strncmp(arg, "-auditlog", arglen) == 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);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
} else if (strcmp(arg, "-localfiles") == 0)
lclpath = argv[++a];
else if (strcmp(arg, "-servers") == 0)
DLLLIBS =\
$(DESTDIR)\lib\afspthread.lib \
$(DESTDIR)\lib\afsrpc.lib \
- $(DESTDIR)\lib\afsauthent.lib
+ $(DESTDIR)\lib\afs\afsutil.lib \
+ $(DESTDIR)\lib\afsauthent.lib \
+ $(DESTDIR)\lib\afs\afsreg.lib
$(DLLFILE): $(DLLOBJS) $(DLLLIBS)
$(DLLCONLINK) /DEF:afsadminutil.def
$(DESTDIR)\lib\afs\afsadminutil.lib \
$(DESTDIR)\lib\afsauthent.lib \
$(DESTDIR)\lib\afsrpc.lib \
- $(DESTDIR)\lib\afspthread.lib
+ $(DESTDIR)\lib\afspthread.lib \
+ $(DESTDIR)\lib\afs\afsutil.lib
$(DLLFILE): $(DLLOBJS) $(DLLLIBS)
$(DLLCONLINK) /DEF:clientadmin.def
$(DESTDIR)\lib\afs\afsptsadmin.lib \
$(DESTDIR)\lib\afsauthent.lib \
$(DESTDIR)\lib\afsrpc.lib \
+ $(DESTDIR)\lib\afs\afsutil.lib \
$(DESTDIR)\lib\afs\afscmd.lib # static library
AFSCP_EXEOBJS =\
$(DESTDIR)\lib\afs\afsutil.lib \
$(DESTDIR)\lib\afs\afsreg.lib \
$(DESTDIR)\lib\afs\afseventlog.lib \
- $(DESTDIR)\lib\lanahelper.lib
+ $(DESTDIR)\lib\afs\afsprocmgmt.lib \
+ $(DESTDIR)\lib\afslwp.lib \
+ $(DESTDIR)\lib\lanahelper.lib
$(LIBFILE): $(DLLOBJS) $(DLLLIBS) $(RXOBJS)
$(DLLCONLINK) /DEF:afsauthent.def rpcrt4.lib dnsapi.lib mpr.lib secur32.lib
com_err @75
error_message @76
rx_socket @77 DATA
- AssertionFailed @79
+; AssertionFailed @79
afs_winsockInit @80
rxevent_debugFile @81 DATA
rx_debugFile @82 DATA
#endif
#include <sys/types.h>
#include <stdio.h>
+#include <fcntl.h>
+#include <sys/stat.h>
#ifdef AFS_NT40_ENV
#include <winsock2.h>
#include <WINNT/afsevent.h>
serverLogSyslogFacility = atoi(arg + 8);
}
#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);
+ }
else if (*arg == '-') {
/* hack in help flag support */
#if defined(SUPERGROUPS)
#ifndef AFS_NT40_ENV
printf("Usage: ptserver [-database <db path>] "
+ "[-auditlog <log path>] "
"[-syslog[=FACILITY]] "
"[-p <number of processes>] [-rebuild] "
"[-groupdepth <depth>] "
"[-help]\n");
#else /* AFS_NT40_ENV */
printf("Usage: ptserver [-database <db path>] "
+ "[-auditlog <log path>] "
"[-p <number of processes>] [-rebuild] "
"[-default_access default_user_access default_group_access] "
"[-restricted] "
#else
#ifndef AFS_NT40_ENV
printf("Usage: ptserver [-database <db path>] "
+ "[-auditlog <log path>] "
"[-syslog[=FACILITY]] "
"[-p <number of processes>] [-rebuild] "
"[-enable_peer_stats] [-enable_process_stats] "
"[-help]\n");
#else /* AFS_NT40_ENV */
printf("Usage: ptserver [-database <db path>] "
+ "[-auditlog <log path>] "
"[-default_access default_user_access default_group_access] "
"[-restricted] "
"[-p <number of processes>] [-rebuild] " "[-help]\n");
extern char *serverLogSyslogTag;
#endif
extern void vFSLog(const char *format, va_list args);
-extern void SetLogThreadNameProgram(char *(*func) () );
+extern void SetLogThreadNumProgram(int (*func) () );
/*@printflike@*/ extern void FSLog(const char *format, ...);
#define ViceLog(level, str) if ((level) <= LogLevel) (FSLog str)
extern void SetupLogSignals(void);
extern int OpenLog(const char *fileName);
extern int ReOpenLog(const char *fileName);
+extern int LogThreadNum();
/* snprintf.c */
#define O_NONBLOCK 0
#endif
-static char *(*threadNameProgram) () = NULL;
+static int
+dummyThreadNum(void)
+{
+ return -1;
+}
+static int (*threadNumProgram) () = dummyThreadNum;
static int serverLogFD = -1;
static char ourName[MAXPATHLEN];
void
-SetLogThreadNameProgram(char *(*func) () )
+SetLogThreadNumProgram(int (*func) () )
{
- threadNameProgram = func;
+ threadNumProgram = func;
}
void
UNLOCK_SERVERLOG();
}
+int
+LogThreadNum(void)
+{
+ return (*threadNumProgram) ();
+}
+
void
vFSLog(const char *format, va_list args)
{
char *timeStamp;
char tbuffer[1024];
char *info;
- int len;
+ int len, num;
char *name;
currenttime = time(0);
info = &timeStamp[25];
if (mrafsStyleLogs || threadIdLogs) {
- name = (*threadNameProgram) ();
- if (name) {
- (void)afs_snprintf(info, (sizeof tbuffer) - strlen(tbuffer), "[%s] ",
- name);
+ num = (*threadNumProgram) ();
+ if (num > -1) {
+ (void)afs_snprintf(info, (sizeof tbuffer) - strlen(tbuffer), "[%d] ",
+ num);
info += strlen(info);
}
}
LogLevel *= 5;
#if defined(AFS_PTHREAD_ENV)
- if (LogLevel > 1 && threadNameProgram != NULL &&
+ if (LogLevel > 1 && threadNumProgram != NULL &&
threadIdLogs == 0) {
threadIdLogs = 1;
}
#include <sys/types.h>
#include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
#include <sys/stat.h>
-#ifdef AFS_NT40_ENV
#include <fcntl.h>
+#ifdef AFS_NT40_ENV
#include <io.h>
#include <windows.h>
#include <WINNT/afsevent.h>
#if defined(AFS_PTHREAD_ENV)
char *
-threadName(void)
+threadNum(void)
{
- char threadid[16];
- if (LogLevel > 999) {
- afs_snprintf(threadid, 16, "%d", pthread_getspecific(rx_thread_id_key));
- return threadid;
- } else
- return NULL;
+ return pthread_getspecific(rx_thread_id_key);
}
#endif
/* default supports help flag */
strcpy(buffer, "Usage: fileserver ");
+ strcpy(buffer, "[-auditlog <log path>] ");
strcat(buffer, "[-d <debug level>] ");
strcat(buffer, "[-p <number of processes>] ");
strcat(buffer, "[-spare <number of spare blocks>] ");
} else if (!strcmp(argv[i], "-enable_process_stats")) {
rx_enableProcessRPCStats();
}
+ else if (strcmp(argv[i], "-auditlog") == 0) {
+ int tempfd, flags;
+ FILE *auditout;
+ char oldName[MAXPATHLEN];
+ char *fileName = argv[++i];
+
+#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);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ }
#ifndef AFS_NT40_ENV
else if (strcmp(argv[i], "-syslog") == 0) {
/* set syslog logging flag */
}
#ifdef AFS_PTHREAD_ENV
- SetLogThreadNameProgram( threadName );
+ SetLogThreadNumProgram( threadNum );
#endif
/* initialize libacl routines */
#include <afs/stds.h>
#include <sys/types.h>
#include <signal.h>
+#include <sys/stat.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
extern char rxi_tracename[80];
strcpy(rxi_tracename, argv[++index]);
+ } else if (strcmp(argv[index], "-auditlog") == 0) {
+ int tempfd, flags;
+ FILE *auditout;
+ char oldName[MAXPATHLEN];
+ char *fileName = argv[++index];
+
+#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);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
} else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
rx_enablePeerRPCStats();
} else if (strcmp(argv[index], "-enable_process_stats") == 0) {
/* support help flag */
#ifndef AFS_NT40_ENV
printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
+ "[-auditlog <log path>] "
"[-syslog[=FACILITY]] "
"[-enable_peer_stats] [-enable_process_stats] "
"[-help]\n");
#else
printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
+ "[-auditlog <log path>] "
"[-enable_peer_stats] [-enable_process_stats] "
"[-help]\n");
#endif
#include <afs/cellconfig.h>
#include <afs/keys.h>
#include <ubik.h>
+#include <fcntl.h>
+#include <sys/stat.h>
#include "volser.h"
#include <errno.h>
exit(code); \
}
+#if defined(AFS_PTHREAD_ENV)
+char *
+threadNum(void)
+{
+ return pthread_getspecific(rx_thread_id_key);
+}
+#endif
static afs_int32
MyBeforeProc(struct rx_call *acall)
lwps, MAXLWP);
lwps = MAXLWP;
}
+ } else if (strcmp(argv[code], "-auditlog") == 0) {
+ int tempfd, flags;
+ FILE *auditout;
+ char oldName[MAXPATHLEN];
+ char *fileName = argv[++code];
+
+#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(VS_StartEvent, 0, AUD_END);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ } else
+ printf("Warning: auditlog %s not writable, ignored.\n", fileName);
} else if (strcmp(argv[code], "-nojumbo") == 0) {
rxJumbograms = 0;
} else if (strcmp(argv[code], "-sleep") == 0) {
usage:
#ifndef AFS_NT40_ENV
printf("Usage: volserver [-log] [-p <number of processes>] "
+ "[-auditlog <log path>] "
"[-udpsize <size of socket buffer in bytes>] "
"[-syslog[=FACILITY]] "
"[-enable_peer_stats] [-enable_process_stats] "
"[-help]\n");
#else
printf("Usage: volserver [-log] [-p <number of processes>] "
+ "[-auditlog <log path>] "
"[-udpsize <size of socket buffer in bytes>] "
"[-enable_peer_stats] [-enable_process_stats] "
"[-help]\n");
#endif
InitErrTabs();
+#ifdef AFS_PTHREAD_ENV
+ SetLogThreadNumProgram( threadNum );
+#endif
+
#ifdef AFS_NT40_ENV
if (afs_winsockInit() < 0) {
ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);