int vaInt;
afs_int32 vaLong;
char *vaStr;
- char *vaLst;
+ va_list vaLst;
struct AFSFid *vaFid;
vaEntry = va_arg(vaList, int);
case AUD_STR: /* String */
case AUD_NAME: /* Name */
case AUD_ACL: /* ACL */
- vaStr = (char *)va_arg(vaList, int);
+ vaStr = (char *)va_arg(vaList, char *);
if (vaStr) {
strcpy(bufferPtr, vaStr);
bufferPtr += strlen(vaStr) + 1;
bufferPtr += sizeof(vaLong);
break;
case AUD_LST: /* Ptr to another list */
- vaLst = (char *)va_arg(vaList, int);
+ vaLst = va_arg(vaList, va_list);
audmakebuf(audEvent, vaLst);
break;
case AUD_FID: /* AFSFid - contains 3 entries */
- vaFid = (struct AFSFid *)va_arg(vaList, int);
+ vaFid = (struct AFSFid *)va_arg(vaList, struct AFSFid *);
if (vaFid) {
memcpy(bufferPtr, vaFid, sizeof(struct AFSFid));
} else {
{
struct AFSCBFids *Fids;
- Fids = (struct AFSCBFids *)va_arg(vaList, int);
+ Fids = (struct AFSCBFids *)va_arg(vaList, struct AFSCBFids *);
if (Fids && Fids->AFSCBFids_len) {
*((u_int *) bufferPtr) = Fids->AFSCBFids_len;
bufferPtr += sizeof(u_int);
int vaInt;
afs_int32 vaLong;
char *vaStr;
- char *vaLst;
+ va_list vaLst;
struct AFSFid *vaFid;
struct AFSCBFids *vaFids;
int num = LogThreadNum();
struct in_addr hostAddr;
-
- /* Don't print the thread id if we recursed */
- if ((num > -1) && (rec == 0))
- fprintf(out, "[%d]:", num);
+ time_t currenttime;
+ char *timeStamp;
+ char tbuffer[26];
+
+ /* Don't print the timestamp or thread id if we recursed */
+ if (rec == 0) {
+ currenttime = time(0);
+ timeStamp = afs_ctime(¤ttime, tbuffer,
+ sizeof(tbuffer));
+ timeStamp[24] = ' '; /* ts[24] is the newline, 25 is the null */
+ fprintf(out, timeStamp);
+
+ if (num > -1)
+ fprintf(out, "[%d] ", num);
+ }
if (strcmp(audEvent, "VALST") != 0)
fprintf(out, "EVENT %s CODE %d ", audEvent, errCode);
while (vaEntry != AUD_END) {
switch (vaEntry) {
case AUD_STR: /* String */
- vaStr = (char *)va_arg(vaList, int);
+ vaStr = (char *)va_arg(vaList, char *);
if (vaStr)
fprintf(out, "STR %s ", vaStr);
else
fprintf(out, "STR <null>");
break;
case AUD_NAME: /* Name */
- vaStr = (char *)va_arg(vaList, int);
+ vaStr = (char *)va_arg(vaList, char *);
if (vaStr)
fprintf(out, "NAME %s ", vaStr);
else
fprintf(out, "NAME <null>");
break;
case AUD_ACL: /* ACL */
- vaStr = (char *)va_arg(vaList, int);
+ vaStr = (char *)va_arg(vaList, char *);
if (vaStr)
fprintf(out, "ACL %s ", vaStr);
else
fprintf(out, "LONG %d ", vaLong);
break;
case AUD_LST: /* Ptr to another list */
- vaLst = (char *)va_arg(vaList, int);
+ vaLst = va_arg(vaList, va_list);
printbuf(out, 1, "VALST", 0, vaLst);
break;
case AUD_FID: /* AFSFid - contains 3 entries */
- vaFid = (struct AFSFid *)va_arg(vaList, int);
+ vaFid = va_arg(vaList, struct AFSFid *);
if (vaFid)
fprintf(out, "FID %u:%u:%u ", vaFid->Volume, vaFid->Vnode,
vaFid->Unique);
fprintf(out, "FID %u:%u:%u ", 0, 0, 0);
break;
case AUD_FIDS: /* array of Fids */
- vaFids = (struct AFSCBFids *)va_arg(vaList, int);
+ vaFids = va_arg(vaList, struct AFSCBFids *);
vaFid = NULL;
if (vaFids) {
fprintf(out, "\n");
}
+#ifdef AFS_PTHREAD_ENV
+static pthread_mutex_t audit_lock;
+static volatile afs_int32 audit_lock_initialized = 0;
+static pthread_once_t audit_lock_once = PTHREAD_ONCE_INIT;
+
+static void
+osi_audit_init_lock(void)
+{
+ pthread_mutex_init(&audit_lock, NULL);
+ audit_lock_initialized = 1;
+}
+#endif
+
+void
+osi_audit_init(void)
+{
+#ifdef AFS_PTHREAD_ENV
+ if (!audit_lock_initialized) {
+ pthread_once(&audit_lock_once, osi_audit_init_lock);
+ }
+#endif /* AFS_PTHREAD_ENV */
+}
+
/* ************************************************************************** */
/* The routine that acually does the audit call.
* ************************************************************************** */
#ifdef AFS_AIX32_ENV
afs_int32 code;
afs_int32 err;
+ static char BUFFER[32768];
#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,
- PTHREAD_COND_INITIALIZER,
- PTHREAD_COND_INITIALIZER
+ /* i'm pretty sure all the server apps now call osi_audit_init(),
+ * but to be extra careful we'll leave this assert in here for a
+ * while to make sure */
+ assert(audit_lock_initialized);
#endif /* AFS_PTHREAD_ENV */
- };
- static char BUFFER[32768];
-#endif
if ((osi_audit_all < 0) || (osi_echo_trail < 0))
osi_audit_check();
break;
}
+#ifdef AFS_PTHREAD_ENV
+ pthread_mutex_lock(&audit_lock);
+#endif
#ifdef AFS_AIX32_ENV
- ObtainWriteLock(&audbuflock);
bufferPtr = BUFFER;
/* Put the error code into the buffer list */
printf("Error while writing audit entry: %d.\n", errno);
}
#endif /* notdef */
- ReleaseWriteLock(&audbuflock);
#else
if (auditout) {
va_start(vaList, errCode);
fflush(auditout);
}
#endif
+#ifdef AFS_PTHREAD_ENV
+ pthread_mutex_unlock(&audit_lock);
+#endif
return 0;
}
}
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);
+ static char local_realms[AFS_NUM_LREALMS][AFS_REALM_SZ];
+ static int num_lrealms = -1;
+ int i, lrealm_match;
+
+ if (num_lrealms == -1) {
+ for (i=0; i<AFS_NUM_LREALMS; i++) {
+ if (afs_krb_get_lrealm(local_realms[i], i) != 0 /*KSUCCESS*/)
+ break;
+ }
+
+ if (i=0)
+ strncpy(local_realms[0], "UNKNOWN.LOCAL.REALM", AFS_REALM_SZ);
+ num_lrealms = i;
}
- if (strcasecmp(local_realm, tcell)) {
+
+ /* Check to see if the ticket cell matches one of the local realms */
+ lrealm_match = 0;
+ for ( i=0;i<num_lrealms;i++ ) {
+ if (!strcasecmp(local_realms[i], tcell)) {
+ lrealm_match = 1;
+ break;
+ }
+ }
+ /* If yes, then make sure that the name is not present in
+ * an exclusion list */
+ if (lrealm_match) {
+ char uname[256];
+ if (inst[0])
+ snprintf(uname,sizeof(uname),"%s.%s@%s",name,inst,tcell);
+ else
+ snprintf(uname,sizeof(uname),"%s@%s",name,tcell);
+
+ if (afs_krb_exclusion(uname))
+ lrealm_match = 0;
+ }
+
+ if (!lrealm_match) {
if (strlen(vname) + 1 + clen >= sizeof(vname))
goto done;
strcat(vname, "@");