* KEY := LOGSET '.' SEVSET
* LOGSET := LOGLIT | LOGLIT ',' LOGSET
* LOGLIT := a registered log type
- * SEVSET := '*' | SEVLIT | '<' SEVLIT | '<=' SEVLIT | '>' SEVLIT | '>=' SEVLIT | SEVLIG ',' SEVSET
+ * SEVSET := '*' | SEVLIT | '<' SEVLIT | '<=' SEVLIT | '>' SEVLIT | '>=' SEVLIT | SEVLIT ',' SEVSET
* SEVLIT := one of log_severity_names
* A KEY contains the Cartesian product of the logs in its LOGSET
* and the severities in its SEVSET.
int first;
cont = strchr(buffer, ',');
- if (cont) *cont++ = 0;
+ if (cont)
+ *cont++ = 0;
if (buffer[0] == '*' && buffer[1] == 0) {
for (bound = 0; bound < LOG_NUM_SEVERITIES; bound++) {
/* make people explicitly specify replay targets */
}
}
} else {
+ if (buffer[0] == '=')
+ buffer++;
bound = find_severity(buffer);
targets[bound] = 1;
}
for (ii = 0; ii < slist->used; ++ii) {
type = log_register_type(slist->list[ii], NULL);
for (sev = 0; sev < LOG_NUM_SEVERITIES; ++sev) {
- if (!sevset[sev]) continue;
+ if (!sevset[sev])
+ continue;
logList_join(&type->logs[sev], &logList);
}
}
/* remove old elements from the linked list */
while (type->log_count > type->max_count)
log_type_free_oldest(type);
- while (type->log_oldest && (type->log_oldest->time + type->max_age < (unsigned long)now))
+ while (type->log_oldest && (type->log_oldest->time + (time_t)type->max_age < now))
log_type_free_oldest(type);
if (type->log_oldest)
type->log_oldest->prev = 0;
unsigned int ii;
va_list args;
+ if (!type)
+ return;
if (sev > LOG_FATAL) {
log_module(MAIN_LOG, LOG_ERROR, "Illegal log_module severity %d", sev);
return;
/* Special behavior before we start full operation */
fprintf(stderr, "%s: %s\n", log_severity_names[sev], msgbuf);
}
+ if (sev == LOG_FATAL) {
+ assert(0 && "fatal message logged");
+ _exit(1);
+ }
}
/* audit log searching */
/* Assume all criteria require arguments. */
if((argc - 1) % 2)
{
- send_message(user, service, "MSG_MISSING_PARAMS", argv[0]);
- return NULL;
+ send_message(user, service, "MSG_MISSING_PARAMS", argv[0]);
+ return NULL;
}
discrim = malloc(sizeof(struct logSearch));
else
discrim->max_time = now - (ParseInterval(cmp+1) - 1);
} else {
- discrim->min_time = now - ParseInterval(cmp+2);
+ discrim->min_time = now - ParseInterval(cmp);
}
} else if (!irccasecmp(argv[ii], "limit")) {
discrim->limit = strtoul(argv[++ii], NULL, 10);
send_message(user, service, "MSG_INVALID_FACILITY", argv[ii]);
goto fail;
}
- } else {
- send_message(user, service, "MSG_INVALID_CRITERIA", argv[ii]);
- goto fail;
- }
+ } else {
+ send_message(user, service, "MSG_INVALID_CRITERIA", argv[ii]);
+ goto fail;
+ }
}
return discrim;
&& !match_ircglob(entry->user_hostmask, discrim->masks.user_hostmask))
|| (discrim->masks.command
&& !match_ircglob(entry->command, discrim->masks.command))) {
- return 0;
+ return 0;
}
return 1;
}
unsigned int matched = 0;
if (discrim->type) {
+ static volatile struct logEntry *last;
struct logEntry *entry;
- for (entry = discrim->type->log_oldest; entry; entry = entry->next) {
+ for (entry = discrim->type->log_oldest, last = NULL;
+ entry;
+ last = entry, entry = entry->next) {
+ verify(entry);
if (entry_match(discrim, entry)) {
esf(entry, data);
if (++matched >= discrim->limit)