src/html.c
src/lmtp.c
src/lmtp_proto.c
+ src/logger.c
src/main.c
src/map.c
src/memcached.c
src/util.c
src/radix.c
src/fuzzy.c
+ src/map.c
+ src/logger.c
src/memcached.c
src/message.c
src/html.c
lock_file (log->fd, FALSE);
if (write (log->fd, &header, sizeof (struct rspamd_binlog_header)) == -1) {
- msg_warn ("binlog_write_header: cannot write file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot write file %s, error %d, %s", log->filename, errno, strerror (errno));
return FALSE;
}
if (write (log->fd, log->metaindex, sizeof (struct rspamd_binlog_metaindex)) == -1) {
g_free (log->metaindex);
- msg_warn ("binlog_write_header: cannot write file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot write file %s, error %d, %s", log->filename, errno, strerror (errno));
unlock_file (log->fd, FALSE);
return FALSE;
}
bzero (log->cur_idx, sizeof (struct rspamd_index_block));
if (write (log->fd, log->cur_idx, sizeof (struct rspamd_index_block)) == -1) {
g_free (log->cur_idx);
- msg_warn ("binlog_write_header: cannot write file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot write file %s, error %d, %s", log->filename, errno, strerror (errno));
unlock_file (log->fd, FALSE);
return FALSE;
}
static char valid_magic[] = VALID_MAGIC, valid_version[] = VALID_VERSION;
if (read (log->fd, &log->header, sizeof (struct rspamd_binlog_header)) != sizeof (struct rspamd_binlog_header)) {
- msg_warn ("binlog_check_file: cannot read file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot read file %s, error %d, %s", log->filename, errno, strerror (errno));
return FALSE;
}
/* Now check all fields */
if (memcmp (&log->header.magic, valid_magic, sizeof (valid_magic)) != 0 ||
memcmp (&log->header.version, valid_version, sizeof (valid_version)) != 0) {
- msg_warn ("binlog_check_file: cannot validate file %s");
+ msg_warn ("cannot validate file %s");
return FALSE;
}
/* Now mmap metaindex and current index */
log->metaindex = g_malloc (sizeof (struct rspamd_binlog_metaindex));
}
if ((read (log->fd, log->metaindex, sizeof (struct rspamd_binlog_metaindex))) != sizeof (struct rspamd_binlog_metaindex)) {
- msg_warn ("binlog_check file: cannot read metaindex of file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot read metaindex of file %s, error %d, %s", log->filename, errno, strerror (errno));
return FALSE;
}
/* Current index */
log->cur_idx = g_malloc (sizeof (struct rspamd_index_block));
}
if (lseek (log->fd, log->metaindex->indexes[log->metaindex->last_index], SEEK_SET) == -1) {
- msg_info ("binlog_check_file: cannot seek in file: %s, error: %s", log->filename, strerror (errno));
+ msg_info ("cannot seek in file: %s, error: %s", log->filename, strerror (errno));
return FALSE;
}
if ((read (log->fd, log->cur_idx, sizeof (struct rspamd_index_block))) != sizeof (struct rspamd_index_block)) {
- msg_warn ("binlog_check_file: cannot read index in file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot read index in file %s, error %d, %s", log->filename, errno, strerror (errno));
return FALSE;
}
binlog_create (struct rspamd_binlog *log)
{
if ((log->fd = open (log->filename, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)) == -1) {
- msg_info ("binlog_create: cannot create file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_info ("cannot create file %s, error %d, %s", log->filename, errno, strerror (errno));
return FALSE;
}
binlog_open_real (struct rspamd_binlog *log)
{
if ((log->fd = open (log->filename, O_RDWR)) == -1) {
- msg_info ("binlog_open: cannot open file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_info ("cannot open file %s, error %d, %s", log->filename, errno, strerror (errno));
return FALSE;
}
if (stat (new->filename, &st) == -1) {
/* Check errno to check whether we should create this file */
if (errno != ENOENT) {
- msg_err ("binlog_open: cannot stat file: %s, error %s", new->filename, strerror (errno));
+ msg_err ("cannot stat file: %s, error %s", new->filename, strerror (errno));
return NULL;
}
else {
elt.value = node->value;
if (write (log->fd, &elt, sizeof (elt)) == -1) {
- msg_info ("write_binlog_tree: cannot write token to file: %s, error: %s", log->filename, strerror (errno));
+ msg_info ("cannot write token to file: %s, error: %s", log->filename, strerror (errno));
return TRUE;
}
/* Seek to end of file */
if ((seek = lseek (log->fd, 0, SEEK_END)) == -1) {
unlock_file (log->fd, FALSE);
- msg_info ("binlog_insert: cannot seek in file: %s, error: %s", log->filename, strerror (errno));
+ msg_info ("cannot seek in file: %s, error: %s", log->filename, strerror (errno));
return FALSE;
}
idx->len = g_tree_nnodes (nodes) * sizeof (struct rspamd_binlog_element);
if (lseek (log->fd, log->metaindex->indexes[log->metaindex->last_index], SEEK_SET) == -1) {
unlock_file (log->fd, FALSE);
- msg_info ("binlog_insert: cannot seek in file: %s, error: %s, seek: %L, op: insert index", log->filename,
+ msg_info ("cannot seek in file: %s, error: %s, seek: %L, op: insert index", log->filename,
strerror (errno), log->metaindex->indexes[log->metaindex->last_index]);
return FALSE;
}
if (write (log->fd, log->cur_idx, sizeof (struct rspamd_index_block)) == -1) {
unlock_file (log->fd, FALSE);
- msg_info ("binlog_insert: cannot write index to file: %s, error: %s", log->filename, strerror (errno));
+ msg_info ("cannot write index to file: %s, error: %s", log->filename, strerror (errno));
return FALSE;
}
log->cur_idx->last_index ++;
/* Seek to end of file */
if ((seek = lseek (log->fd, 0, SEEK_END)) == -1) {
unlock_file (log->fd, FALSE);
- msg_info ("create_new_metaindex_block: cannot seek in file: %s, error: %s", log->filename, strerror (errno));
+ msg_info ("cannot seek in file: %s, error: %s", log->filename, strerror (errno));
return FALSE;
}
if (write (log->fd, log->cur_idx, sizeof (struct rspamd_index_block)) == -1) {
unlock_file (log->fd, FALSE);
g_free (log->cur_idx);
- msg_warn ("create_new_metaindex_block: cannot write file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot write file %s, error %d, %s", log->filename, errno, strerror (errno));
return FALSE;
}
/* Offset to metaindex */
/* Overwrite all metaindexes */
if (lseek (log->fd, sizeof (struct rspamd_binlog_header), SEEK_SET) == -1) {
unlock_file (log->fd, FALSE);
- msg_info ("create_new_metaindex_block: cannot seek in file: %s, error: %s", log->filename, strerror (errno));
+ msg_info ("cannot seek in file: %s, error: %s", log->filename, strerror (errno));
return FALSE;
}
if (write (log->fd, log->metaindex, sizeof (struct rspamd_binlog_metaindex)) == -1) {
unlock_file (log->fd, FALSE);
- msg_info ("create_new_metaindex_block: cannot write metaindex in file: %s, error: %s", log->filename, strerror (errno));
+ msg_info ("cannot write metaindex in file: %s, error: %s", log->filename, strerror (errno));
return FALSE;
}
bzero (log->cur_idx, sizeof (struct rspamd_index_block));
backup_name = g_strdup_printf ("%s.%s", log->filename, BACKUP_SUFFIX);
if (stat (backup_name, &st) != -1) {
- msg_info ("rotate_binlog: replace old %s", backup_name);
+ msg_info ("replace old %s", backup_name);
unlink (backup_name);
}
off_t seek;
if (!log || !log->metaindex || !log->cur_idx || !nodes) {
- msg_info ("binlog_insert: improperly opened binlog: %s", log->filename);
+ msg_info ("improperly opened binlog: %s", log->filename);
return FALSE;
}
if (log->metaindex->last_index < METAINDEX_LEN) {
/* Create new index block */
if ((seek = lseek (log->fd, 0, SEEK_END)) == -1) {
- msg_info ("binlog_insert: cannot seek in file: %s, error: %s", log->filename, strerror (errno));
+ msg_info ("cannot seek in file: %s, error: %s", log->filename, strerror (errno));
return FALSE;
}
if (!create_new_metaindex_block (log)) {
gboolean idx_mapped = FALSE, res = TRUE, is_first = FALSE;
if (!log || !log->metaindex || !log->cur_idx) {
- msg_info ("binlog_sync: improperly opened binlog: %s", log->filename);
+ msg_info ("improperly opened binlog: %s", log->filename);
return FALSE;
}
idx_mapped = TRUE;
if (lseek (log->fd, log->metaindex->indexes[metaindex_num], SEEK_SET) == -1) {
unlock_file (log->fd, FALSE);
- msg_warn ("binlog_sync: cannot seek file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot seek file %s, error %d, %s", log->filename, errno, strerror (errno));
res = FALSE;
goto end;
}
if ((read (log->fd, idxb, sizeof (struct rspamd_index_block))) != sizeof (struct rspamd_index_block)) {
unlock_file (log->fd, FALSE);
- msg_warn ("binlog_sync: cannot read index from file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot read index from file %s, error %d, %s", log->filename, errno, strerror (errno));
res = FALSE;
goto end;
}
(*rep)->len = idx->len;
/* Read result */
if (lseek (log->fd, idx->seek, SEEK_SET) == -1) {
- msg_warn ("binlog_sync: cannot seek file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot seek file %s, error %d, %s", log->filename, errno, strerror (errno));
res = FALSE;
goto end;
}
(*rep)->data = g_malloc (idx->len);
if ((read (log->fd, (*rep)->data, idx->len)) != idx->len) {
- msg_warn ("binlog_sync: cannot read file %s, error %d, %s", log->filename, errno, strerror (errno));
+ msg_warn ("cannot read file %s, error %d, %s", log->filename, errno, strerror (errno));
res = FALSE;
goto end;
}
buf->pos += r;
if (BUFREMAIN (buf) != 0) {
/* Continue with this buffer */
- msg_debug ("write_buffers: wrote %z bytes of %z", r, buf->data->len);
+ debug_ip (d->peer_addr, "wrote %z bytes of %z", r, buf->data->len);
continue;
}
}
}
}
else if (r == -1 && errno == EAGAIN) {
- msg_debug ("write_buffers: partially write data, retry");
+ debug_ip (d->peer_addr, "partially write data, retry");
/* Wait for other event */
event_del (d->ev);
event_set (d->ev, fd, EV_WRITE, dispatcher_cb, (void *)d);
g_list_free (d->out_buffers);
d->out_buffers = NULL;
- msg_debug ("write_buffers: all buffers were written successfully");
+ debug_ip (d->peer_addr, "all buffers were written successfully");
if (is_delayed && d->write_callback) {
if (!d->write_callback (d->user_data)) {
- msg_debug ("write_buffers: callback set wanna_die flag, terminating");
+ debug_ip (d->peer_addr, "callback set wanna_die flag, terminating");
return FALSE;
}
}
}
}
else if (r == -1 && errno == EAGAIN) {
- msg_debug ("read_buffers: partially read data, retry");
+ debug_ip (d->peer_addr, "partially read data, retry");
return;
}
else {
*pos += r;
*len += r;
}
- msg_debug ("read_buffers: read %z characters, policy is %s, watermark is: %z", r,
+ debug_ip (d->peer_addr, "read %z characters, policy is %s, watermark is: %z", r,
d->policy == BUFFER_LINE ? "LINE" : "CHARACTER", d->nchars);
}
*pos = b + *len;
r = 0;
if (d->policy != saved_policy) {
- msg_debug ("read_buffers: policy changed during callback, restart buffer's processing");
+ debug_ip (d->peer_addr, "policy changed during callback, restart buffer's processing");
read_buffers (fd, d, TRUE);
return;
}
*len -= r;
*pos = b + *len;
if (d->policy != saved_policy) {
- msg_debug ("read_buffers: policy changed during callback, restart buffer's processing");
+ debug_ip (d->peer_addr, "policy changed during callback, restart buffer's processing");
read_buffers (fd, d, TRUE);
return;
}
rspamd_io_dispatcher_t *d = (rspamd_io_dispatcher_t *) arg;
GError *err;
- msg_debug ("dispatcher_cb: in dispatcher callback, what: %d, fd: %d", (int)what, fd);
+ debug_ip (d->peer_addr, "in dispatcher callback, what: %d, fd: %d", (int)what, fd);
switch (what) {
case EV_TIMEOUT:
}
}
- msg_debug ("rspamd_set_dispatcher_policy: new input length watermark is %uz", d->nchars);
+ debug_ip (d->peer_addr, "new input length watermark is %uz", d->nchars);
}
gboolean
d->out_buffers = g_list_prepend (d->out_buffers, newbuf);
if (!delayed) {
- msg_debug ("rspamd_dispatcher_write: plan write event");
+ debug_ip (d->peer_addr, "plan write event");
return write_buffers (d->fd, d, FALSE);
}
return TRUE;
enum io_policy policy; /**< IO policy */
size_t nchars; /**< how many chars to read */
int fd; /**< descriptor */
+ uint32_t peer_addr; /**< address of peer for debugging */
gboolean wanna_die; /**< if dispatcher should be stopped */
dispatcher_read_callback_t read_callback; /**< read callback */
dispatcher_write_callback_t write_callback; /**< write callback */
int log_facility; /**< log facility in case of syslog */
int log_level; /**< log level trigger */
char *log_file; /**< path to logfile in case of file logging */
- int log_fd; /**< log descriptor in case of file logging */
- FILE *logf;
+ gboolean log_buffered; /**< whether logging is buffered */
+ uint32_t log_buf_size; /**< length of log buffer */
+ char *debug_ip_map; /**< turn on debugging for specified ip addresses */
gboolean log_urls; /**< whether we should log URLs */
size_t max_statfile_size; /**< maximum size for statfile */
ERROR return LOG_LEVEL_ERROR;
log_facility return LOG_FACILITY;
log_file return LOG_FILENAME;
+log_buffer return LOG_BUFFER;
+debug_ip return DEBUG_IP;
profile_file return PROFILE_FILE;
statfile_pool_size return STATFILE_POOL_SIZE;
%token VIEW IP FROM SYMBOLS CLIENT_IP
%token AUTOLEARN MIN_MARK MAX_MARK MAXFILES MAXCORE
%token SETTINGS USER_SETTINGS DOMAIN_SETTINGS SYMBOL PATH SKIP_CHECK GROW_FACTOR
+%token LOG_BUFFER DEBUG_IP
%type <string> STRING
%type <string> VARIABLE
| loggingfacility
| loggingfile
| loggingurls
+ | loggingbuffer
+ | loggingdebugip
;
loggingtype:
}
;
+loggingbuffer:
+ LOG_BUFFER EQSIGN NUMBER
+ | LOG_BUFFER EQSIGN SIZELIMIT {
+ cfg->log_buf_size = $3;
+ cfg->log_buffered = TRUE;
+ }
+ ;
+
+loggingdebugip:
+ DEBUG_IP EQSIGN QUOTEDSTRING {
+ cfg->debug_ip_map = $3;
+ }
+ ;
+
classifier:
CLASSIFIER OBRACE classifierbody EBRACE {
if (cur_classifier == NULL || cur_classifier->classifier == NULL) {
/* Try to call gethostbyname */
hent = gethostbyname (tokens[0]);
if (hent == NULL) {
- msg_warn ("parse_host_port: cannot resolve %s", tokens[0]);
+ msg_warn ("cannot resolve %s", tokens[0]);
goto err;
}
else {
errno = 0;
port_parsed = strtoul (tokens[1], &err_str, 10);
if (*err_str != '\0' || errno != 0) {
- msg_warn ("parse_host_port: cannot parse port: %s, at symbol %c, error: %s", tokens[1], *err_str, strerror (errno));
+ msg_warn ("cannot parse port: %s, at symbol %c, error: %s", tokens[1], *err_str, strerror (errno));
goto err;
}
if (port_parsed > G_MAXUINT16) {
errno = ERANGE;
- msg_warn ("parse_host_port: cannot parse port: %s, error: %s", tokens[1], *err_str, strerror (errno));
+ msg_warn ("cannot parse port: %s, error: %s", tokens[1], *err_str, strerror (errno));
goto err;
}
*port = port_parsed;
if (strcasecmp (modules[i].name, *p) == 0) {
cur = memory_pool_alloc (cfg->cfg_pool, sizeof (struct filter));
cur->type = C_FILTER;
- msg_debug ("parse_filters_str: found C filter %s", *p);
+ msg_debug ("found C filter %s", *p);
cur->func_name = memory_pool_strdup (cfg->cfg_pool, *p);
cur->module = &modules[i];
cfg->filters = g_list_prepend (cfg->filters, cur);
st = cur->data;
if ((data.file = statfile_pool_is_open (pool, st->path)) == NULL) {
if ((data.file = statfile_pool_open (pool, st->path, st->size, FALSE)) == NULL) {
- msg_warn ("winnow_classify: cannot open %s, skip it", st->path);
+ msg_warn ("cannot open %s, skip it", st->path);
cur = g_list_next (cur);
continue;
}
struct mime_part *p;
struct controller_session *session = ud;
- msg_debug ("free_session: freeing session %p", session);
+ msg_debug ("freeing session %p", session);
while ((part = g_list_first (session->parts))) {
session->parts = g_list_remove_link (session->parts, part);
arg = *args;
if (!arg || *arg == '\0') {
- msg_info ("process_sync_command: bad arguments to sync command, need symbol");
+ msg_info ("bad arguments to sync command, need symbol");
return FALSE;
}
symbol = arg;
arg = *(args + 1);
if (!arg || *arg == '\0') {
- msg_info ("process_sync_command: bad arguments to sync command, need revision");
+ msg_info ("bad arguments to sync command, need revision");
return FALSE;
}
rev = strtoull (arg, &err_str, 10);
if (err_str && *err_str != 0) {
- msg_info ("process_sync_command: bad arguments to sync commanc: %s", arg);
+ msg_info ("bad arguments to sync commanc: %s", arg);
return FALSE;
}
arg = *(args + 2);
if (!arg || *arg == '\0') {
- msg_info ("process_sync_command: bad arguments to sync command, need time");
+ msg_info ("bad arguments to sync command, need time");
return FALSE;
}
time = strtoull (arg, &err_str, 10);
if (err_str && *err_str != 0) {
- msg_info ("process_sync_command: bad arguments to sync commanc: %s", arg);
+ msg_info ("bad arguments to sync commanc: %s", arg);
return FALSE;
}
ccf = g_hash_table_lookup (session->cfg->classifiers_symbols, symbol);
if (ccf == NULL) {
- msg_info ("process_sync_command: bad symbol: %s", symbol);
+ msg_info ("bad symbol: %s", symbol);
return FALSE;
}
cur = g_list_next (cur);
}
if (st == NULL) {
- msg_info ("process_sync_command: bad symbol: %s", symbol);
+ msg_info ("bad symbol: %s", symbol);
return FALSE;
}
binlog = get_binlog_by_statfile (st);
if (binlog == NULL) {
- msg_info ("process_sync_command: cannot open binlog: %s", symbol);
+ msg_info ("cannot open binlog: %s", symbol);
return FALSE;
}
case COMMAND_PASSWORD:
arg = *cmd_args;
if (!arg || *arg == '\0') {
- msg_debug ("process_command: empty password passed");
+ msg_debug ("empty password passed");
r = snprintf (out_buf, sizeof (out_buf), "password command requires one argument" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE);
return;
if (check_auth (cmd, session)) {
arg = *cmd_args;
if (!arg || *arg == '\0') {
- msg_debug ("process_command: no statfile specified in learn command");
+ msg_debug ("no statfile specified in learn command");
r = snprintf (out_buf, sizeof (out_buf), "learn command requires at least two arguments: stat filename and its size" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE);
return;
}
arg = *(cmd_args + 1);
if (arg == NULL || *arg == '\0') {
- msg_debug ("process_command: no statfile size specified in learn command");
+ msg_debug ("no statfile size specified in learn command");
r = snprintf (out_buf, sizeof (out_buf), "learn command requires at least two arguments: stat filename and its size" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE);
return;
}
size = strtoul (arg, &err_str, 10);
if (err_str && *err_str != '\0') {
- msg_debug ("process_command: statfile size is invalid: %s", arg);
+ msg_debug ("statfile size is invalid: %s", arg);
r = snprintf (out_buf, sizeof (out_buf), "learn size is invalid" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE);
return;
break;
case 0:
if (!process_custom_command (cmd, ¶ms[1], session)) {
- msg_debug ("Unknown command: '%s'", cmd);
+ msg_debug ("'%s'", cmd);
i = snprintf (out_buf, sizeof (out_buf), "Unknown command" CRLF);
if (!rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) {
return FALSE;
}
break;
default:
- msg_debug ("Ambigious command: '%s'", cmd);
+ msg_debug ("'%s'", cmd);
i = snprintf (out_buf, sizeof (out_buf), "Ambigious command" CRLF);
if (!rspamd_dispatcher_write (session->dispatcher, out_buf, i, FALSE, FALSE)) {
return FALSE;
r = process_message (task);
if (r == -1) {
- msg_warn ("read_socket: processing of message failed");
+ msg_warn ("processing of message failed");
free_task (task, FALSE);
session->state = STATE_REPLY;
r = snprintf (out_buf, sizeof (out_buf), "cannot process message" CRLF);
rspamd_dispatcher_pause (session->dispatcher);
break;
default:
- msg_debug ("controller_read_socket: unknown state while reading %d", session->state);
+ msg_debug ("unknown state while reading %d", session->state);
break;
}
struct controller_session *session = (struct controller_session *)arg;
if (err->code != EOF) {
- msg_info ("controller_err_socket: abnormally closing control connection, error: %s", err->message);
+ msg_info ("abnormally closing control connection, error: %s", err->message);
}
/* Free buffers */
int nfd;
if ((nfd = accept_from_socket (fd, (struct sockaddr *)&ss, &addrlen)) == -1) {
- msg_warn ("accept_socket: accept failed: %s", strerror (errno));
+ msg_warn ("accept failed: %s", strerror (errno));
return;
}
new_session = g_malloc (sizeof (struct controller_session));
if (new_session == NULL) {
- msg_err ("accept_socket: cannot allocate memory for task, %s", strerror (errno));
+ msg_err ("cannot allocate memory for task, %s", strerror (errno));
return;
}
bzero (new_session, sizeof (struct controller_session));
/* Start statfile synchronization */
if (!start_statfile_sync (worker->srv->statfile_pool, worker->srv->cfg)) {
- msg_info ("start_controller: cannot start statfile synchronization, statfiles would not be synchronized");
+ msg_info ("cannot start statfile synchronization, statfiles would not be synchronized");
}
/* Init command completion */
SET(EVDNSSRC evdns.c)
ADD_LIBRARY(rspamd_evdns STATIC ${EVDNSSRC})
+SET_TARGET_PROPERTIES(rspamd_evdns PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
CLOSE_SOCKET(ns->socket);
out1:
g_free(ns);
- msg_warn("Unable to add nameserver %s: error %d", debug_ntop(address), err);
+ msg_warn("error %d", debug_ntop(address), err);
return err;
}
GList *cur;
if (session == NULL) {
- msg_info ("register_async_event: session is NULL");
+ msg_info ("session is NULL");
return;
}
GList *cur;
if (session == NULL) {
- msg_info ("remove_forced_event: session is NULL");
+ msg_info ("session is NULL");
return;
}
GList *cur;
if (session == NULL) {
- msg_info ("remove_forced_event: session is NULL");
+ msg_info ("session is NULL");
return;
}
GList *cur, *tmp;
if (session == NULL) {
- msg_info ("destroy_session: session is NULL");
+ msg_info ("session is NULL");
return FALSE;
}
return NULL;
}
- msg_debug ("parse_expression: parsing expression {{ %s }}", line);
+ msg_debug ("parsing expression {{ %s }}", line);
function_stack = g_queue_new ();
p = line;
str = memory_pool_alloc (pool, p - c + 2);
g_strlcpy (str, c - 1, (p - c + 2));
g_strstrip (str);
- msg_debug ("parse_expression: found regexp: %s", str);
+ msg_debug ("found regexp: %s", str);
if (strlen (str) > 0) {
insert_expression (pool, &expr, EXPR_REGEXP, 0, str);
}
g_queue_free (function_stack);
if (state != SKIP_SPACES) {
/* In fact we got bad expression */
- msg_warn ("parse_expression: expression \"%s\" is invalid", line);
+ msg_warn ("expression \"%s\" is invalid", line);
return NULL;
}
/* Pop everything from stack */
line++;
}
if (line == '\0') {
- msg_warn ("parse_regexp: got empty regexp");
+ msg_warn ("got empty regexp");
return NULL;
}
/* First try to find header name */
}
else {
/* We got header name earlier but have not found // expression, so it is invalid regexp */
- msg_warn ("parse_regexp: got no header name (eg. header=) but without corresponding regexp, %s", src);
+ msg_warn ("got no header name (eg. header=) but without corresponding regexp, %s", src);
return NULL;
}
/* Find end */
end++;
}
if (end == begin || *end != '/') {
- msg_warn ("parse_regexp: no trailing / in regexp %s", src);
+ msg_warn ("no trailing / in regexp %s", src);
return NULL;
}
/* Parse flags */
if (result->regexp == NULL || err != NULL) {
*end = '/';
- msg_warn ("parse_regexp: could not read regexp: %s while reading regexp %s", err->message, src);
+ msg_warn ("could not read regexp: %s while reading regexp %s", err->message, src);
return NULL;
}
if ((regexp_flags & G_REGEX_RAW) != 0) {
*end = '/';
if (result->raw_regexp == NULL || err != NULL) {
- msg_warn ("parse_regexp: could not read raw regexp: %s while reading regexp %s", err->message, src);
+ msg_warn ("could not read raw regexp: %s while reading regexp %s", err->message, src);
return NULL;
}
selected = bsearch (&key, list_ptr, functions_number, sizeof (struct _fl), fl_cmp);
if (selected == NULL) {
- msg_warn ("call_expression_function: call to undefined function %s", key.name);
+ msg_warn ("call to undefined function %s", key.name);
return FALSE;
}
struct expression *it;
if (expr == NULL) {
- msg_warn ("get_function_arg: NULL expression passed");
+ msg_warn ("NULL expression passed");
return NULL;
}
if (expr->next == NULL) {
res->data = GSIZE_TO_POINTER (cur);
}
else {
- msg_warn ("get_function_arg: cannot parse argument: it contains operator or bool expression that is not wanted");
+ msg_warn ("cannot parse argument: it contains operator or bool expression that is not wanted");
return NULL;
}
return res;
}
else if (it->type == EXPR_FUNCTION) {
cur = (gsize) call_expression_function ((struct expression_function *)it->content.operand, task);
- msg_debug ("get_function_arg: function %s returned %s", ((struct expression_function *)it->content.operand)->name, cur ? "true" : "false");
+ debug_task ("function %s returned %s", ((struct expression_function *)it->content.operand)->name, cur ? "true" : "false");
}
else if (it->type == EXPR_OPERATION) {
if (g_queue_is_empty (stack)) {
/* Queue has no operands for operation, exiting */
- msg_debug ("get_function_arg: invalid expression");
+ debug_task ("invalid expression");
g_queue_free (stack);
return NULL;
}
return res;
}
- msg_warn ("get_function_arg: invalid expression argument");
+ msg_warn ("invalid expression argument");
return NULL;
}
arg = get_function_arg (args->data, task, TRUE);
if (arg->type == EXPRESSION_ARGUMENT_BOOL) {
- msg_warn ("rspamd_compare_encoding: invalid argument to function is passed");
+ msg_warn ("invalid argument to function is passed");
return FALSE;
}
arg = get_function_arg (args->data, task, TRUE);
if (!arg || arg->type == EXPRESSION_ARGUMENT_BOOL) {
- msg_warn ("rspamd_header_exists: invalid argument to function is passed");
+ msg_warn ("invalid argument to function is passed");
return FALSE;
}
struct expression_argument *arg;
if (args == NULL) {
- msg_debug ("rspamd_parts_distance: no threshold is specified, assume it 100");
+ debug_task ("no threshold is specified, assume it 100");
threshold = 100;
}
else {
arg = get_function_arg (args->data, task, TRUE);
threshold = strtoul ((char *)arg->data, NULL, 10);
if (errno != 0) {
- msg_info ("rspamd_parts_distance: bad numeric value for threshold \"%s\", assume it 100", (char *)args->data);
+ msg_info ("bad numeric value for threshold \"%s\", assume it 100", (char *)args->data);
threshold = 100;
}
}
p1 = cur->data;
cur = g_list_next (cur);
if (cur == NULL) {
- msg_info ("rspamd_parts_distance: bad parts list");
+ msg_info ("bad parts list");
return FALSE;
}
p2 = cur->data;
}
}
else {
- msg_debug ("rspamd_parts_distance: message has too many text parts, so do not try to compare them with each other");
+ debug_task ("message has too many text parts, so do not try to compare them with each other");
return FALSE;
}
int r;
if (args == NULL) {
- msg_warn ("rspamd_content_type_compare_param: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
arg = get_function_arg (args->data, task, TRUE);
param_name = arg->data;
args = g_list_next (args);
if (args == NULL) {
- msg_warn ("rspamd_content_type_compare_param: too few params to function");
+ msg_warn ("too few params to function");
return FALSE;
}
arg = get_function_arg (args->data, task, TRUE);
if ((re = re_cache_check (param_pattern)) == NULL) {
re = parse_regexp (task->cfg->cfg_pool, param_pattern, task->cfg->raw_mode);
if (re == NULL) {
- msg_warn ("rspamd_content_type_compare_param: cannot compile regexp for function");
+ msg_warn ("cannot compile regexp for function");
return FALSE;
}
re_cache_add (param_pattern, re);
const GMimeContentType *ct;
if (args == NULL) {
- msg_warn ("rspamd_content_type_compare_param: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
arg = get_function_arg (args->data, task, TRUE);
ct = g_mime_object_get_content_type (part);
g_object_unref (part);
- msg_debug ("rspamd_content_type_has_param: checking %s param", param_name);
+ debug_task ("checking %s param", param_name);
if ((param_data = g_mime_content_type_get_parameter (ct, param_name)) == NULL) {
return FALSE;
int r;
if (args == NULL) {
- msg_warn ("rspamd_content_type_compare_param: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
if ((re = re_cache_check (param_pattern)) == NULL) {
re = parse_regexp (task->cfg->cfg_pool, param_pattern, task->cfg->raw_mode);
if (re == NULL) {
- msg_warn ("rspamd_content_type_compare_param: cannot compile regexp for function");
+ msg_warn ("cannot compile regexp for function");
return FALSE;
}
re_cache_add (param_pattern, re);
int r;
if (args == NULL) {
- msg_warn ("rspamd_content_type_compare_param: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
if ((re = re_cache_check (param_pattern)) == NULL) {
re = parse_regexp (task->cfg->cfg_pool, param_pattern, task->cfg->raw_mode);
if (re == NULL) {
- msg_warn ("rspamd_content_type_compare_param: cannot compile regexp for function");
+ msg_warn ("cannot compile regexp for function");
return FALSE;
}
re_cache_add (param_pattern, re);
int num, i, j, hits = 0, total = 0;
if (args == NULL) {
- msg_warn ("rspamd_content_type_compare_param: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
errno = 0;
threshold = strtod ((char *)arg->data, NULL);
if (errno != 0) {
- msg_warn ("rspamd_recipients_distance: invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
+ msg_warn ("invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
return FALSE;
}
if ((re = re_cache_check (subtype)) == NULL) {
re = parse_regexp (task->cfg->cfg_pool, subtype, task->cfg->raw_mode);
if (re == NULL) {
- msg_warn ("compare_subtype: cannot compile regexp for function");
+ msg_warn ("cannot compile regexp for function");
return FALSE;
}
re_cache_add (subtype, re);
if ((re = re_cache_check (param_type)) == NULL) {
re = parse_regexp (task->cfg->cfg_pool, param_type, task->cfg->raw_mode);
if (re == NULL) {
- msg_warn ("rspamd_has_content_part: cannot compile regexp for function");
+ msg_warn ("cannot compile regexp for function");
cur = g_list_next (cur);
continue;
}
struct expression_argument *arg;
if (args == NULL) {
- msg_warn ("rspamd_has_content_part: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
struct expression_argument *arg;
if (args == NULL) {
- msg_warn ("rspamd_has_content_part_len: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
errno = 0;
min = strtoul (arg->data, NULL, 10);
if (errno != 0) {
- msg_warn ("rspamd_has_content_part_len: invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
+ msg_warn ("invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
return FALSE;
}
args = args->next;
arg = get_function_arg (args->data, task, TRUE);
max = strtoul (arg->data, NULL, 10);
if (errno != 0) {
- msg_warn ("rspamd_has_content_part_len: invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
+ msg_warn ("invalid numeric value '%s': %s", (char *)arg->data, strerror (errno));
return FALSE;
}
}
struct expression_argument *arg;
if (args == NULL) {
- msg_warn ("rspamd_compare_transfer_encoding: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
#else
if (enc_req == GMIME_CONTENT_ENCODING_DEFAULT) {
#endif
- msg_warn ("rspamd_compare_transfer_encoding: bad encoding type: %s", (char *)arg->data);
+ msg_warn ("bad encoding type: %s", (char *)arg->data);
return FALSE;
}
if (GMIME_IS_PART (part)) {
part_enc = g_mime_part_get_encoding (GMIME_PART (part));
- msg_debug ("rspamd_compare_transfer_encoding: got encoding in part: %d and compare with %d", (int)part_enc, (int)enc_req);
+ debug_task ("got encoding in part: %d and compare with %d", (int)part_enc, (int)enc_req);
g_object_unref (part);
return part_enc == enc_req;
struct html_callback_data cd;
if (args == NULL) {
- msg_warn ("rspamd_has_html_tag: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
arg = get_function_arg (args->data, task, TRUE);
tag = get_tag_by_name (arg->data);
if (tag == NULL) {
- msg_warn ("rspamd_has_html_tag: unknown tag type passed as argument: %s", (char *)arg->data);
+ msg_warn ("unknown tag type passed as argument: %s", (char *)arg->data);
return FALSE;
}
double *factor, fs, grow = 1;
struct symbol *s = (struct symbol *)value;
struct consolidation_callback_data *data = (struct consolidation_callback_data *)arg;
+ struct worker_task *task = data->task;
if (data->count > 0) {
grow = 1. + (data->task->cfg->grow_factor - 1.) * data->count;
else {
factor = g_hash_table_lookup (data->task->worker->srv->cfg->factors, key);
if (factor == NULL) {
- msg_debug ("consolidation_callback: got %.2f score for metric %s, factor: 1", s->score, (char *)key);
+ debug_task ("got %.2f score for metric %s, factor: 1", s->score, (char *)key);
data->score += s->score;
}
else {
else {
data->score += *factor * s->score;
}
- msg_debug ("consolidation_callback: got %.2f score for metric %s, factor: %.2f", s->score, (char *)key, *factor);
+ debug_task ("got %.2f score for metric %s, factor: %.2f", s->score, (char *)key, *factor);
}
}
}
c_module->filter (task);
}
else {
- msg_debug ("call_filter_by_name: %s is not a C module", name);
+ debug_task ("%s is not a C module", name);
}
break;
case PERL_FILTER:
#elif defined(WITH_LUA)
lua_call_filter (name, task);
#else
- msg_err ("call_filter_by_name: trying to call perl function while perl support is disabled %s", name);
+ msg_err ("trying to call perl function while perl support is disabled %s", name);
#endif
break;
}
- msg_debug ("call_filter_by_name: filter name: %s, result: %d", name, (int)res);
+ debug_task ("filter name: %s, result: %d", name, (int)res);
}
static void
else {
metric_res->score = factor_consolidation_func (task, metric_res->metric->name, NULL);
}
- msg_debug ("process_metric_callback: got result %.2f from consolidation function for metric %s", metric_res->score, metric_res->metric->name);
+ debug_task ("got result %.2f from consolidation function for metric %s", metric_res->score, metric_res->metric->name);
}
static void
if (check_skip (task->cfg->views, task)) {
task->is_skipped = TRUE;
task->state = WRITE_REPLY;
- msg_info ("process_filters: disable check for message id <%s>, view wants spam", task->message_id);
+ msg_info ("disable check for message id <%s>, view wants spam", task->message_id);
return 1;
}
/* Check want spam setting */
if (check_want_spam (task)) {
task->is_skipped = TRUE;
task->state = WRITE_REPLY;
- msg_info ("process_filters: disable check for message id <%s>, user wants spam", task->message_id);
+ msg_info ("disable check for message id <%s>, user wants spam", task->message_id);
return 1;
}
/* For ham messages */
return TRUE;
}
- msg_debug ("check_autolearn: metric %s has no results", metric_name);
+ debug_task ("metric %s has no results", metric_name);
return FALSE;
}
else {
if (check_autolearn (st->autolearn, task)) {
if (tokens) {
- msg_info ("process_autolearn: message with id <%s> autolearned statfile '%s'", task->message_id, filename);
+ msg_info ("message with id <%s> autolearned statfile '%s'", task->message_id, filename);
/* Get or create statfile */
statfile = get_statfile_by_symbol (task->worker->srv->statfile_pool, ctx->cfg,
c.len = text_part->content->len;
/* Tree would be freed at task pool freeing */
if (!cl->tokenizer->tokenize_func (cl->tokenizer, task->task_pool, &c, &tokens)) {
- msg_info ("statfiles_callback: cannot tokenize input");
+ msg_info ("cannot tokenize input");
return;
}
cur = g_list_next (cur);
return;
}
- msg_info ("sync_cache: syncing fuzzy hash storage");
+ msg_info ("syncing fuzzy hash storage");
filename = g_hash_table_lookup (wrk->cf->params, "hashfile");
if (filename == NULL) {
return;
}
if ((fd = open (filename, O_WRONLY | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH)) == -1) {
- msg_err ("sync_cache: cannot create hash file %s: %s", filename, strerror (errno));
+ msg_err ("cannot create hash file %s: %s", filename, strerror (errno));
return;
}
continue;
}
if (write (fd, node, sizeof (struct rspamd_fuzzy_node)) == -1) {
- msg_err ("sync_cache: cannot write file %s: %s", filename, strerror (errno));
+ msg_err ("cannot write file %s: %s", filename, strerror (errno));
}
cur = g_list_next (cur);
}
}
if ((fd = open (filename, O_RDONLY)) == -1) {
- msg_err ("read_hashes_file: cannot open hash file %s: %s", filename, strerror (errno));
+ msg_err ("cannot open hash file %s: %s", filename, strerror (errno));
return FALSE;
}
close (fd);
if (r > 0) {
- msg_warn ("read_hashes_file: ignore garbadge at the end of file, length of garbadge: %d", r);
+ msg_warn ("ignore garbadge at the end of file, length of garbadge: %d", r);
}
else if (r == -1) {
- msg_err ("read_hashes_file: cannot open read file %s: %s", filename, strerror (errno));
+ msg_err ("cannot open read file %s: %s", filename, strerror (errno));
return FALSE;
}
while (cur) {
h = cur->data;
if ((prob = fuzzy_compare_hashes (&h->h, &s)) > LEV_LIMIT) {
- msg_info ("process_check_command: fuzzy hash was found, probability %d%%", prob);
+ msg_info ("fuzzy hash was found, probability %d%%", prob);
return TRUE;
}
cur = g_list_next (cur);
}
- msg_debug ("process_check_command: fuzzy hash was NOT found, prob is %d%%", prob);
+ msg_debug ("fuzzy hash was NOT found, prob is %d%%", prob);
return FALSE;
}
g_queue_push_head (hashes[cmd->blocksize % BUCKETS], h);
bloom_add (bf, cmd->hash);
mods++;
- msg_info ("process_write_command: fuzzy hash was successfully added");
+ msg_info ("fuzzy hash was successfully added");
return TRUE;
}
cur = g_list_next (cur);
g_queue_delete_link (hashes[cmd->blocksize % BUCKETS], tmp);
bloom_del (bf, cmd->hash);
- msg_info ("process_delete_command: fuzzy hash was successfully deleted");
+ msg_info ("fuzzy hash was successfully deleted");
res = TRUE;
mods++;
continue;
do { \
if (process_##x##_command (&session->cmd)) { \
if (sendto (session->fd, "OK" CRLF, sizeof ("OK" CRLF) - 1, 0, (struct sockaddr *)&session->sa, session->salen) == -1) { \
- msg_err ("process_fuzzy_command: error while writing reply: %s", strerror (errno)); \
+ msg_err ("error while writing reply: %s", strerror (errno)); \
} \
} \
else { \
if (sendto (session->fd, "ERR" CRLF, sizeof ("ERR" CRLF) - 1, 0, (struct sockaddr *)&session->sa, session->salen) == -1) { \
- msg_err ("process_fuzzy_command: error while writing reply: %s", strerror (errno)); \
+ msg_err ("error while writing reply: %s", strerror (errno)); \
} \
} \
} while(0)
break;
default:
if (sendto (session->fd, "ERR" CRLF, sizeof ("ERR" CRLF) - 1, 0, (struct sockaddr *)&session->sa, session->salen) == -1) {
- msg_err ("process_fuzzy_command: error while writing reply: %s", strerror (errno));
+ msg_err ("error while writing reply: %s", strerror (errno));
}
break;
}
/* Got some data */
if (what == EV_READ) {
if ((r = recvfrom (fd, session.pos, sizeof (struct fuzzy_cmd), MSG_WAITALL, (struct sockaddr *)&session.sa, &session.salen)) == -1) {
- msg_err ("fuzzy_io_callback: got error while reading from socket: %d, %s", errno, strerror (errno));
+ msg_err ("got error while reading from socket: %d, %s", errno, strerror (errno));
return;
}
else if (r == sizeof (struct fuzzy_cmd)) {
process_fuzzy_command (&session);
}
else {
- msg_err ("fuzzy_io_callback: got incomplete data while reading from socket: %d, %s", errno, strerror (errno));
+ msg_err ("got incomplete data while reading from socket: %d, %s", errno, strerror (errno));
return;
}
}
bf = bloom_create (20000000L, DEFAULT_BLOOM_HASHES);
/* Try to read hashes from file */
if (!read_hashes_file (worker)) {
- msg_err ("read_hashes_file: cannot read hashes file, it can be created after save procedure");
+ msg_err ("cannot read hashes file, it can be created after save procedure");
}
/* Timer event */
evtimer_set (&tev, sync_callback, worker);
while ((worker->cf->listen_sock = make_udp_socket (&worker->cf->bind_addr, worker->cf->bind_port, TRUE, TRUE)) == -1) {
sleep (1);
if (++retries > MAX_RETRIES) {
- msg_err ("start_fuzzy_storage: cannot bind to socket, exiting");
+ msg_err ("cannot bind to socket, exiting");
exit (0);
}
}
else {
new = construct_html_node (pool, tag_text);
if (new == NULL) {
- msg_debug ("add_html_node: cannot construct HTML node for text '%s'", tag_text);
+ debug_task ("cannot construct HTML node for text '%s'", tag_text);
return -1;
}
data = new->data;
}
if (data->flags & FL_CLOSING) {
if (!*cur_level) {
- msg_debug ("add_html_node: bad parent node");
+ debug_task ("bad parent node");
return FALSE;
}
g_node_append (*cur_level, new);
if (!check_balance (new, cur_level)) {
- msg_debug ("add_html_node: mark part as unbalanced as it has not pairable closing tags");
+ debug_task ("mark part as unbalanced as it has not pairable closing tags");
part->is_balanced = FALSE;
}
}
value.c)
ADD_LIBRARY(rspamd_json STATIC ${JSONSRC})
+SET_TARGET_PROPERTIES(rspamd_json PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
{
GList *part;
struct mime_part *p;
+ struct worker_task *task = lmtp->task;
if (lmtp) {
- msg_debug ("free_lmtp_task: free pointer %p", lmtp->task);
+ debug_task ("free pointer %p", lmtp->task);
if (lmtp->task->memc_ctx) {
memc_close_ctx (lmtp->task->memc_ctx);
}
case READ_COMMAND:
case READ_HEADER:
if (read_lmtp_input_line (lmtp, in) != 0) {
- msg_info ("read_lmtp_socket: closing lmtp connection due to protocol error");
+ msg_info ("closing lmtp connection due to protocol error");
lmtp->task->state = CLOSING_CONNECTION;
}
/* Task was read, recall read handler once more with new state to process message and write reply */
}
break;
default:
- msg_debug ("lmtp_read_socket: invalid state while reading from socket %d", lmtp->task->state);
+ debug_task ("invalid state while reading from socket %d", lmtp->task->state);
break;
}
lmtp_write_socket (void *arg)
{
struct rspamd_lmtp_proto *lmtp = (struct rspamd_lmtp_proto *)arg;
+ struct worker_task *task = lmtp->task;
switch (lmtp->task->state) {
case WRITE_REPLY:
lmtp->task->state = CLOSING_CONNECTION;
break;
case CLOSING_CONNECTION:
- msg_debug ("lmtp_write_socket: normally closing connection");
+ debug_task ("normally closing connection");
free_lmtp_task (lmtp, TRUE);
return FALSE;
break;
default:
- msg_debug ("lmtp_write_socket: invalid state while writing to socket %d", lmtp->task->state);
+ debug_task ("invalid state while writing to socket %d", lmtp->task->state);
break;
}
lmtp_err_socket (GError * err, void *arg)
{
struct rspamd_lmtp_proto *lmtp = (struct rspamd_lmtp_proto *)arg;
- msg_info ("lmtp_err_socket: abnormally closing connection, error: %s", err->message);
+ msg_info ("abnormally closing connection, error: %s", err->message);
/* Free buffers */
free_lmtp_task (lmtp, FALSE);
}
{
struct rspamd_worker *worker = (struct rspamd_worker *)arg;
struct sockaddr_storage ss;
+ struct sockaddr_in *sin;
struct worker_task *new_task;
struct rspamd_lmtp_proto *lmtp;
socklen_t addrlen = sizeof (ss);
int nfd;
if ((nfd = accept_from_socket (fd, (struct sockaddr *)&ss, &addrlen)) == -1) {
- msg_warn ("accept_socket: accept failed: %s", strerror (errno));
+ msg_warn ("accept failed: %s", strerror (errno));
return;
}
lmtp = g_malloc (sizeof (struct rspamd_lmtp_proto));
- new_task = g_malloc (sizeof (struct worker_task));
- bzero (new_task, sizeof (struct worker_task));
- new_task->worker = worker;
- new_task->state = READ_COMMAND;
+
+ new_task = construct_task (worker);
+
+ if (ss.ss_family == AF_UNIX) {
+ msg_info ("accepted connection from unix socket");
+ new_task->client_addr.s_addr = INADDR_NONE;
+ }
+ else if (ss.ss_family == AF_INET) {
+ sin = (struct sockaddr_in *)&ss;
+ msg_info ("accepted connection from %s port %d", inet_ntoa (sin->sin_addr), ntohs (sin->sin_port));
+ memcpy (&new_task->client_addr, &sin->sin_addr, sizeof (struct in_addr));
+ }
+
new_task->sock = nfd;
new_task->cfg = worker->srv->cfg;
new_task->task_pool = memory_pool_new (memory_pool_get_size ());
/* Set up dispatcher */
new_task->dispatcher = rspamd_create_dispatcher (nfd, BUFFER_LINE, lmtp_read_socket, lmtp_write_socket, lmtp_err_socket, &io_tv, (void *)lmtp);
+ new_task->dispatcher->peer_addr = new_task->client_addr.s_addr;
rspamd_dispatcher_write (lmtp->task->dispatcher, greetingbuf, strlen (greetingbuf), FALSE, FALSE);
}
case LMTP_READ_LHLO:
/* Search LHLO line */
if ((i = fstrstri (line, &lhlo_command)) == -1) {
- msg_info ("read_lmtp_input_line: LHLO expected but not found");
+ msg_info ("LHLO expected but not found");
out_lmtp_reply (lmtp->task, LMTP_BAD_CMD, "5.0.0", "Need LHLO here");
return -1;
}
case LMTP_READ_FROM:
/* Search MAIL FROM: line */
if ((i = fstrstri (line, &mail_command)) == -1) {
- msg_info ("read_lmtp_input_line: MAIL expected but not found");
+ msg_info ("MAIL expected but not found");
out_lmtp_reply (lmtp->task, LMTP_BAD_CMD, "5.0.0", "Need MAIL here");
return -1;
}
case LMTP_READ_RCPT:
/* Search RCPT_TO: line */
if ((i = fstrstri (line, &rcpt_command)) == -1) {
- msg_info ("read_lmtp_input_line: RCPT expected but not found");
+ msg_info ("RCPT expected but not found");
out_lmtp_reply (lmtp->task, LMTP_NO_RCPT, "5.5.4", "Need RCPT here");
return -1;
}
rcpt = extract_mail (lmtp->task->task_pool, &fstr);
if (*rcpt == '<' && *(rcpt + 1) == '>') {
/* Invalid or empty rcpt not allowed */
- msg_info ("read_lmtp_input_line: bad recipient");
+ msg_info ("bad recipient");
out_lmtp_reply (lmtp->task, LMTP_NO_RCPT, "5.5.4", "Bad recipient");
return -1;
}
case LMTP_READ_DATA:
/* Search DATA line */
if ((i = fstrstri (line, &data_command)) == -1) {
- msg_info ("read_lmtp_input_line: DATA expected but not found");
+ msg_info ("DATA expected but not found");
out_lmtp_reply (lmtp->task, LMTP_BAD_CMD, "5.0.0", "Need DATA here");
return -1;
}
switch (cd->state) {
case LMTP_WANT_GREETING:
if (!parse_mta_str (in, cd)) {
- msg_warn ("mta_read_socket: got bad greeting");
+ msg_warn ("got bad greeting");
close_mta_connection (cd, FALSE);
return FALSE;
}
break;
case LMTP_WANT_MAIL:
if (!parse_mta_str (in, cd)) {
- msg_warn ("mta_read_socket: got bad helo");
+ msg_warn ("got bad helo");
close_mta_connection (cd, FALSE);
return FALSE;
}
break;
case LMTP_WANT_RCPT:
if (!parse_mta_str (in, cd)) {
- msg_warn ("mta_read_socket: got bad mail from");
+ msg_warn ("got bad mail from");
close_mta_connection (cd, FALSE);
return FALSE;
}
break;
case LMTP_WANT_DATA:
if (!parse_mta_str (in, cd)) {
- msg_warn ("mta_read_socket: got bad rcpt");
+ msg_warn ("got bad rcpt");
close_mta_connection (cd, FALSE);
return FALSE;
}
break;
case LMTP_WANT_DOT:
if (!parse_mta_str (in, cd)) {
- msg_warn ("mta_read_socket: got bad data");
+ msg_warn ("got bad data");
close_mta_connection (cd, FALSE);
return FALSE;
}
cd->state = LMTP_WANT_CLOSING;
case LMTP_WANT_CLOSING:
if (!parse_mta_str (in, cd)) {
- msg_warn ("mta_read_socket: message not delivered");
+ msg_warn ("message not delivered");
close_mta_connection (cd, FALSE);
return FALSE;
}
mta_err_socket (GError * err, void *arg)
{
struct mta_callback_data *cd = (struct mta_callback_data *)arg;
- msg_info ("mta_err_socket: abnormaly terminating connection with MTA");
+ msg_info ("abnormaly terminating connection with MTA");
close_mta_connection (cd, FALSE);
}
sock = make_tcp_socket (&task->cfg->deliver_addr, task->cfg->deliver_port, FALSE, TRUE);
}
if (sock == -1) {
- msg_warn ("lmtp_deliver_mta: cannot create socket for %s, %s", task->cfg->deliver_host, strerror (errno));
+ msg_warn ("cannot create socket for %s, %s", task->cfg->deliver_host, strerror (errno));
}
cd = memory_pool_alloc (task->task_pool, sizeof (struct mta_callback_data));
/* Format arguments in shell style */
if (!g_shell_parse_argv (args, &argc, &argv, NULL)) {
- msg_info ("lmtp_deliver_lda: cannot parse arguments");
+ msg_info ("cannot parse arguments");
return -1;
}
if (pipe (p) == -1) {
g_strfreev (argv);
- msg_info ("lmtp_deliver_lda: cannot open pipe: %s", strerror (errno));
+ msg_info ("cannot open pipe: %s", strerror (errno));
return -1;
}
#ifdef HAVE_VFORK
if ((cpid = vfork ()) == -1) {
g_strfreev (argv);
- msg_info ("lmtp_deliver_lda: cannot fork: %s", strerror (errno));
+ msg_info ("cannot fork: %s", strerror (errno));
return -1;
}
#else
if ((cpid = fork ()) == -1) {
g_strfreev (argv);
- msg_info ("lmtp_deliver_lda: cannot fork: %s", strerror (errno));
+ msg_info ("cannot fork: %s", strerror (errno));
return -1;
}
#endif
if (g_mime_object_write_to_stream ((GMimeObject *) task->message, stream) == -1) {
g_strfreev (argv);
- msg_info ("lmtp_deliver_lda: cannot write stream to lda");
+ msg_info ("cannot write stream to lda");
return -1;
}
#endif
if (rc == -1) {
g_strfreev (argv);
- msg_info ("lmtp_deliver_lda: lda returned error code");
+ msg_info ("lda returned error code");
return -1;
}
else if (WIFEXITED (rc)) {
}
else {
g_strfreev (argv);
- msg_info ("lmtp_deliver_lda: lda returned error code %d", ecode);
+ msg_info ("lda returned error code %d", ecode);
return -1;
}
}
write_lmtp_reply (struct rspamd_lmtp_proto *lmtp)
{
int r;
+ struct worker_task *task = lmtp->task;
- msg_debug ("write_lmtp_reply: writing reply to client");
+ debug_task ("writing reply to client");
if (lmtp->task->error_code != 0) {
out_lmtp_reply (lmtp->task, lmtp->task->error_code, "", lmtp->task->last_error);
}
--- /dev/null
+/*
+ * Copyright (c) 2009, Rambler media
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Rambler media ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Rambler BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#include "config.h"
+#include "logger.h"
+#include "util.h"
+#include "main.h"
+#include "map.h"
+
+
+#ifdef RSPAMD_MAIN
+sig_atomic_t do_reopen_log = 0;
+#endif
+
+rspamd_logger_t *rspamd_log;
+
+static const char lf_chr = '\n';
+
+static void
+syslog_log_function (const gchar * log_domain, const gchar *function,
+ GLogLevelFlags log_level, const gchar * message,
+ gboolean forced, gpointer arg);
+static void
+file_log_function (const gchar * log_domain, const gchar *function,
+ GLogLevelFlags log_level, const gchar * message,
+ gboolean forced, gpointer arg);
+
+static void
+direct_write_log_line (void *data, int count, gboolean is_iov)
+{
+ char errmsg[128];
+ struct iovec *iov;
+ const char *line;
+ int r;
+
+ if (rspamd_log->enabled) {
+ if (is_iov) {
+ iov = (struct iovec *)data;
+ r = writev (rspamd_log->fd, iov, count);
+ }
+ else {
+ line = (const char *)data;
+ r = write (rspamd_log->fd, line, count);
+ }
+ if (r == -1) {
+ /* We cannot write message to file, so we need to detect error and make decision */
+ r = rspamd_snprintf (errmsg, sizeof (errmsg), "direct_write_log_line: cannot write log line: %s", strerror (errno));
+ if (errno == EBADF || errno == EIO || errno == EINTR) {
+ /* Descriptor is somehow invalid, try to restart */
+ reopen_log ();
+ if (write (rspamd_log->fd, errmsg, r) != -1) {
+ /* Try again */
+ direct_write_log_line (data, count, is_iov);
+ }
+ }
+ else if (errno == EFAULT || errno == EINVAL || errno == EFBIG || errno == ENOSPC) {
+ /* Rare case */
+ (void)write (rspamd_log->fd, errmsg, r);
+ }
+ else if (errno == EPIPE) {
+ /* We write to some pipe and it disappears, disable logging */
+ rspamd_log->enabled = FALSE;
+ }
+ }
+ }
+}
+
+/* Logging utility functions */
+int
+open_log (void)
+{
+
+ rspamd_log->enabled = TRUE;
+
+ switch (rspamd_log->cfg->log_type) {
+ case RSPAMD_LOG_CONSOLE:
+ /* Do nothing with console */
+ return 0;
+ case RSPAMD_LOG_SYSLOG:
+ openlog ("rspamd", LOG_NDELAY | LOG_PID, rspamd_log->cfg->log_facility);
+ return 0;
+ case RSPAMD_LOG_FILE:
+ rspamd_log->fd = open (rspamd_log->cfg->log_file, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
+ if (rspamd_log->fd == -1) {
+ fprintf (stderr, "open_log: cannot open desired log file: %s, %s", rspamd_log->cfg->log_file, strerror (errno));
+ return -1;
+ }
+ return 0;
+ }
+ return -1;
+}
+
+void
+close_log (void)
+{
+ flush_log_buf ();
+
+ switch (rspamd_log->type) {
+ case RSPAMD_LOG_CONSOLE:
+ /* Do nothing special */
+ break;
+ case RSPAMD_LOG_SYSLOG:
+ closelog ();
+ break;
+ case RSPAMD_LOG_FILE:
+ if (rspamd_log->enabled) {
+ if (fsync (rspamd_log->fd) == -1) {
+ msg_err ("error syncing log file: %s", strerror (errno));
+ }
+ close (rspamd_log->fd);
+ }
+ break;
+ }
+
+ rspamd_log->enabled = FALSE;
+}
+
+void
+rspamd_set_logger (enum rspamd_log_type type, struct config_file *cfg)
+{
+ char **strvec, *p, *err;
+ int num, i, k;
+ struct in_addr addr;
+ uint32_t mask = 0xFFFFFFFF;
+
+ if (rspamd_log == NULL) {
+ rspamd_log = g_malloc (sizeof (rspamd_logger_t));
+ bzero (rspamd_log, sizeof (rspamd_logger_t));
+ }
+
+ rspamd_log->type = type;
+ rspamd_log->pid = getpid ();
+
+ switch (type) {
+ case RSPAMD_LOG_CONSOLE:
+ rspamd_log->log_func = file_log_function;
+ rspamd_log->fd = STDERR_FILENO;
+ break;
+ case RSPAMD_LOG_SYSLOG:
+ rspamd_log->log_func = syslog_log_function;
+ break;
+ case RSPAMD_LOG_FILE:
+ rspamd_log->log_func = file_log_function;
+ break;
+ }
+
+ rspamd_log->cfg = cfg;
+ /* Set up buffer */
+ if (cfg->log_buffered) {
+ if (cfg->log_buf_size != 0) {
+ rspamd_log->io_buf.size = cfg->log_buf_size;
+ }
+ else {
+ rspamd_log->io_buf.size = BUFSIZ;
+ }
+ rspamd_log->is_buffered = TRUE;
+ rspamd_log->io_buf.buf = g_malloc (rspamd_log->io_buf.size);
+ }
+ /* Set up conditional logging */
+ if (cfg->debug_ip_map != NULL) {
+ /* Try to add it as map first of all */
+ rspamd_log->debug_ip = radix_tree_create ();
+ if (!add_map (cfg->debug_ip_map, read_radix_list, fin_radix_list, (void **)&rspamd_log->debug_ip)) {
+ /* Try to parse it as list */
+ strvec = g_strsplit (cfg->debug_ip_map, ",; ", 0);
+ num = g_strv_length (strvec);
+
+ for (i = 0; i < num; i++) {
+ g_strstrip (strvec[i]);
+
+ if ((p = strchr (strvec[i], '/')) != NULL) {
+ /* Try to extract mask */
+ *p = '\0';
+ p ++;
+ errno = 0;
+ k = strtoul (p, &err, 10);
+ if (errno != 0 || *err != '\0' || k > 32) {
+ continue;
+ }
+ }
+ else {
+ k = 32;
+ }
+ if (inet_aton (strvec[i], &addr)) {
+ /* Check ip */
+ mask = mask << (32 - k);
+ radix32tree_insert (rspamd_log->debug_ip, ntohl (addr.s_addr), mask, 1);
+ }
+ }
+ g_strfreev (strvec);
+ }
+ }
+}
+
+int
+reopen_log (void)
+{
+#ifdef RSPAMD_MAIN
+ do_reopen_log = 0;
+#endif
+ close_log ();
+ return open_log ();
+}
+
+void
+update_log_pid (void)
+{
+ rspamd_log->pid = getpid ();
+}
+
+void
+flush_log_buf (void)
+{
+ if (rspamd_log->is_buffered && (rspamd_log->type == RSPAMD_LOG_CONSOLE || rspamd_log->type == RSPAMD_LOG_FILE)) {
+ direct_write_log_line (rspamd_log->io_buf.buf, rspamd_log->io_buf.used, FALSE);
+ rspamd_log->io_buf.used = 0;
+ }
+}
+
+
+void
+rspamd_common_log_function (GLogLevelFlags log_level, const char *function, const char *fmt, ...)
+{
+ static char logbuf[BUFSIZ];
+ va_list vp;
+ u_char *end;
+
+ if (log_level <= rspamd_log->cfg->log_level) {
+ va_start (vp, fmt);
+ end = rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, vp);
+ *end = '\0';
+ va_end (vp);
+ rspamd_log->log_func (NULL, function, log_level, logbuf, FALSE, rspamd_log->cfg);
+ }
+}
+
+
+/* Fill buffer with message (limits must be checked BEFORE this call) */
+static void
+fill_buffer (const struct iovec *iov, int iovcnt)
+{
+ int i;
+
+ for (i = 0; i < iovcnt; i ++) {
+ memcpy (rspamd_log->io_buf.buf + rspamd_log->io_buf.used, iov[i].iov_base, iov[i].iov_len);
+ rspamd_log->io_buf.used += iov[i].iov_len;
+ }
+
+}
+
+/* Write message to buffer or to file */
+static void
+file_log_helper (const struct iovec *iov, int iovcnt)
+{
+ size_t len = 0;
+ int i;
+
+ if (! rspamd_log->is_buffered) {
+ /* Write string directly */
+ direct_write_log_line ((void *)iov, iovcnt, TRUE);
+ }
+ else {
+ /* Calculate total length */
+ for (i = 0; i < iovcnt; i ++) {
+ len += iov[i].iov_len;
+ }
+ /* Fill buffer */
+ if (rspamd_log->io_buf.size < len) {
+ /* Buffer is too small to hold this string, so write it dirrectly */
+ flush_log_buf ();
+ direct_write_log_line ((void *)iov, iovcnt, TRUE);
+ }
+ else if (rspamd_log->io_buf.used + len >= rspamd_log->io_buf.size) {
+ /* Buffer is full, try to write it dirrectly */
+ flush_log_buf ();
+ fill_buffer (iov, iovcnt);
+ }
+ else {
+ /* Copy incoming string to buffer */
+ fill_buffer (iov, iovcnt);
+ }
+ }
+}
+
+static void
+syslog_log_function (const gchar * log_domain, const gchar *function, GLogLevelFlags log_level, const gchar * message, gboolean forced, gpointer arg)
+{
+ struct config_file *cfg = (struct config_file *)arg;
+#ifdef RSPAMD_MAIN
+ if (do_reopen_log) {
+ reopen_log ();
+ }
+#endif
+ if (! rspamd_log->enabled) {
+ return;
+ }
+ if (function == NULL) {
+ if (forced || log_level <= cfg->log_level) {
+ if (forced || log_level >= G_LOG_LEVEL_DEBUG) {
+ syslog (LOG_DEBUG, "%s", message);
+ }
+ else if (log_level >= G_LOG_LEVEL_INFO) {
+ syslog (LOG_INFO, "%s", message);
+ }
+ else if (log_level >= G_LOG_LEVEL_WARNING) {
+ syslog (LOG_WARNING, "%s", message);
+ }
+ else if (log_level >= G_LOG_LEVEL_CRITICAL) {
+ syslog (LOG_ERR, "%s", message);
+ }
+ }
+ }
+ else {
+ if (forced || log_level <= cfg->log_level) {
+ if (log_level >= G_LOG_LEVEL_DEBUG) {
+ syslog (LOG_DEBUG, "%s: %s", function, message);
+ }
+ else if (log_level >= G_LOG_LEVEL_INFO) {
+ syslog (LOG_INFO, "%s: %s", function, message);
+ }
+ else if (log_level >= G_LOG_LEVEL_WARNING) {
+ syslog (LOG_WARNING, "%s: %s", function, message);
+ }
+ else if (log_level >= G_LOG_LEVEL_CRITICAL) {
+ syslog (LOG_ERR, "%s: %s", function, message);
+ }
+ }
+ }
+}
+
+static void
+file_log_function (const gchar * log_domain, const gchar *function, GLogLevelFlags log_level, const gchar * message, gboolean forced, gpointer arg)
+{
+ char tmpbuf[256], timebuf[32];
+ time_t now;
+ struct tm *tms;
+ struct iovec iov[3];
+ int r;
+
+ if (! rspamd_log->enabled) {
+ return;
+ }
+#ifdef RSPAMD_MAIN
+ if (do_reopen_log) {
+ reopen_log ();
+ }
+#endif
+
+ if (forced || log_level <= rspamd_log->cfg->log_level) {
+ now = time (NULL);
+ tms = localtime (&now);
+
+ strftime (timebuf, sizeof (timebuf), "%b %d %H:%M:%S", tms);
+ if (function == NULL) {
+ r = rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "#%P: %s rspamd ", rspamd_log->pid, timebuf);
+ }
+ else {
+ r = rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "#%P: %s rspamd %s: ", rspamd_log->pid, timebuf, function);
+ }
+ iov[0].iov_base = tmpbuf;
+ iov[0].iov_len = r;
+ iov[1].iov_base = (void *)message;
+ iov[1].iov_len = strlen (message);
+ iov[2].iov_base = (void *)&lf_chr;
+ iov[2].iov_len = 1;
+
+ file_log_helper (iov, 3);
+ }
+}
+
+void
+rspamd_conditional_debug (uint32_t addr, const char *function, const char *fmt, ...)
+{
+ static char logbuf[BUFSIZ];
+ va_list vp;
+ u_char *end;
+
+ if (rspamd_log->cfg->log_level >= G_LOG_LEVEL_DEBUG ||
+ (rspamd_log->debug_ip != NULL && radix32tree_find (rspamd_log->debug_ip, ntohl (addr)) != RADIX_NO_VALUE)) {
+
+ va_start (vp, fmt);
+ end = rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, vp);
+ *end = '\0';
+ va_end (vp);
+ rspamd_log->log_func (NULL, function, G_LOG_LEVEL_DEBUG, logbuf, TRUE, rspamd_log->cfg);
+ }
+}
+
+void
+rspamd_glib_log_function (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer arg)
+{
+ if (rspamd_log->enabled) {
+ rspamd_log->log_func (log_domain, NULL, log_level, message, FALSE, rspamd_log->cfg);
+ }
+}
--- /dev/null
+#ifndef RSPAMD_LOGGER_H
+#define RSPAMD_LOGGER_H
+
+#include "config.h"
+#include "cfg_file.h"
+#include "radix.h"
+
+typedef void (*rspamd_log_func_t)(const gchar * log_domain, const gchar *function,
+ GLogLevelFlags log_level, const gchar * message,
+ gboolean forced, gpointer arg);
+
+typedef struct rspamd_logger_s {
+ rspamd_log_func_t log_func;
+ struct config_file *cfg;
+ struct {
+ uint32_t size;
+ uint32_t used;
+ u_char *buf;
+ } io_buf;
+ int fd;
+ gboolean is_buffered;
+ gboolean enabled;
+ enum rspamd_log_type type;
+ pid_t pid;
+ radix_tree_t *debug_ip;
+} rspamd_logger_t;
+
+/**
+ * Init logger
+ */
+void rspamd_set_logger (enum rspamd_log_type type, struct config_file *cfg);
+/**
+ * Open log file or initialize other structures
+ */
+int open_log (void);
+/**
+ * Close log file or destroy other structures
+ */
+void close_log (void);
+/**
+ * Close and open log again
+ */
+int reopen_log (void);
+/**
+ * Set log pid
+ */
+void update_log_pid (void);
+
+/**
+ * Flush log buffer for some types of logging
+ */
+void flush_log_buf (void);
+/**
+ * Log function that is compatible for glib messages
+ */
+void rspamd_glib_log_function (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer arg);
+
+/**
+ * Function with variable number of arguments support
+ */
+void rspamd_common_log_function (GLogLevelFlags log_level, const char *function, const char *fmt, ...);
+
+/**
+ * Conditional debug function
+ */
+void rspamd_conditional_debug (uint32_t addr, const char *function, const char *fmt, ...) ;
+
+
+/* Typical functions */
+
+/* Logging in postfix style */
+#if (defined(RSPAMD_MAIN) || defined(RSPAMD_LIB))
+#define msg_err(args...) rspamd_common_log_function(G_LOG_LEVEL_CRITICAL, __FUNCTION__, ##args)
+#define msg_warn(args...) rspamd_common_log_function(G_LOG_LEVEL_WARNING, __FUNCTION__, ##args)
+#define msg_info(args...) rspamd_common_log_function(G_LOG_LEVEL_INFO, __FUNCTION__, ##args)
+#define msg_debug(args...) rspamd_common_log_function(G_LOG_LEVEL_DEBUG, __FUNCTION__, ##args)
+#define debug_task(args...) rspamd_conditional_debug(task->from_addr.s_addr, __FUNCTION__, ##args)
+#define debug_ip(ip, args...) rspamd_conditional_debug((ip), __FUNCTION__, ##args)
+#else
+#define msg_err(args...) fprintf(stderr, ##args)
+#define msg_warn(args...) fprintf(stderr, ##args)
+#define msg_info(args...) fprintf(stderr, ##args)
+#define msg_debug(args...) fprintf(stderr, ##args)
+#define debug_task(args...) fprintf(stderr, ##args)
+#endif
+
+#endif
ADD_LIBRARY(rspamd_lua STATIC ${LUASRC})
TARGET_LINK_LIBRARIES(rspamd_lua ${LUALIB})
+SET_TARGET_PROPERTIES(rspamd_lua PROPERTIES COMPILE_FLAGS "-DRSPAMD_LIB")
*ptask = task;
if (lua_pcall (cd->L, 2, 1, 0) != 0) {
- msg_warn ("call_classifier_pre_callbacks: error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
+ msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
else {
if (lua_istable (cd->L, 1)) {
lua_pushnumber (cd->L, out);
if (lua_pcall (cd->L, 3, 1, 0) != 0) {
- msg_warn ("call_classifier_pre_callbacks: error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
+ msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
else {
if (lua_isnumber (cd->L, 1)) {
module = cur->data;
if (module->path) {
if (luaL_loadfile (L, module->path) != 0) {
- msg_info ("lua_init_filters: load of %s failed: %s", module->path, lua_tostring (L, -1));
+ msg_info ("load of %s failed: %s", module->path, lua_tostring (L, -1));
cur = g_list_next (cur);
continue;
}
lua_setglobal (L, "rspamd_config");
/* do the call (1 arguments, 1 result) */
if (lua_pcall (L, 0, LUA_MULTRET, 0) != 0) {
- msg_info ("lua_init_filters: init of %s failed: %s", module->path, lua_tostring (L, -1));
+ msg_info ("init of %s failed: %s", module->path, lua_tostring (L, -1));
}
}
cur = g_list_next (cur);
*ptask = task;
if (lua_pcall (L, 1, 1, 0) != 0) {
- msg_info ("lua_call_filter: call to %s failed", function);
+ msg_info ("call to %s failed", function);
}
/* retrieve result */
if (!lua_isnumber (L, -1)) {
- msg_info ("lua_call_filter: function %s must return a number", function);
+ msg_info ("function %s must return a number", function);
}
result = lua_tonumber (L, -1);
lua_pop (L, 1); /* pop returned value */
lua_pushnumber (L, marks[i]);
}
if (lua_pcall (L, number, 1, 0) != 0) {
- msg_info ("lua_init_filters: call to %s failed", function);
+ msg_info ("call to %s failed", function);
}
/* retrieve result */
if (!lua_isnumber (L, -1)) {
- msg_info ("lua_call_header_filter: function %s must return a number", function);
+ msg_info ("function %s must return a number", function);
}
result = lua_tonumber (L, -1);
lua_pop (L, 1); /* pop returned value */
lua_pushstring (L, (const char *)key);
lua_pushnumber (L, s->score);
if (lua_pcall (L, 2, 1, 0) != 0) {
- msg_info ("lua_consolidation_callback: call to %s failed", data->func);
+ msg_info ("call to %s failed", data->func);
}
/* retrieve result */
if (!lua_isnumber (L, -1)) {
- msg_info ("lua_consolidation_callback: function %s must return a number", data->func);
+ msg_info ("function %s must return a number", data->func);
}
res = lua_tonumber (L, -1);
lua_pop (L, 1); /* pop returned value */
}
if (lua_pcall (cd->L, i, 1, 0) != 0) {
- msg_warn ("lua_metric_symbol_callback: error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
+ msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
else {
if (lua_isboolean (cd->L, 1)) {
r = g_malloc (sizeof (radix_tree_t *));
*r = radix_tree_create ();
if (!add_map (map_line, read_radix_list, fin_radix_list, (void **)r)) {
- msg_warn ("add_radix_map: invalid radix map %s", map_line);
+ msg_warn ("invalid radix map %s", map_line);
radix_tree_free (*r);
g_free (r);
lua_pushnil (L);
r = g_malloc (sizeof (GHashTable *));
*r = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
if (!add_map (map_line, read_host_list, fin_host_list, (void **)r)) {
- msg_warn ("add_radix_map: invalid hash map %s", map_line);
+ msg_warn ("invalid hash map %s", map_line);
g_hash_table_destroy (*r);
g_free (r);
lua_pushnil (L);
*ptask = task;
if (lua_pcall (cd->L, 1, 1, 0) != 0) {
- msg_warn ("lua_metric_symbol_callback: error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
+ msg_warn ("error running function %s: %s", cd->name, lua_tostring (cd->L, -1));
}
}
}
if (lua_pcall (cd->L, 4, 0, 0) != 0) {
- msg_info ("lua_dns_callback: call to %s failed: %s", cd->callback, lua_tostring (cd->L, -1));
+ msg_info ("call to %s failed: %s", cd->callback, lua_tostring (cd->L, -1));
}
cd->task->save.saved--;
cd->to_resolve = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 2));
cd->callback = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 3));
if (!cd->to_resolve || !cd->callback) {
- msg_info ("lua_task_resolve_dns_a: invalid parameters passed to function");
+ msg_info ("invalid parameters passed to function");
return 0;
}
if (evdns_resolve_ipv4 (cd->to_resolve, DNS_QUERY_NO_SEARCH, lua_dns_callback, (void *)cd) == 0) {
cd->callback = memory_pool_strdup (task->task_pool, luaL_checkstring (L, 3));
ina = memory_pool_alloc (task->task_pool, sizeof (struct in_addr));
if (!cd->to_resolve || !cd->callback || !inet_aton (cd->to_resolve, ina)) {
- msg_info ("lua_task_resolve_dns_a: invalid parameters passed to function");
+ msg_info ("invalid parameters passed to function");
return 0;
}
if (evdns_resolve_reverse (ina, DNS_QUERY_NO_SEARCH, lua_dns_callback, (void *)cd) == 0) {
while ((inf = g_queue_pop_head (signals_info))) {
if (inf->si_signo == SIGCHLD) {
- msg_info ("main: got SIGCHLD from child: %P; reason: '%s'",
+ msg_info ("got SIGCHLD from child: %P; reason: '%s'",
inf->si_pid, chldsigcode (inf->si_code));
}
else {
- msg_info ("main: got signal: '%s'; received from pid: %P; uid: %l",
+ msg_info ("got signal: '%s'; received from pid: %P; uid: %l",
g_strsignal (inf->si_signo), inf->si_pid, (long int)inf->si_uid);
}
g_free (inf);
if (geteuid () == 0 && cfg->rspamd_user) {
pwd = getpwnam (cfg->rspamd_user);
if (pwd == NULL) {
- msg_err ("drop_priv: user specified does not exists (%s), aborting", strerror (errno));
+ msg_err ("user specified does not exists (%s), aborting", strerror (errno));
exit (-errno);
}
if (cfg->rspamd_group) {
grp = getgrnam (cfg->rspamd_group);
if (grp == NULL) {
- msg_err ("drop_priv: group specified does not exists (%s), aborting", strerror (errno));
+ msg_err ("group specified does not exists (%s), aborting", strerror (errno));
exit (-errno);
}
if (setgid (grp->gr_gid) == -1) {
- msg_err ("drop_priv: cannot setgid to %d (%s), aborting", (int)grp->gr_gid, strerror (errno));
+ msg_err ("cannot setgid to %d (%s), aborting", (int)grp->gr_gid, strerror (errno));
exit (-errno);
}
if (initgroups (cfg->rspamd_user, grp->gr_gid) == -1) {
- msg_err ("drop_priv: initgroups failed (%s), aborting", strerror (errno));
+ msg_err ("initgroups failed (%s), aborting", strerror (errno));
exit (-errno);
}
}
if (setuid (pwd->pw_uid) == -1) {
- msg_err ("drop_priv: cannot setuid to %d (%s), aborting", (int)pwd->pw_uid, strerror (errno));
+ msg_err ("cannot setuid to %d (%s), aborting", (int)pwd->pw_uid, strerror (errno));
exit (-errno);
}
}
static void
config_logger (struct rspamd_main *rspamd, gboolean is_fatal)
{
- switch (rspamd->cfg->log_type) {
- case RSPAMD_LOG_CONSOLE:
- if (!rspamd->cfg->no_fork) {
- if (is_fatal) {
- fprintf (stderr, "Cannot log to console while daemonized, disable logging\n");
- }
- rspamd->cfg->log_fd = -1;
- rspamd->cfg->logf = NULL;
- }
- else {
- rspamd->cfg->logf = stderr;
- rspamd->cfg->log_fd = STDERR_FILENO;
- }
- rspamd_set_logger (file_log_function, rspamd->cfg);
- g_log_set_default_handler (file_log_function, rspamd->cfg);
- break;
- case RSPAMD_LOG_FILE:
- if (rspamd->cfg->log_file == NULL || open_log (rspamd->cfg) == -1) {
- if (is_fatal) {
- fprintf (stderr, "Fatal error, cannot open logfile, exiting\n");
- exit (EXIT_FAILURE);
- }
- else {
- msg_err ("config_logger: cannot log to file, logfile unaccessable");
- }
- }
- else {
- rspamd_set_logger (file_log_function, rspamd->cfg);
- g_log_set_default_handler (file_log_function, rspamd->cfg);
- }
- break;
- case RSPAMD_LOG_SYSLOG:
- if (open_log (rspamd->cfg) == -1) {
- if (is_fatal) {
- fprintf (stderr, "Fatal error, cannot open syslog facility, exiting\n");
- exit (EXIT_FAILURE);
- }
- else {
- msg_err ("config_logger: cannot log to syslog");
- }
+ rspamd_set_logger (rspamd->cfg->log_type, rspamd->cfg);
+ if (open_log () == -1) {
+ if (is_fatal) {
+ fprintf (stderr, "Fatal error, cannot open logfile, exiting\n");
+ exit (EXIT_FAILURE);
}
else {
- rspamd_set_logger (syslog_log_function, rspamd->cfg);
- g_log_set_default_handler (syslog_log_function, rspamd->cfg);
+ msg_err ("cannot log to file, logfile unaccessable");
}
- break;
}
}
cfg_file = memory_pool_strdup (tmp_cfg->cfg_pool, rspamd->cfg->cfg_name);
f = fopen (rspamd->cfg->cfg_name, "r");
if (f == NULL) {
- msg_warn ("reread_config: cannot open file: %s", rspamd->cfg->cfg_name);
+ msg_warn ("cannot open file: %s", rspamd->cfg->cfg_name);
}
else {
yyin = f;
yyrestart (yyin);
if (yyparse () != 0 || yynerrs > 0) {
- msg_warn ("reread_config: yyparse: cannot parse config file, %d errors", yynerrs);
+ msg_warn ("yyparse: cannot parse config file, %d errors", yynerrs);
fclose (f);
}
else {
- msg_debug ("reread_config: replacing config");
+ msg_debug ("replacing config");
free_config (rspamd->cfg);
- close_log (rspamd->cfg);
+ close_log ();
g_free (rspamd->cfg);
rspamd->cfg = tmp_cfg;
rspamd->cfg->cfg_name = cfg_file;
config_logger (rspamd, FALSE);
- msg_info ("reread_config: config rereaded successfully");
+ open_log ();
+ msg_info ("config rereaded successfully");
}
}
}
rlmt.rlim_max = (rlim_t) cf->rlimit_nofile;
if (setrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
- msg_warn ("set_worker_limits: cannot set files rlimit: %d, %s", cf->rlimit_nofile, strerror (errno));
+ msg_warn ("cannot set files rlimit: %d, %s", cf->rlimit_nofile, strerror (errno));
}
}
rlmt.rlim_max = (rlim_t) cf->rlimit_maxcore;
if (setrlimit(RLIMIT_CORE, &rlmt) == -1) {
- msg_warn ("set_worker_limits: cannot set max core rlimit: %d, %s", cf->rlimit_maxcore, strerror (errno));
+ msg_warn ("cannot set max core rlimit: %d, %s", cf->rlimit_maxcore, strerror (errno));
}
}
cur->pending = FALSE;
switch (cur->pid) {
case 0:
+ /* Update pid for logging */
+ update_log_pid ();
/* Drop privilleges */
drop_priv (cfg);
/* Set limits */
case TYPE_CONTROLLER:
setproctitle ("controller process");
pidfile_close (rspamd->pfh);
- msg_info ("fork_worker: starting controller process %P", getpid ());
+ msg_info ("starting controller process %P", getpid ());
start_controller (cur);
break;
case TYPE_LMTP:
setproctitle ("lmtp process");
pidfile_close (rspamd->pfh);
- msg_info ("fork_worker: starting lmtp process %P", getpid ());
+ msg_info ("starting lmtp process %P", getpid ());
start_lmtp_worker (cur);
break;
case TYPE_FUZZY:
setproctitle ("fuzzy storage");
pidfile_close (rspamd->pfh);
- msg_info ("fork_worker: starting fuzzy storage process %P", getpid ());
+ msg_info ("starting fuzzy storage process %P", getpid ());
start_fuzzy_storage (cur);
break;
case TYPE_WORKER:
default:
setproctitle ("worker process");
pidfile_close (rspamd->pfh);
- msg_info ("fork_worker: starting worker process %P", getpid ());
+ msg_info ("starting worker process %P", getpid ());
start_worker (cur);
break;
}
break;
case -1:
- msg_err ("fork_worker: cannot fork main process. %s", strerror (errno));
+ msg_err ("cannot fork main process. %s", strerror (errno));
pidfile_remove (rspamd->pfh);
exit (-errno);
break;
/* Create listen socket */
if (family == AF_INET) {
if ((listen_sock = make_tcp_socket (addr, port, TRUE, TRUE)) == -1) {
- msg_err ("create_listen_socket: cannot create tcp listen socket. %s", strerror (errno));
+ msg_err ("cannot create tcp listen socket. %s", strerror (errno));
}
}
else {
un_addr = (struct sockaddr_un *)alloca (sizeof (struct sockaddr_un));
if (!un_addr || (listen_sock = make_unix_socket (path, un_addr, TRUE)) == -1) {
- msg_err ("create_listen_socket: cannot create unix listen socket. %s", strerror (errno));
+ msg_err ("cannot create unix listen socket. %s", strerror (errno));
}
}
if (listen_sock != -1) {
if (listen (listen_sock, -1) == -1) {
- msg_err ("start_lmtp: cannot listen on socket. %s", strerror (errno));
+ msg_err ("cannot listen on socket. %s", strerror (errno));
}
}
struct rspamd_worker *w = value;
kill (w->pid, SIGUSR2);
- msg_info ("rspamd_restart: send signal to worker %P", w->pid);
+ msg_info ("send signal to worker %P", w->pid);
}
static gboolean
waitpid (w->pid, &res, 0);
- msg_debug ("main(cleaning): %s process %P terminated", get_process_type (w->type), w->pid);
+ msg_debug ("%s process %P terminated", get_process_type (w->type), w->pid);
g_free (w);
return TRUE;
#endif
/* First set logger to console logger */
- cfg->log_fd = STDERR_FILENO;
- cfg->logf = stderr;
- rspamd_set_logger (file_log_function, rspamd->cfg);
- g_log_set_default_handler (file_log_function, cfg);
+ rspamd_set_logger (RSPAMD_LOG_CONSOLE, rspamd->cfg);
+ g_log_set_default_handler (rspamd_glib_log_function, cfg);
#ifndef HAVE_SETPROCTITLE
init_title (argc, argv, environ);
f = fopen (rspamd->cfg->cfg_name, "r");
if (f == NULL) {
- msg_err ("main: cannot open file: %s", rspamd->cfg->cfg_name);
+ msg_err ("cannot open file: %s", rspamd->cfg->cfg_name);
return EBADF;
}
yyin = f;
if (yyparse () != 0 || yynerrs > 0) {
- msg_err ("main: cannot parse config file, %d errors", yynerrs);
+ msg_err ("cannot parse config file, %d errors", yynerrs);
return EBADF;
}
config_logger (rspamd, TRUE);
- msg_info ("main: rspamd " RVERSION " is starting");
+ msg_info ("rspamd " RVERSION " is starting");
rspamd->cfg->cfg_name = memory_pool_strdup (rspamd->cfg->cfg_pool, rspamd->cfg->cfg_name);
/* Strictly set temp dir */
if (!rspamd->cfg->temp_dir) {
- msg_warn ("main: tempdir is not set, trying to use $TMPDIR");
+ msg_warn ("tempdir is not set, trying to use $TMPDIR");
rspamd->cfg->temp_dir = memory_pool_strdup (rspamd->cfg->cfg_pool, getenv ("TMPDIR"));
if (!rspamd->cfg->temp_dir) {
- msg_warn ("main: $TMPDIR is empty too, using /tmp as default");
+ msg_warn ("$TMPDIR is empty too, using /tmp as default");
rspamd->cfg->temp_dir = memory_pool_strdup (rspamd->cfg->cfg_pool, "/tmp");
}
}
init_signals (&signals, sig_handler);
if (write_pid (rspamd) == -1) {
- msg_err ("main: cannot write pid file %s", rspamd->cfg->pid_file);
+ msg_err ("cannot write pid file %s", rspamd->cfg->pid_file);
exit (-errno);
}
PERL_SYS_INIT3 (&argc, &argv, &env);
perl_interpreter = perl_alloc ();
if (perl_interpreter == NULL) {
- msg_err ("main: cannot allocate perl interpreter, %s", strerror (errno));
+ msg_err ("cannot allocate perl interpreter, %s", strerror (errno));
exit (-errno);
}
l = g_list_next (l);
}
+ flush_log_buf ();
+
rspamd->workers = g_hash_table_new (g_direct_hash, g_direct_equal);
spawn_workers (rspamd, TRUE);
/* Signal processing cycle */
for (;;) {
- msg_debug ("main: calling sigsuspend");
+ msg_debug ("calling sigsuspend");
sigemptyset (&signals.sa_mask);
sigsuspend (&signals.sa_mask);
#ifdef HAVE_SA_SIGINFO
print_signals_info ();
#endif
if (do_terminate) {
- msg_debug ("main: catch termination signal, waiting for childs");
+ msg_debug ("catch termination signal, waiting for childs");
pass_signal_worker (rspamd->workers, SIGTERM);
break;
}
if (child_dead) {
child_dead = 0;
- msg_debug ("main: catch SIGCHLD signal, finding terminated worker");
+ msg_debug ("catch SIGCHLD signal, finding terminated worker");
/* Remove dead child form childs list */
wrk = waitpid (0, &res, 0);
if ((cur = g_hash_table_lookup (rspamd->workers, GSIZE_TO_POINTER (wrk))) != NULL) {
if (WIFEXITED (res) && WEXITSTATUS (res) == 0) {
/* Normal worker termination, do not fork one more */
- msg_info ("main: %s process %P terminated normally", get_process_type (cur->type), cur->pid);
+ msg_info ("%s process %P terminated normally", get_process_type (cur->type), cur->pid);
}
else {
if (WIFSIGNALED (res)) {
- msg_warn ("main: %s process %P terminated abnormally by signal: %d", get_process_type (cur->type), cur->pid, WTERMSIG (res));
+ msg_warn ("%s process %P terminated abnormally by signal: %d", get_process_type (cur->type), cur->pid, WTERMSIG (res));
}
else {
- msg_warn ("main: %s process %P terminated abnormally", get_process_type (cur->type), cur->pid);
+ msg_warn ("%s process %P terminated abnormally", get_process_type (cur->type), cur->pid);
}
/* Fork another worker in replace of dead one */
delay_fork (cur->cf);
g_free (cur);
}
else {
- msg_err ("main: got SIGCHLD, but pid %P is not found in workers hash table, something goes wrong", wrk);
+ msg_err ("got SIGCHLD, but pid %P is not found in workers hash table, something goes wrong", wrk);
}
}
if (do_restart) {
do_restart = 0;
do_reopen_log = 1;
- msg_info ("main: rspamd " RVERSION " is restarting");
+ msg_info ("rspamd " RVERSION " is restarting");
g_hash_table_foreach (rspamd->workers, kill_old_workers, NULL);
spawn_workers (rspamd, FALSE);
/* Wait for workers termination */
g_hash_table_foreach_remove (rspamd->workers, wait_for_workers, NULL);
- msg_info ("main: terminating...");
+ msg_info ("terminating...");
+
+ close_log ();
free_config (rspamd->cfg);
g_free (rspamd->cfg);
#include "hash.h"
#include "events.h"
#include "util.h"
+#include "logger.h"
/* Default values */
#define FIXED_CONFIG_FILE ETC_PREFIX "/rspamd.conf"
/* 60 seconds for worker's IO */
#define WORKER_IO_TIMEOUT 60
-/* Logging in postfix style */
-#define msg_err(args...) rspamd_log_function(G_LOG_LEVEL_CRITICAL, ##args)
-#define msg_warn(args...) rspamd_log_function(G_LOG_LEVEL_WARNING, ##args)
-#define msg_info(args...) rspamd_log_function(G_LOG_LEVEL_INFO, ##args)
-#define msg_debug(args...) rspamd_log_function(G_LOG_LEVEL_DEBUG, ##args)
-
#ifdef CRLF
#undef CRLF
#undef CR
int sock;
if ((sock = make_tcp_socket (&data->addr, data->port, FALSE, is_async)) == -1) {
- msg_info ("connect_http: cannot connect to http server %s: %d, %s", data->host, errno, strerror (errno));
+ msg_info ("cannot connect to http server %s: %d, %s", data->host, errno, strerror (errno));
return -1;
}
r += snprintf (outbuf + r, sizeof (outbuf) - r, CRLF);
if (write (sock, outbuf, r) == -1) {
- msg_err ("write_http_request: failed to write request: %d, %s", errno, strerror (errno));
+ msg_err ("failed to write request: %d, %s", errno, strerror (errno));
}
}
/* Try to parse HTTP reply code */
reply->code = strtoul (++p, (char **)&err_str, 10);
if (*err_str != ' ') {
- msg_info ("parse_http_reply: error while reading HTTP status code: %s", p);
+ msg_info ("error while reading HTTP status code: %s", p);
return NULL;
}
/* Now skip to end of status string */
return TRUE;
}
else {
- msg_info ("read_http_chunked: invalid chunked reply: %*s", len, buf);
+ msg_info ("invalid chunked reply: %*s", len, buf);
return FALSE;
}
}
}
if (reply->parser_state == 6) {
if (reply->code != 200 && reply->code != 304) {
- msg_err ("read_http: got error reply from server %s, %d", data->host, reply->code);
+ msg_err ("got error reply from server %s, %d", data->host, reply->code);
return FALSE;
}
else if (reply->code == 304) {
struct http_reply *repl;
if (map->read_callback == NULL || map->fin_callback == NULL) {
- msg_err ("read_map_file: bad callback for reading map file");
+ msg_err ("bad callback for reading map file");
return;
}
int fd, rlen;
if (map->read_callback == NULL || map->fin_callback == NULL) {
- msg_err ("read_map_file: bad callback for reading map file");
+ msg_err ("bad callback for reading map file");
return;
}
if ((fd = open (data->filename, O_RDONLY)) == -1) {
- msg_warn ("read_map_file: cannot open file '%s': %s", data->filename, strerror (errno));
+ msg_warn ("cannot open file '%s': %s", data->filename, strerror (errno));
return;
}
def = map_line + sizeof ("file://") - 1;
}
else {
- msg_debug ("add_map: invalid map fetching protocol: %s", map_line);
+ msg_debug ("invalid map fetching protocol: %s", map_line);
return FALSE;
}
/* Constant pool */
/* Now check for each proto separately */
if (proto == PROTO_FILE) {
if ((fd = open (def, O_RDONLY)) == -1) {
- msg_warn ("add_map: cannot open file '%s': %s", def, strerror (errno));
+ msg_warn ("cannot open file '%s': %s", def, strerror (errno));
return FALSE;
}
fdata = memory_pool_alloc0 (map_pool, sizeof (struct file_map_data));
portbuf[i++] = *p++;
}
if (*p != '/') {
- msg_info ("add_map: bad http map definition: %s", def);
+ msg_info ("bad http map definition: %s", def);
return FALSE;
}
portbuf[i] = '\0';
hdata->port = 80;
/* Now separate host from path */
if ((p = strchr (def, '/')) == NULL) {
- msg_info ("add_map: bad http map definition: %s", def);
+ msg_info ("bad http map definition: %s", def);
return FALSE;
}
hostend = p;
/* Resolve using dns */
hent = gethostbyname (hdata->host);
if (hent == NULL) {
- msg_info ("add_map: cannot resolve: %s", hdata->host);
+ msg_info ("cannot resolve: %s", hdata->host);
return FALSE;
}
else {
}
/* Now try to connect */
if ((s = make_tcp_socket (&hdata->addr, hdata->port, FALSE, FALSE)) == -1) {
- msg_info ("add_map: cannot connect to http server %s: %d, %s", hdata->host, errno, strerror (errno));
+ msg_info ("cannot connect to http server %s: %d, %s", hdata->host, errno, strerror (errno));
return FALSE;
}
close (s);
errno = 0;
k = strtoul (ipnet, &err_str, 10);
if (errno != 0) {
- msg_warn ("radix_tree_insert_helper: invalid netmask, error detected on symbol: %s, erorr: %s", err_str, strerror (errno));
+ msg_warn ("invalid netmask, error detected on symbol: %s, erorr: %s", err_str, strerror (errno));
k = 32;
}
else if (k > 32 || k < 0) {
- msg_warn ("radix_tree_insert_helper: invalid netmask value: %d", k);
+ msg_warn ("invalid netmask value: %d", k);
k = 32;
}
- k = 32 - k;
- mask = mask << k;
+ mask = mask << (32 - k);
}
if (inet_aton (token, &ina) == 0) {
- msg_err ("radix_tree_insert_helper: invalid ip address: %s", token);
+ msg_err ("invalid ip address: %s", token);
return;
}
ip = ntohl ((uint32_t) ina.s_addr);
k = radix32tree_insert (tree, ip, mask, 1);
if (k == -1) {
- msg_warn ("radix_tree_insert_helper: cannot insert ip to tree: %s, mask %X", inet_ntoa (ina), mask);
+ msg_warn ("cannot insert ip to tree: %s, mask %X", inet_ntoa (ina), mask);
}
else if (k == 1) {
- msg_warn ("add_ip_radix: ip %s, mask %X, value already exists", inet_ntoa (ina), mask);
+ msg_warn ("ip %s, mask %X, value already exists", inet_ntoa (ina), mask);
}
cur++;
}
event_add (&cbd->ev, &cbd->tv);
}
else {
- msg_err ("http_async_callback: bad state when got write readiness");
+ msg_err ("bad state when got write readiness");
free_http_cbdata (cbd);
return;
}
/* Handle Not-Modified in a special way */
if (cbd->reply->code == 304) {
cbd->data->last_checked = time (NULL);
- msg_info ("http_async_callback: data is not modified for server %s", cbd->data->host);
+ msg_info ("data is not modified for server %s", cbd->data->host);
}
else if (cbd->cbdata.cur_data != NULL) {
cbd->map->fin_callback (cbd->map->pool, &cbd->cbdata);
}
if (cbd->state == 1 && cbd->reply->code == 200) {
/* Write to log that data is modified */
- msg_info ("http_async_callback: rereading map data from %s", cbd->data->host);
+ msg_info ("rereading map data from %s", cbd->data->host);
}
free_http_cbdata (cbd);
}
else if (cbd->state == 1) {
/* Write to log that data is modified */
- msg_info ("http_async_callback: rereading map data from %s", cbd->data->host);
+ msg_info ("rereading map data from %s", cbd->data->host);
}
cbd->state = 2;
}
}
else {
- msg_err ("http_async_callback: connection with http server terminated incorrectly");
+ msg_err ("connection with http server terminated incorrectly");
free_http_cbdata (cbd);
}
}
res_str = g_convert_with_fallback (part_content->data, part_content->len, "UTF-8", charset, NULL, &read_bytes, &write_bytes, &err);
if (res_str == NULL) {
- msg_warn ("convert_text_to_utf: cannot convert from %s to utf8: %s", charset, err ? err->message : "unknown problem");
+ msg_warn ("cannot convert from %s to utf8: %s", charset, err ? err->message : "unknown problem");
text_part->is_raw = TRUE;
return part_content;
}
struct mime_text_part *text_part;
if (g_mime_content_type_is_type (type, "text", "html") || g_mime_content_type_is_type (type, "text", "xhtml")) {
- msg_debug ("mime_foreach_callback: got urls from text/html part");
+ debug_task ("got urls from text/html part");
text_part = memory_pool_alloc0 (task->task_pool, sizeof (struct mime_text_part));
text_part->is_html = TRUE;
task->text_parts = g_list_prepend (task->text_parts, text_part);
}
else if (g_mime_content_type_is_type (type, "text", "plain")) {
- msg_debug ("mime_foreach_callback: got urls from text/plain part");
+ debug_task ("got urls from text/plain part");
text_part = memory_pool_alloc0 (task->task_pool, sizeof (struct mime_text_part));
text_part->is_html = FALSE;
#endif
}
else {
- msg_err ("mime_foreach_callback: endless recursion detected: %d", task->parser_recursion);
+ msg_err ("endless recursion detected: %d", task->parser_recursion);
return;
}
g_object_unref (message);
g_mime_multipart_foreach ((GMimeMultipart *) part, mime_foreach_callback, task);
}
else {
- msg_err ("mime_foreach_callback: endless recursion detected: %d", task->parser_recursion);
+ msg_err ("endless recursion detected: %d", task->parser_recursion);
return;
}
}
type = (GMimeContentType *) g_mime_part_get_content_type (GMIME_PART (part));
#endif
if (type == NULL) {
- msg_warn ("mime_foreach_callback: type of part is unknown, assume text/plain");
+ msg_warn ("type of part is unknown, assume text/plain");
type = g_mime_content_type_new ("text", "plain");
memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_mime_content_type_destroy, type);
}
mime_part = memory_pool_alloc (task->task_pool, sizeof (struct mime_part));
mime_part->type = type;
mime_part->content = part_content;
- msg_debug ("mime_foreach_callback: found part with content-type: %s/%s", type->type, type->subtype);
+ debug_task ("found part with content-type: %s/%s", type->type, type->subtype);
task->parts = g_list_prepend (task->parts, mime_part);
/* Skip empty parts */
process_text_part (task, part_content, type, (part_content->len <= 0));
}
else {
- msg_warn ("mime_foreach_callback: write to stream failed: %d, %s", errno, strerror (errno));
+ msg_warn ("write to stream failed: %d, %s", errno, strerror (errno));
}
g_object_unref (wrapper);
}
else {
- msg_warn ("mime_foreach_callback: cannot get wrapper for mime part, type of part: %s/%s", type->type, type->subtype);
+ msg_warn ("cannot get wrapper for mime part, type of part: %s/%s", type->type, type->subtype);
}
}
else {
{
GMimeMessage *msg = pointer;
- msg_debug ("destroy_message: freeing pointer %p", msg);
+ msg_debug ("freeing pointer %p", msg);
g_object_unref (msg);
}
if (task->is_mime) {
- msg_debug ("process_message: construct mime parser from string length %ld", (long int)task->msg->len);
+ debug_task ("construct mime parser from string length %ld", (long int)task->msg->len);
/* create a new parser object to parse the stream */
parser = g_mime_parser_new_with_stream (stream);
g_object_unref (stream);
message = g_mime_parser_construct_message (parser);
if (message == NULL) {
- msg_warn ("process_message: cannot construct mime from stream");
+ msg_warn ("cannot construct mime from stream");
return -1;
}
g_mime_message_foreach_part (message, mime_foreach_callback, task);
#endif
- msg_debug ("process_message: found %d parts in message", task->parts_count);
+ debug_task ("found %d parts in message", task->parts_count);
if (task->queue_id == NULL) {
task->queue_id = (char *)g_mime_message_get_message_id (task->message);
}
g_mime_multipart_foreach (GMIME_MULTIPART (part), multipart_iterate, data);
}
else {
- msg_info ("multipart_iterate: maximum recurse limit is over, stop recursing, %d", data->rec);
+ msg_info ("maximum recurse limit is over, stop recursing, %d", data->rec);
data->try_search = FALSE;
}
}
SPAGAIN;
result = POPi;
- msg_debug ("header_filter: call of %s with returned mark %d\n", function, result);
+ debug_task ("call of %s with returned mark %d\n", function, result);
PUTBACK;
FREETMPS;
SPAGAIN;
result = POPi;
- msg_debug ("chain_filter: call of %s returned mark %d\n", function, result);
+ debug_task ("call of %s returned mark %d\n", function, result);
PUTBACK;
FREETMPS;
errno = 0;
chartable_module_ctx->threshold = strtod (value, NULL);
if (errno != 0) {
- msg_warn ("chartable_module_config: invalid numeric value '%s': %s", value, strerror (errno));
+ msg_warn ("invalid numeric value '%s': %s", value, strerror (errno));
chartable_module_ctx->threshold = DEFAULT_THRESHOLD;
}
}
metric = g_hash_table_lookup (cfg->metrics, chartable_module_ctx->metric);
if (metric == NULL) {
- msg_err ("chartable_module_config: cannot find metric definition %s", chartable_module_ctx->metric);
+ msg_err ("cannot find metric definition %s", chartable_module_ctx->metric);
return FALSE;
}
metric = g_hash_table_lookup (cfg->metrics, email_module_ctx->metric);
if (metric == NULL) {
- msg_err ("emails_module_config: cannot find metric definition %s", email_module_ctx->metric);
+ msg_err ("cannot find metric definition %s", email_module_ctx->metric);
return FALSE;
}
}
}
else if (err != NULL) {
- msg_debug ("extract_emails: error matching regexp: %s", err->message);
+ debug_task ("error matching regexp: %s", err->message);
}
else {
- msg_debug ("extract_emails: cannot find url pattern in given string");
+ debug_task ("cannot find url pattern in given string");
}
g_match_info_free (info);
outbuf[r++] = '\n';
rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE);
- msg_info ("process_message: msg ok, id: <%s>, %d emails extracted", task->message_id, num);
+ msg_info ("msg ok, id: <%s>, %d emails extracted", task->message_id, num);
return 0;
}
/* Resolve using dns */
hent = gethostbyname (name);
if (hent == NULL) {
- msg_info ("parse_servers_string: cannot resolve: %s", name);
+ msg_info ("cannot resolve: %s", name);
continue;
}
else {
metric = g_hash_table_lookup (cfg->metrics, fuzzy_module_ctx->metric);
if (metric == NULL) {
- msg_err ("fuzzy_module_config: cannot find metric definition %s", fuzzy_module_ctx->metric);
+ msg_err ("cannot find metric definition %s", fuzzy_module_ctx->metric);
return FALSE;
}
return;
err:
- msg_err ("fuzzy_io_callback: got error on IO with server %s:%d, %d, %s", session->server->name, session->server->port, errno, strerror (errno));
+ msg_err ("got error on IO with server %s:%d, %d, %s", session->server->name, session->server->port, errno, strerror (errno));
ok:
close (fd);
remove_normal_event (session->task->s, fuzzy_io_fin, session);
return;
err:
- msg_err ("fuzzy_learn_callback: got error in IO with server %s:%d, %d, %s", session->server->name, session->server->port, errno, strerror (errno));
+ msg_err ("got error in IO with server %s:%d, %d, %s", session->server->name, session->server->port, errno, strerror (errno));
ok:
close (fd);
remove_normal_event (session->session->s, fuzzy_learn_fin, session);
DEFAULT_UPSTREAM_ERROR_TIME, DEFAULT_UPSTREAM_DEAD_TIME, DEFAULT_UPSTREAM_MAXERRORS, part->fuzzy->hash_pipe, sizeof (part->fuzzy->hash_pipe));
if (selected) {
if ((sock = make_udp_socket (&selected->addr, selected->port, FALSE, TRUE)) == -1) {
- msg_warn ("fuzzy_symbol_callback: cannot connect to %s, %d, %s", selected->name, errno, strerror (errno));
+ msg_warn ("cannot connect to %s, %d, %s", selected->name, errno, strerror (errno));
}
else {
session = memory_pool_alloc (task->task_pool, sizeof (struct fuzzy_client_session));
saved = memory_pool_alloc0 (session->session_pool, sizeof (int));
r = process_message (task);
if (r == -1) {
- msg_warn ("read_socket: processing of message failed");
+ msg_warn ("processing of message failed");
free_task (task, FALSE);
session->state = STATE_REPLY;
r = snprintf (out_buf, sizeof (out_buf), "cannot process message" CRLF);
DEFAULT_UPSTREAM_ERROR_TIME, DEFAULT_UPSTREAM_DEAD_TIME, DEFAULT_UPSTREAM_MAXERRORS, part->fuzzy->hash_pipe, sizeof (part->fuzzy->hash_pipe));
if (selected) {
if ((sock = make_udp_socket (&selected->addr, selected->port, FALSE, TRUE)) == -1) {
- msg_warn ("fuzzy_symbol_callback: cannot connect to %s, %d, %s", selected->name, errno, strerror (errno));
+ msg_warn ("cannot connect to %s, %d, %s", selected->name, errno, strerror (errno));
session->state = STATE_REPLY;
r = snprintf (out_buf, sizeof (out_buf), "no hashes written" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE);
arg = *args;
if (!arg || *arg == '\0') {
- msg_info ("fuzzy_controller_handler: empty content length");
+ msg_info ("empty content length");
r = snprintf (out_buf, sizeof (out_buf), "fuzzy command requires length as argument" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE);
session->state = STATE_REPLY;
e = parse_expression (regexp_module_ctx->regexp_pool, line);
if (e == NULL) {
- msg_warn ("read_regexp_expression: %s = \"%s\" is invalid regexp expression", symbol, line);
+ msg_warn ("%s = \"%s\" is invalid regexp expression", symbol, line);
return FALSE;
}
chain->expr = e;
if (cur->type == EXPR_REGEXP) {
cur->content.operand = parse_regexp (pool, cur->content.operand, cfg->raw_mode);
if (cur->content.operand == NULL) {
- msg_warn ("read_regexp_expression: cannot parse regexp, skip expression %s = \"%s\"", symbol, line);
+ msg_warn ("cannot parse regexp, skip expression %s = \"%s\"", symbol, line);
return FALSE;
}
cur->type = EXPR_REGEXP_PARSED;
}
}
else {
- msg_warn ("parse_autolearn_param: cannot extract statfile name from %s", p);
+ msg_warn ("cannot extract statfile name from %s", p);
}
}
else {
- msg_warn ("parse_autolearn_param: cannot extract symbol name from %s", p);
+ msg_warn ("cannot extract symbol name from %s", p);
}
}
metric = g_hash_table_lookup (cfg->metrics, regexp_module_ctx->metric);
if (metric == NULL) {
- msg_err ("regexp_module_config: cannot find metric definition %s", regexp_module_ctx->metric);
+ msg_err ("cannot find metric definition %s", regexp_module_ctx->metric);
return FALSE;
}
if (re == NULL) {
- msg_info ("process_regexp: invalid regexp passed");
+ msg_info ("invalid regexp passed");
return 0;
}
if ((r = task_cache_check (task, re)) != -1) {
- msg_debug ("process_regexp: regexp /%s/ is found in cache, result: %d", re->regexp_text, r);
+ debug_task ("regexp /%s/ is found in cache, result: %d", re->regexp_text, r);
return r == 1;
}
switch (re->type) {
case REGEXP_NONE:
- msg_warn ("process_regexp: bad error detected: /%s/ has invalid regexp type", re->regexp_text);
+ msg_warn ("bad error detected: /%s/ has invalid regexp type", re->regexp_text);
return 0;
case REGEXP_HEADER:
if (re->header == NULL) {
- msg_info ("process_regexp: header regexp without header name: '%s'", re->regexp_text);
+ msg_info ("header regexp without header name: '%s'", re->regexp_text);
task_cache_add (task, re, 0);
return 0;
}
- msg_debug ("process_regexp: checking header regexp: %s = /%s/", re->header, re->regexp_text);
+ debug_task ("checking header regexp: %s = /%s/", re->header, re->regexp_text);
headerlist = message_get_header (task->task_pool, task->message, re->header);
if (headerlist == NULL) {
task_cache_add (task, re, 0);
else {
memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_list_free, headerlist);
if (re->regexp == NULL) {
- msg_debug ("process_regexp: regexp contains only header and it is found %s", re->header);
+ debug_task ("regexp contains only header and it is found %s", re->header);
task_cache_add (task, re, 1);
return 1;
}
cur = headerlist;
while (cur) {
- msg_debug ("process_regexp: found header \"%s\" with value \"%s\"", re->header, (char *)cur->data);
+ debug_task ("found header \"%s\" with value \"%s\"", re->header, (char *)cur->data);
if (cur->data && g_regex_match (re->regexp, cur->data, 0, NULL) == TRUE) {
task_cache_add (task, re, 1);
return 1;
}
break;
case REGEXP_MIME:
- msg_debug ("process_regexp: checking mime regexp: /%s/", re->regexp_text);
+ debug_task ("checking mime regexp: /%s/", re->regexp_text);
cur = g_list_first (task->text_parts);
while (cur) {
part = (struct mime_text_part *)cur->data;
task_cache_add (task, re, 0);
return 0;
case REGEXP_MESSAGE:
- msg_debug ("process_regexp: checking message regexp: /%s/", re->regexp_text);
+ debug_task ("checking message regexp: /%s/", re->regexp_text);
if (g_regex_match_full (re->raw_regexp, task->msg->begin, task->msg->len, 0, 0, NULL, NULL) == TRUE) {
task_cache_add (task, re, 1);
return 1;
task_cache_add (task, re, 0);
return 0;
case REGEXP_URL:
- msg_debug ("process_regexp: checking url regexp: /%s/", re->regexp_text);
+ debug_task ("checking url regexp: /%s/", re->regexp_text);
cur = g_list_first (task->text_parts);
while (cur) {
part = (struct mime_text_part *)cur->data;
}
return 0;
case REGEXP_RAW_HEADER:
- msg_debug ("process_regexp: checking for raw header: %s with regexp: /%s/", re->header, re->regexp_text);
+ debug_task ("checking for raw header: %s with regexp: /%s/", re->header, re->regexp_text);
if (task->raw_headers == NULL) {
- msg_debug ("process_regexp: cannot check for raw header in message, no headers found");
+ debug_task ("cannot check for raw header in message, no headers found");
task_cache_add (task, re, 0);
return 0;
}
/* Temporary null terminate this part of string */
t = *c;
*c = '\0';
- msg_debug ("process_regexp: found raw header \"%s\" with value \"%s\"", re->header, headerv);
+ debug_task ("found raw header \"%s\" with value \"%s\"", re->header, headerv);
if (g_regex_match (re->raw_regexp, headerv, 0, NULL) == TRUE) {
*c = t;
task_cache_add (task, re, 1);
task_cache_add (task, re, 0);
return 0;
default:
- msg_warn ("process_regexp: bad error detected: %p is not a valid regexp object", re);
+ msg_warn ("bad error detected: %p is not a valid regexp object", re);
}
/* Not reached */
/* If this operation is just ! just inverse res and check for further operators */
if (it->content.operation == '!') {
if (is_nearest) {
- msg_debug ("optimize_regexp_expression: found '!' operator, inversing result");
+ msg_debug ("found '!' operator, inversing result");
res = !res;
*e = it;
}
/* Check whether we found corresponding operator for this operand */
if (skip_level <= 0) {
if (it->content.operation == '|' && res == TRUE) {
- msg_debug ("optimize_regexp_expression: found '|' and previous expression is true");
+ msg_debug ("found '|' and previous expression is true");
*e = it;
ret = TRUE;
}
else if (it->content.operation == '&' && res == FALSE) {
- msg_debug ("optimize_regexp_expression: found '&' and previous expression is false");
+ msg_debug ("found '&' and previous expression is false");
*e = it;
ret = TRUE;
}
if (it->type == EXPR_REGEXP_PARSED) {
/* Find corresponding symbol */
cur = process_regexp ((struct rspamd_regexp *)it->content.operand, task, additional);
- msg_debug ("process_regexp_expression: regexp %s found", cur ? "is" : "is not");
+ debug_task ("regexp %s found", cur ? "is" : "is not");
if (try_optimize) {
try_optimize = optimize_regexp_expression (&it, stack, cur);
}
}
else if (it->type == EXPR_FUNCTION) {
cur = (gsize) call_expression_function ((struct expression_function *)it->content.operand, task);
- msg_debug ("process_regexp_expression: function %s returned %s", ((struct expression_function *)it->content.operand)->name, cur ? "true" : "false");
+ debug_task ("function %s returned %s", ((struct expression_function *)it->content.operand)->name, cur ? "true" : "false");
if (try_optimize) {
try_optimize = optimize_regexp_expression (&it, stack, cur);
}
}
re = parse_regexp (task->cfg->cfg_pool, it->content.operand, task->cfg->raw_mode);
if (re == NULL) {
- msg_warn ("process_regexp_expression: cannot parse regexp, skip expression");
+ msg_warn ("cannot parse regexp, skip expression");
g_queue_free (stack);
return FALSE;
}
else if (it->type == EXPR_OPERATION) {
if (g_queue_is_empty (stack)) {
/* Queue has no operands for operation, exiting */
- msg_warn ("process_regexp_expression: regexp expression seems to be invalid: empty stack while reading operation");
+ msg_warn ("regexp expression seems to be invalid: empty stack while reading operation");
g_queue_free (stack);
return FALSE;
}
- msg_debug ("process_regexp_expression: got operation %c", it->content.operation);
+ debug_task ("got operation %c", it->content.operation);
switch (it->content.operation) {
case '!':
op1 = GPOINTER_TO_SIZE (g_queue_pop_head (stack));
}
}
else {
- msg_warn ("process_regexp_expression: regexp expression seems to be invalid: empty stack at the end of expression, symbol %s", symbol);
+ msg_warn ("regexp expression seems to be invalid: empty stack at the end of expression, symbol %s", symbol);
}
g_queue_free (stack);
GList *cur;
if (args == NULL) {
- msg_warn ("rspamd_regexp_match_number: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
arg = get_function_arg (args->data, task, TRUE);
if (!arg || arg->type == EXPRESSION_ARGUMENT_BOOL) {
- msg_warn ("rspamd_raw_header_exists: invalid argument to function is passed");
+ msg_warn ("invalid argument to function is passed");
return FALSE;
}
if (find_raw_header_pos (task->raw_headers, (char *)arg->data) == NULL) {
char *type, *what = NULL;
if (args == NULL) {
- msg_warn ("rspamd_check_smtp_data: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
arg = get_function_arg (args->data, task, TRUE);
if (!arg || !arg->data) {
- msg_warn ("rspamd_check_smtp_data: no parameters to function");
+ msg_warn ("no parameters to function");
return FALSE;
}
else {
what = task->from;
}
else {
- msg_warn ("rspamd_check_smtp_data: bad argument to function: %s", type);
+ msg_warn ("bad argument to function: %s", type);
return FALSE;
}
break;
what = task->helo;
}
else {
- msg_warn ("rspamd_check_smtp_data: bad argument to function: %s", type);
+ msg_warn ("bad argument to function: %s", type);
return FALSE;
}
break;
what = task->user;
}
else {
- msg_warn ("rspamd_check_smtp_data: bad argument to function: %s", type);
+ msg_warn ("bad argument to function: %s", type);
return FALSE;
}
break;
what = task->subject;
}
else {
- msg_warn ("rspamd_check_smtp_data: bad argument to function: %s", type);
+ msg_warn ("bad argument to function: %s", type);
return FALSE;
}
break;
rcpt_list = task->rcpt;
}
else {
- msg_warn ("rspamd_check_smtp_data: bad argument to function: %s", type);
+ msg_warn ("bad argument to function: %s", type);
return FALSE;
}
break;
default:
- msg_warn ("rspamd_check_smtp_data: bad argument to function: %s", type);
+ msg_warn ("bad argument to function: %s", type);
return FALSE;
}
}
metric = g_hash_table_lookup (cfg->metrics, spf_module_ctx->metric);
if (metric == NULL) {
- msg_err ("spf_module_config: cannot find metric definition %s", spf_module_ctx->metric);
+ msg_err ("cannot find metric definition %s", spf_module_ctx->metric);
return FALSE;
}
{
if (task->from_addr.s_addr != INADDR_NONE && task->from_addr.s_addr != INADDR_ANY) {
if (!resolve_spf (task, spf_plugin_callback)) {
- msg_info ("spf_symbol_callback: cannot make spf request for [%s]", task->message_id);
+ msg_info ("cannot make spf request for [%s]", task->message_id);
}
}
}
metric = g_hash_table_lookup (cfg->metrics, surbl_module_ctx->metric);
if (metric == NULL) {
- msg_err ("surbl_module_config: cannot find metric definition %s", surbl_module_ctx->metric);
+ msg_err ("cannot find metric definition %s", surbl_module_ctx->metric);
return FALSE;
}
*str = '\0';
new_suffix->symbol = memory_pool_strdup (surbl_module_ctx->surbl_pool, str + 1);
new_suffix->suffix = memory_pool_strdup (surbl_module_ctx->surbl_pool, cur->value);
- msg_debug ("surbl_module_config: add new surbl suffix: %s with symbol: %s", new_suffix->suffix, new_suffix->symbol);
+ msg_debug ("add new surbl suffix: %s with symbol: %s", new_suffix->suffix, new_suffix->symbol);
*str = '_';
surbl_module_ctx->suffixes = g_list_prepend (surbl_module_ctx->suffixes, new_suffix);
/* Search in factors hash table */
new_bit = memory_pool_alloc (surbl_module_ctx->surbl_pool, sizeof (struct surbl_bit_item));
new_bit->bit = bit;
new_bit->symbol = memory_pool_strdup (surbl_module_ctx->surbl_pool, cur->value);
- msg_debug ("surbl_module_config: add new bit suffix: %d with symbol: %s", (int)new_bit->bit, new_bit->symbol);
+ msg_debug ("add new bit suffix: %d with symbol: %s", (int)new_bit->bit, new_bit->symbol);
surbl_module_ctx->bits = g_list_prepend (surbl_module_ctx->bits, new_bit);
}
}
new_suffix = memory_pool_alloc (surbl_module_ctx->surbl_pool, sizeof (struct suffix_item));
new_suffix->suffix = memory_pool_strdup (surbl_module_ctx->surbl_pool, DEFAULT_SURBL_SUFFIX);
new_suffix->symbol = memory_pool_strdup (surbl_module_ctx->surbl_pool, DEFAULT_SURBL_SYMBOL);
- msg_debug ("surbl_module_config: add default surbl suffix: %s with symbol: %s", new_suffix->suffix, new_suffix->symbol);
+ msg_debug ("add default surbl suffix: %s with symbol: %s", new_suffix->suffix, new_suffix->symbol);
surbl_module_ctx->suffixes = g_list_prepend (surbl_module_ctx->suffixes, new_suffix);
w = g_hash_table_lookup (cfg->factors, new_suffix->symbol);
if (w == NULL) {
octet3 = g_match_info_fetch (info, 3);
octet4 = g_match_info_fetch (info, 4);
result = memory_pool_alloc (pool, len);
- msg_debug ("format_surbl_request: got numeric host for check: %s.%s.%s.%s", octet1, octet2, octet3, octet4);
+ msg_debug ("got numeric host for check: %s.%s.%s.%s", octet1, octet2, octet3, octet4);
r = snprintf (result, len, "%s.%s.%s.%s", octet4, octet3, octet2, octet1);
if (g_hash_table_lookup (surbl_module_ctx->whitelist, result) != NULL) {
g_free (octet1);
g_free (octet3);
g_free (octet4);
g_match_info_free (info);
- msg_debug ("format_surbl_request: url %s is whitelisted", result);
+ msg_debug ("url %s is whitelisted", result);
g_set_error (err, SURBL_ERROR, /* error domain */
WHITELIST_ERROR, /* error code */
"URL is whitelisted: %s", /* error message format string */
ip_num = strtoull (ip, NULL, 10);
if (errno != 0) {
g_match_info_free (info);
- msg_info ("format_surbl_request: cannot convert ip to number '%s': %s", ip, strerror (errno));
+ msg_info ("cannot convert ip to number '%s': %s", ip, strerror (errno));
g_set_error (err, SURBL_ERROR, /* error domain */
CONVERSION_ERROR, /* error code */
"URL cannot be decoded");
hpart1 = g_match_info_fetch (info, 1);
hpart2 = g_match_info_fetch (info, 2);
hpart3 = g_match_info_fetch (info, 3);
- msg_debug ("format_surbl_request: got hoster 3-d level domain %s.%s.%s", hpart1, hpart2, hpart3);
+ msg_debug ("got hoster 3-d level domain %s.%s.%s", hpart1, hpart2, hpart3);
r = snprintf (result, len, "%s.%s.%s", hpart1, hpart2, hpart3);
if (g_hash_table_lookup (surbl_module_ctx->whitelist, result) != NULL) {
g_free (hpart1);
g_free (hpart2);
g_free (hpart3);
g_match_info_free (info);
- msg_debug ("format_surbl_request: url %s is whitelisted", result);
+ msg_debug ("url %s is whitelisted", result);
g_set_error (err, SURBL_ERROR, /* error domain */
WHITELIST_ERROR, /* error code */
"URL is whitelisted: %s", /* error message format string */
if (g_hash_table_lookup (surbl_module_ctx->whitelist, result) != NULL) {
g_free (part1);
g_free (part2);
- msg_debug ("format_surbl_request: url %s is whitelisted", result);
+ msg_debug ("url %s is whitelisted", result);
g_set_error (err, SURBL_ERROR, /* error domain */
WHITELIST_ERROR, /* error code */
"URL is whitelisted: %s", /* error message format string */
r += snprintf (result + r, len - r, ".%s", suffix->suffix);
}
*host_end = result + r - slen - 1;
- msg_debug ("format_surbl_request: got normal 2-d level domain %s.%s", part1, part2);
+ msg_debug ("got normal 2-d level domain %s.%s", part1, part2);
}
g_free (part1);
g_free (part2);
*host_end = '\0';
param->host_resolve = memory_pool_strdup (task->task_pool, surbl_req);
*host_end = '.';
- msg_debug ("surbl_test_url: send surbl dns request %s", surbl_req);
+ debug_task ("send surbl dns request %s", surbl_req);
if (evdns_resolve_ipv4 (surbl_req, DNS_QUERY_NO_SEARCH, dns_callback, (void *)param) == 0) {
param->task->save.saved++;
register_async_event (task->s, (event_finalizer_t) dns_callback, NULL, TRUE);
}
}
else {
- msg_debug ("make_surbl_requests: request %s is already sent", surbl_req);
+ debug_task ("request %s is already sent", surbl_req);
}
}
else if (err != NULL && err->code != WHITELIST_ERROR) {
- msg_info ("surbl_test_url: cannot format url string for surbl %s, %s", struri (url), err->message);
+ msg_info ("cannot format url string for surbl %s, %s", struri (url), err->message);
g_error_free (err);
return;
}
}
}
else {
- msg_debug ("make_surbl_requests: skipping symbol that is not in view: %s", suffix->symbol);
+ debug_task ("skipping symbol that is not in view: %s", suffix->symbol);
}
}
while (cur) {
bit = (struct surbl_bit_item *)cur->data;
- msg_debug ("process_dns_results: got result(%d) AND bit(%d): %d", (int)addr, (int)ntohl (bit->bit), (int)bit->bit & (int)ntohl (addr));
+ debug_task ("got result(%d) AND bit(%d): %d", (int)addr, (int)ntohl (bit->bit), (int)bit->bit & (int)ntohl (addr));
if (((int)bit->bit & (int)ntohl (addr)) != 0) {
len = strlen (suffix->symbol) - 2 + strlen (bit->symbol) + 1;
*c = '\0';
dns_callback (int result, char type, int count, int ttl, void *addresses, void *data)
{
struct dns_param *param = (struct dns_param *)data;
+ struct worker_task *task = param->task;
- msg_debug ("dns_callback: in surbl request callback");
+ debug_task ("in surbl request callback");
/* If we have result from DNS server, this url exists in SURBL, so increase score */
if (result == DNS_ERR_NONE && type == DNS_IPv4_A) {
- msg_info ("surbl_check: <%s> domain [%s] is in surbl %s", param->task->message_id, param->host_resolve, param->suffix->suffix);
+ msg_info ("<%s> domain [%s] is in surbl %s", param->task->message_id, param->host_resolve, param->suffix->suffix);
process_dns_results (param->task, param->suffix, param->host_resolve, (uint32_t) (((in_addr_t *) addresses)[0]));
}
else {
- msg_debug ("surbl_check: <%s> domain [%s] is not in surbl %s", param->task->message_id, param->host_resolve, param->suffix->suffix);
+ debug_task ("<%s> domain [%s] is not in surbl %s", param->task->message_id, param->host_resolve, param->suffix->suffix);
}
param->task->save.saved--;
switch (ctx->op) {
case CMD_CONNECT:
if (error != OK) {
- msg_info ("memcached_callback: memcached returned error %s on CONNECT stage", memc_strerror (error));
+ msg_info ("memcached returned error %s on CONNECT stage", memc_strerror (error));
memc_close_ctx (param->ctx);
param->task->save.saved--;
if (param->task->save.saved == 0) {
break;
case CMD_READ:
if (error != OK) {
- msg_info ("memcached_callback: memcached returned error %s on READ stage", memc_strerror (error));
+ msg_info ("memcached returned error %s on READ stage", memc_strerror (error));
memc_close_ctx (param->ctx);
param->task->save.saved--;
if (param->task->save.saved == 0) {
url_count = (int *)param->ctx->param->buf;
/* Do not check DNS for urls that have count more than max_urls */
if (*url_count > surbl_module_ctx->max_urls) {
- msg_info ("memcached_callback: url '%s' has count %d, max: %d", struri (param->url), *url_count, surbl_module_ctx->max_urls);
+ msg_info ("url '%s' has count %d, max: %d", struri (param->url), *url_count, surbl_module_ctx->max_urls);
/*
* XXX: try to understand why we should use memcached here
* insert_result (param->task, surbl_module_ctx->metric, surbl_module_ctx->symbol, 1);
break;
case CMD_WRITE:
if (error != OK) {
- msg_info ("memcached_callback: memcached returned error %s on WRITE stage", memc_strerror (error));
+ msg_info ("memcached returned error %s on WRITE stage", memc_strerror (error));
}
memc_close_ctx (param->ctx);
param->task->save.saved--;
task->cfg->memcached_servers_num, sizeof (struct memcached_server),
time (NULL), task->cfg->memcached_error_time, task->cfg->memcached_dead_time, task->cfg->memcached_maxerrors, cur_param->key, strlen (cur_param->key));
if (selected == NULL) {
- msg_err ("surbl_register_memcached_call: no memcached servers can be selected");
+ msg_err ("no memcached servers can be selected");
return;
}
param->ctx->callback = memcached_callback;
redirector_callback (int fd, short what, void *arg)
{
struct redirector_param *param = (struct redirector_param *)arg;
+ struct worker_task *task = param->task;
char url_buf[1024];
int r;
struct timeval *timeout;
event_add (¶m->ev, timeout);
r = snprintf (url_buf, sizeof (url_buf), "GET %s HTTP/1.0\r\n\r\n", struri (param->url));
if (write (param->sock, url_buf, r) == -1) {
- msg_err ("redirector_callback: write failed %s", strerror (errno));
+ msg_err ("write failed %s", strerror (errno));
remove_normal_event (param->task->s, free_redirector_session, param);
return;
}
param->state = STATE_READ;
}
else {
- msg_info ("redirector_callback: <%s> connection to redirector timed out while waiting for write", param->task->message_id);
+ msg_info ("<%s> connection to redirector timed out while waiting for write", param->task->message_id);
remove_normal_event (param->task->s, free_redirector_session, param);
return;
}
}
}
if (*p == '\0') {
- msg_debug ("redirector_callback: <%s> got reply from redirector: '%s' -> '%s'", param->task->message_id, struri (param->url), c);
+ debug_task ("<%s> got reply from redirector: '%s' -> '%s'", param->task->message_id, struri (param->url), c);
parse_uri (param->url, memory_pool_strdup (param->task->task_pool, c), param->task->task_pool);
}
}
remove_normal_event (param->task->s, free_redirector_session, param);
}
else {
- msg_info ("redirector_callback: <%s> reading redirector timed out, while waiting for read", param->task->message_id);
+ msg_info ("<%s> reading redirector timed out, while waiting for read", param->task->message_id);
remove_normal_event (param->task->s, free_redirector_session, param);
}
break;
s = make_tcp_socket (&surbl_module_ctx->redirector_addr, surbl_module_ctx->redirector_port, FALSE, TRUE);
if (s == -1) {
- msg_info ("register_redirector_call: <%s> cannot create tcp socket failed: %s", task->message_id, strerror (errno));
+ msg_info ("<%s> cannot create tcp socket failed: %s", task->message_id, strerror (errno));
task->save.saved--;
make_surbl_requests (url, task, url_tree, suffix);
return;
tree_url_callback (gpointer key, gpointer value, void *data)
{
struct redirector_param *param = data;
+ struct worker_task *task = param->task;
struct uri *url = value;
f_str_t f;
char *urlstr, *host_end;
GError *err = NULL;
- msg_debug ("surbl_test_url: check url %s", struri (url));
+ debug_task ("check url %s", struri (url));
if (surbl_module_ctx->use_redirector) {
outbuf[r++] = '\n';
rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, TRUE);
- msg_info ("process_message: msg ok, id: <%s>, %d urls extracted", task->message_id, num);
+ msg_info ("msg ok, id: <%s>, %d urls extracted", task->message_id, num);
g_tree_destroy (url_tree);
return 0;
token = separate_command (line, ' ');
if (line == NULL || token == NULL) {
- msg_debug ("parse_command: bad command: %s", token);
+ debug_task ("bad command: %s", token);
return -1;
}
task->cmd = CMD_CHECK;
}
else {
- msg_debug ("parse_command: bad command: %s", token);
+ debug_task ("bad command: %s", token);
return -1;
}
break;
task->cmd = CMD_SKIP;
}
else {
- msg_debug ("parse_command: bad command: %s", token);
+ debug_task ("bad command: %s", token);
return -1;
}
break;
task->cmd = CMD_PROCESS;
}
else {
- msg_debug ("parse_command: bad command: %s", token);
+ debug_task ("bad command: %s", token);
return -1;
}
break;
task->cmd = CMD_REPORT_IFSPAM;
}
else {
- msg_debug ("parse_command: bad command: %s", token);
+ debug_task ("bad command: %s", token);
return -1;
}
break;
}
if (cur == NULL) {
- msg_debug ("parse_command: bad command: %s", token);
+ debug_task ("bad command: %s", token);
return -1;
}
break;
/* Check end of headers */
if (line->len == 0) {
- msg_debug ("parse_header: got empty line, assume it as end of headers");
+ debug_task ("got empty line, assume it as end of headers");
if (task->cmd == CMD_PING || task->cmd == CMD_SKIP) {
task->state = WRITE_REPLY;
}
if (task->content_length == 0) {
tmp = memory_pool_fstrdup (task->task_pool, line);
task->content_length = strtoul (tmp, &err, 10);
- msg_debug ("parse_header: read Content-Length header, value: %lu", (unsigned long int)task->content_length);
+ debug_task ("read Content-Length header, value: %lu", (unsigned long int)task->content_length);
}
}
else {
- msg_info ("parse_header: wrong header: %s", headern);
+ msg_info ("wrong header: %s", headern);
return -1;
}
break;
/* Deliver-To */
if (strncasecmp (headern, DELIVER_TO_HEADER, sizeof (DELIVER_TO_HEADER) - 1) == 0) {
task->deliver_to = memory_pool_fstrdup (task->task_pool, line);
- msg_debug ("parse_header: read deliver-to header, value: %s", task->deliver_to);
+ debug_task ("read deliver-to header, value: %s", task->deliver_to);
}
else {
- msg_info ("parse_header: wrong header: %s", headern);
+ msg_info ("wrong header: %s", headern);
return -1;
}
break;
/* helo */
if (strncasecmp (headern, HELO_HEADER, sizeof (HELO_HEADER) - 1) == 0) {
task->helo = memory_pool_fstrdup (task->task_pool, line);
- msg_debug ("parse_header: read helo header, value: %s", task->helo);
+ debug_task ("read helo header, value: %s", task->helo);
}
else {
- msg_info ("parse_header: wrong header: %s", headern);
+ msg_info ("wrong header: %s", headern);
return -1;
}
break;
/* from */
if (strncasecmp (headern, FROM_HEADER, sizeof (FROM_HEADER) - 1) == 0) {
task->from = memory_pool_fstrdup (task->task_pool, line);
- msg_debug ("parse_header: read from header, value: %s", task->from);
+ debug_task ("read from header, value: %s", task->from);
}
else {
- msg_info ("parse_header: wrong header: %s", headern);
+ msg_info ("wrong header: %s", headern);
return -1;
}
break;
/* Queue id */
if (strncasecmp (headern, QUEUE_ID_HEADER, sizeof (QUEUE_ID_HEADER) - 1) == 0) {
task->queue_id = memory_pool_fstrdup (task->task_pool, line);
- msg_debug ("parse_header: read queue_id header, value: %s", task->queue_id);
+ debug_task ("read queue_id header, value: %s", task->queue_id);
}
else {
- msg_info ("parse_header: wrong header: %s", headern);
+ msg_info ("wrong header: %s", headern);
return -1;
}
break;
if (strncasecmp (headern, RCPT_HEADER, sizeof (RCPT_HEADER) - 1) == 0) {
tmp = memory_pool_fstrdup (task->task_pool, line);
task->rcpt = g_list_prepend (task->rcpt, tmp);
- msg_debug ("parse_header: read rcpt header, value: %s", tmp);
+ debug_task ("read rcpt header, value: %s", tmp);
}
else if (strncasecmp (headern, NRCPT_HEADER, sizeof (NRCPT_HEADER) - 1) == 0) {
tmp = memory_pool_fstrdup (task->task_pool, line);
task->nrcpt = strtoul (tmp, &err, 10);
- msg_debug ("parse_header: read rcpt header, value: %d", (int)task->nrcpt);
+ debug_task ("read rcpt header, value: %d", (int)task->nrcpt);
}
else {
- msg_info ("parse_header: wrong header: %s", headern);
+ msg_info ("wrong header: %s", headern);
return -1;
}
break;
if (strncasecmp (headern, IP_ADDR_HEADER, sizeof (IP_ADDR_HEADER) - 1) == 0) {
tmp = memory_pool_fstrdup (task->task_pool, line);
if (!inet_aton (tmp, &task->from_addr)) {
- msg_info ("parse_header: bad ip header: '%s'", tmp);
+ msg_info ("bad ip header: '%s'", tmp);
return -1;
}
- msg_debug ("parse_header: read IP header, value: %s", tmp);
+ debug_task ("read IP header, value: %s", tmp);
}
else {
- msg_info ("parse_header: wrong header: %s", headern);
+ msg_info ("wrong header: %s", headern);
return -1;
}
break;
}
break;
default:
- msg_info ("parse_header: wrong header: %s", headern);
+ msg_info ("wrong header: %s", headern);
return -1;
}
url = cur->data;
if (task->cfg->log_urls) {
/* Write this url to log as well */
- msg_info ("process_message: url found: <%s>, score: [%.2f / %.2f]", struri (url), default_score, default_required_score);
+ msg_info ("url found: <%s>, score: [%.2f / %.2f]", struri (url), default_score, default_required_score);
}
host.begin = url->host;
host.len = url->hostlen;
if (g_list_next (cur) != NULL) {
c = *(host.begin + host.len);
*(host.begin + host.len) = '\0';
- msg_debug ("show_url_header: write url: %s", host.begin);
+ debug_task ("write url: %s", host.begin);
r += snprintf (outbuf + r, sizeof (outbuf) - r, "%s, ", host.begin);
*(host.begin + host.len) = c;
}
else {
c = *(host.begin + host.len);
*(host.begin + host.len) = '\0';
- msg_debug ("show_url_header: write url: %s", host.begin);
+ debug_task ("write url: %s", host.begin);
r += snprintf (outbuf + r, sizeof (outbuf) - r, "%s" CRLF, host.begin);
*(host.begin + host.len) = c;
}
cd.task = task;
cd.log_buf = logbuf;
- cd.log_offset = snprintf (logbuf, sizeof (logbuf), "process_message: msg ok, id: <%s>, ", task->message_id);
+ cd.log_offset = snprintf (logbuf, sizeof (logbuf), "msg ok, id: <%s>, ", task->message_id);
cd.log_size = sizeof (logbuf);
if (task->proto == SPAMC_PROTO) {
cd.task = task;
cd.log_buf = logbuf;
- cd.log_offset = snprintf (logbuf, sizeof (logbuf), "process_message: msg ok, id: <%s>, ", task->message_id);
+ cd.log_offset = snprintf (logbuf, sizeof (logbuf), "msg ok, id: <%s>, ", task->message_id);
cd.log_size = sizeof (logbuf);
if (task->proto == SPAMC_PROTO) {
int r;
char outbuf[OUTBUFSIZ];
- msg_debug ("write_reply: writing reply to client");
+ debug_task ("writing reply to client");
if (task->error_code != 0) {
/* Write error message and error code to reply */
if (task->proto == SPAMC_PROTO) {
r = snprintf (outbuf, sizeof (outbuf), "%s/%s %d %s" CRLF CRLF,
SPAMD_REPLY_BANNER, task->proto_ver, task->error_code, SPAMD_ERROR);
- msg_debug ("write_reply: writing error: %s", outbuf);
+ debug_task ("writing error: %s", outbuf);
}
else {
r = snprintf (outbuf, sizeof (outbuf), "%s/%s %d %s" CRLF "%s: %s" CRLF CRLF,
RSPAMD_REPLY_BANNER, task->proto_ver, task->error_code, SPAMD_ERROR, ERROR_HEADER, task->last_error);
- msg_debug ("write_reply: writing error: %s", outbuf);
+ debug_task ("writing error: %s", outbuf);
}
/* Write to bufferevent error message */
rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE);
jb = data->cur_data;
}
else {
- msg_err ("json_fin_cb: no data read");
+ msg_err ("no data read");
return;
}
if (jb->buf == NULL) {
- msg_err ("json_fin_cb: no data read");
+ msg_err ("no data read");
return;
}
/* NULL terminate current buf */
js = json_loads (jb->buf, &je);
if (!js) {
- msg_err ("json_fin_cb: cannot load json data: parse error %s, on line %d", je.text, je.line);
+ msg_err ("cannot load json data: parse error %s, on line %d", je.text, je.line);
return;
}
if (!json_is_array (js)) {
json_decref (js);
- msg_err ("json_fin_cb: loaded json is not an array");
+ msg_err ("loaded json is not an array");
return;
}
cur_elt = json_array_get (js, i);
if (!cur_elt || !json_is_object (cur_elt)) {
json_decref (js);
- msg_err ("json_fin_cb: loaded json is not an object");
+ msg_err ("loaded json is not an object");
return;
}
cur_nm = json_object_get (cur_elt, "name");
if (cur_nm == NULL || !json_is_string (cur_nm)) {
json_decref (js);
- msg_err ("json_fin_cb: name is not a string or not exists");
+ msg_err ("name is not a string or not exists");
return;
}
cur_name = g_strdup (json_string_value (cur_nm));
*pjb = jb;
if (!add_map (path, json_read_cb, json_fin_cb, (void **)pjb)) {
- msg_err ("read_settings: cannot add map %s", path);
+ msg_err ("cannot add map %s", path);
return FALSE;
}
/* Also parse mask */
addr->mask = (mask_buf[0] - '0') * 10 + mask_buf[1] - '0';
if (addr->mask > 32) {
- msg_info ("parse_spf_ipmask: bad ipmask value: '%s'", begin);
+ msg_info ("bad ipmask value: '%s'", begin);
return FALSE;
}
}
switch (cb->cur_action) {
case SPF_RESOLVE_MX:
if (type == DNS_MX) {
- msg_info ("spf_dns_callback: cannot find MX record for %s", cb->rec->cur_domain);
+ msg_info ("cannot find MX record for %s", cb->rec->cur_domain);
cb->addr->addr = ntohl (INADDR_NONE);
}
else if (type == DNS_IPv4_A) {
- msg_info ("spf_dns_callback: cannot resolve MX record for %s", cb->rec->cur_domain);
+ msg_info ("cannot resolve MX record for %s", cb->rec->cur_domain);
cb->addr->addr = ntohl (INADDR_NONE);
}
break;
case SPF_RESOLVE_PTR:
break;
case SPF_RESOLVE_REDIRECT:
- msg_info ("spf_dns_callback: cannot resolve TXT record for redirect action");
+ msg_info ("cannot resolve TXT record for redirect action");
break;
case SPF_RESOLVE_INCLUDE:
- msg_info ("spf_dns_callback: cannot resolve TXT record for include action");
+ msg_info ("cannot resolve TXT record for include action");
break;
case SPF_RESOLVE_EXP:
break;
{
CHECK_REC (rec);
- msg_info ("parse_spf_ptr: ptr parsing is unimplemented");
+ msg_info ("ptr parsing is unimplemented");
return FALSE;
}
{
CHECK_REC (rec);
- msg_info ("parse_spf_exp: exp record is ignored");
+ msg_info ("exp record is ignored");
return TRUE;
}
int t = 0, l = len;
if (len > sizeof (ipbuf)) {
- msg_info ("reverse_spf_ip: cannot reverse string of length %d", len);
+ msg_info ("cannot reverse string of length %d", len);
return;
}
}
else {
/* Something unknown */
- msg_info ("expand_spf_macro: bad spf element: %s", begin);
+ msg_info ("bad spf element: %s", begin);
return begin;
}
p ++;
}
break;
default:
- msg_info ("expand_spf_macro: unknown or unsupported spf macro %c in %s", *p, begin);
+ msg_info ("unknown or unsupported spf macro %c in %s", *p, begin);
return begin;
}
p ++;
state = 0;
}
else if (*p != 'r' && !g_ascii_isdigit (*p)) {
- msg_info ("expand_spf_macro: unknown or unsupported spf modifier %c in %s", *p, begin);
+ msg_info ("unknown or unsupported spf modifier %c in %s", *p, begin);
return begin;
}
p ++;
}
else {
/* Something unknown */
- msg_info ("expand_spf_macro: bad spf element: %s", begin);
+ msg_info ("bad spf element: %s", begin);
return begin;
}
p ++;
}
break;
default:
- msg_info ("expand_spf_macro: unknown or unsupported spf macro %c in %s", *p, begin);
+ msg_info ("unknown or unsupported spf macro %c in %s", *p, begin);
return begin;
}
p ++;
/*XXX: try to implement domain strimming */
}
else {
- msg_info ("expand_spf_macro: unknown or unsupported spf modifier %c in %s", *p, begin);
+ msg_info ("unknown or unsupported spf modifier %c in %s", *p, begin);
return begin;
}
p ++;
}
/* Null terminate */
*c = '\0';
- msg_info ("expanded string: %s", new);
+ msg_info ("%s", new);
return new;
}
res = parse_spf_a (task, begin, rec, new);
}
else {
- msg_info ("parse_spf_record: bad spf command: %s", begin);
+ msg_info ("bad spf command: %s", begin);
}
break;
case 'i':
res = parse_spf_include (task, begin, rec, new);
}
else {
- msg_info ("parse_spf_record: bad spf command: %s", begin);
+ msg_info ("bad spf command: %s", begin);
}
break;
case 'm':
res = parse_spf_mx (task, begin, rec, new);
}
else {
- msg_info ("parse_spf_record: bad spf command: %s", begin);
+ msg_info ("bad spf command: %s", begin);
}
break;
case 'p':
res = parse_spf_ptr (task, begin, rec, new);
}
else {
- msg_info ("parse_spf_record: bad spf command: %s", begin);
+ msg_info ("bad spf command: %s", begin);
}
break;
case 'e':
res = parse_spf_exists (task, begin, rec, new);
}
else {
- msg_info ("parse_spf_record: bad spf command: %s", begin);
+ msg_info ("bad spf command: %s", begin);
}
break;
case 'r':
res = parse_spf_redirect (task, begin, rec, NULL);
}
else {
- msg_info ("parse_spf_record: bad spf command: %s", begin);
+ msg_info ("bad spf command: %s", begin);
}
break;
default:
- msg_info ("parse_spf_record: bad spf command: %s", begin);
+ msg_info ("bad spf command: %s", begin);
break;
}
if (res) {
}
}
else {
- msg_info ("start_spf_parse: bad spf record version: %*s", sizeof (SPF_VER_STR) - 1, begin);
+ msg_info ("bad spf record version: %*s", sizeof (SPF_VER_STR) - 1, begin);
}
}
/* Format backup name */
backup_name = g_strdup_printf ("%s.%s", file->filename, BACKUP_SUFFIX);
- msg_info ("convert_statfile_10: convert old statfile %s to version %c.%c, backup in %s", file->filename,
+ msg_info ("convert old statfile %s to version %c.%c, backup in %s", file->filename,
header.version[0], header.version[1], backup_name);
if (stat (backup_name, &st) != -1) {
- msg_info ("convert_statfile_10: replace old %s", backup_name);
+ msg_info ("replace old %s", backup_name);
unlink (backup_name);
}
unlock_file (file->fd, FALSE);
close (file->fd);
if ((file->fd = open (file->filename, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)) == -1) {
- msg_info ("convert_statfile_10: cannot create file %s, error %d, %s", file->filename, errno, strerror (errno));
+ msg_info ("cannot create file %s, error %d, %s", file->filename, errno, strerror (errno));
return FALSE;
}
lock_file (file->fd, FALSE);
/* Now make new header and copy it to new file */
if (write (file->fd, &header, sizeof (header)) == -1) {
- msg_info ("convert_statfile_10: cannot write to file %s, error %d, %s", file->filename, errno, strerror (errno));
+ msg_info ("cannot write to file %s, error %d, %s", file->filename, errno, strerror (errno));
return FALSE;
}
/* Now write old map to new file */
if (write (file->fd, ((u_char *)file->map + sizeof (struct stat_file_header_10)),
file->len - sizeof (struct stat_file_header_10)) == -1) {
- msg_info ("convert_statfile_10: cannot write to file %s, error %d, %s", file->filename, errno, strerror (errno));
+ msg_info ("cannot write to file %s, error %d, %s", file->filename, errno, strerror (errno));
return FALSE;
}
/* Unmap old memory and map new */
munmap (file->map, file->len);
file->len = file->len + sizeof (struct stat_file_header) - sizeof (struct stat_file_header_10);
if ((file->map = mmap (NULL, file->len, PROT_READ | PROT_WRITE, MAP_SHARED, file->fd, 0)) == MAP_FAILED) {
- msg_info ("convert_statfile_10: cannot mmap file %s, error %d, %s", file->filename, errno, strerror (errno));
+ msg_info ("cannot mmap file %s, error %d, %s", file->filename, errno, strerror (errno));
return FALSE;
}
}
if (file->len < sizeof (struct stat_file)) {
- msg_info ("statfile_pool_check: file %s is too short to be stat file: %zd", file->filename, file->len);
+ msg_info ("file %s is too short to be stat file: %zd", file->filename, file->len);
return -1;
}
c = f->header.magic;
/* Check magic and version */
if (*c++ != 'r' || *c++ != 's' || *c++ != 'd') {
- msg_info ("statfile_pool_check: file %s is invalid stat file", file->filename);
+ msg_info ("file %s is invalid stat file", file->filename);
return -1;
}
/* Now check version and convert old version to new one (that can be used for sync */
}
else if (memcmp (c, valid_version, sizeof (valid_version)) != 0) {
/* Unknown version */
- msg_info ("statfile_pool_check: file %s has invalid version %c.%c", file->filename, '0' + *c, '0' + *(c + 1));
+ msg_info ("file %s has invalid version %c.%c", file->filename, '0' + *c, '0' + *(c + 1));
return -1;
}
file->cur_section.code = f->section.code;
file->cur_section.length = f->section.length;
if (file->cur_section.length * sizeof (struct stat_file_block) > file->len) {
- msg_info ("statfile_pool_check: file %s is truncated: %z, must be %z", file->filename, file->len, file->cur_section.length * sizeof (struct stat_file_block));
+ msg_info ("file %s is truncated: %z, must be %z", file->filename, file->len, file->cur_section.length * sizeof (struct stat_file_block));
return -1;
}
file->seek_pos = sizeof (struct stat_file) - sizeof (struct stat_file_block);
backup = g_strconcat (filename, ".old", NULL);
if (rename (filename, backup) == -1) {
- msg_err ("statfile_pool_reindex: cannot rename %s to %s: %s", filename, backup, strerror (errno));
+ msg_err ("cannot rename %s to %s: %s", filename, backup, strerror (errno));
g_free (backup);
memory_pool_unlock_mutex (pool->lock);
return NULL;
/* Now create new file with required size */
if (statfile_pool_create (pool, filename, size) != 0) {
- msg_err ("statfile_pool_reindex: cannot create new file");
+ msg_err ("cannot create new file");
g_free (backup);
return NULL;
}
new = statfile_pool_open (pool, filename, size, TRUE);
if (fd == -1 || new == NULL) {
- msg_err ("statfile_pool_reindex: cannot open file: %s", strerror (errno));
+ msg_err ("cannot open file: %s", strerror (errno));
g_free (backup);
return NULL;
}
/* Now start reading blocks from old statfile */
if ((map = mmap (NULL, old_size, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) {
- msg_err ("statfile_pool_reindex: cannot mmap file: %s", strerror (errno));
+ msg_err ("cannot mmap file: %s", strerror (errno));
close (fd);
g_free (backup);
return NULL;
}
if (pool->opened >= STATFILES_MAX - 1) {
- msg_err ("sttafile_pool_open: reached hard coded limit of statfiles opened: %d", STATFILES_MAX);
+ msg_err ("reached hard coded limit of statfiles opened: %d", STATFILES_MAX);
return NULL;
}
if (stat (filename, &st) == -1) {
- msg_info ("statfile_pool_open: cannot stat file %s, error %s, %d", filename, strerror (errno), errno);
+ msg_info ("cannot stat file %s, error %s, %d", filename, strerror (errno), errno);
return NULL;
}
if (!forced && st.st_size > pool->max) {
- msg_info ("statfile_pool_open: cannot attach file to pool, too large: %zd", (size_t) st.st_size);
+ msg_info ("cannot attach file to pool, too large: %zd", (size_t) st.st_size);
return NULL;
}
memory_pool_lock_mutex (pool->lock);
if (!forced && abs (st.st_size - size) > sizeof (struct stat_file)) {
memory_pool_unlock_mutex (pool->lock);
- msg_warn ("statfile_pool_open: need to reindex statfile old size: %zd, new size: %zd", st.st_size, size);
+ msg_warn ("need to reindex statfile old size: %zd, new size: %zd", st.st_size, size);
return statfile_pool_reindex (pool, filename, st.st_size, size);
}
memory_pool_unlock_mutex (pool->lock);
while (!forced && (pool->max + pool->opened * sizeof (struct stat_file) * 2 < pool->occupied + st.st_size)) {
if (statfile_pool_expire (pool) == -1) {
/* Failed to find any more free space in pool */
- msg_info ("statfile_pool_open: expiration for pool failed, opening file %s failed", filename);
+ msg_info ("expiration for pool failed, opening file %s failed", filename);
return NULL;
}
}
new_file = &pool->files[pool->opened++];
bzero (new_file, sizeof (stat_file_t));
if ((new_file->fd = open (filename, O_RDWR)) == -1) {
- msg_info ("statfile_pool_open: cannot open file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot open file %s, error %d, %s", filename, errno, strerror (errno));
memory_pool_unlock_mutex (pool->lock);
pool->opened--;
return NULL;
if ((new_file->map = mmap (NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, new_file->fd, 0)) == MAP_FAILED) {
close (new_file->fd);
memory_pool_unlock_mutex (pool->lock);
- msg_info ("statfile_pool_open: cannot mmap file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot mmap file %s, error %d, %s", filename, errno, strerror (errno));
pool->opened--;
return NULL;
stat_file_t *pos;
if ((pos = statfile_pool_is_open (pool, file->filename)) == NULL) {
- msg_info ("statfile_pool_open: file %s is not opened", file->filename);
+ msg_info ("file %s is not opened", file->filename);
return -1;
}
char *buf = NULL;
if (statfile_pool_is_open (pool, filename) != NULL) {
- msg_info ("statfile_pool_open: file %s is already opened", filename);
+ msg_info ("file %s is already opened", filename);
return 0;
}
header.total_blocks = nblocks;
if ((fd = open (filename, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)) == -1) {
- msg_info ("statfile_pool_create: cannot create file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot create file %s, error %d, %s", filename, errno, strerror (errno));
memory_pool_unlock_mutex (pool->lock);
return -1;
}
header.create_time = (uint64_t) time (NULL);
if (write (fd, &header, sizeof (header)) == -1) {
- msg_info ("statfile_pool_create: cannot write header to file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot write header to file %s, error %d, %s", filename, errno, strerror (errno));
close (fd);
memory_pool_unlock_mutex (pool->lock);
return -1;
section.length = (uint64_t) nblocks;
if (write (fd, §ion, sizeof (section)) == -1) {
- msg_info ("statfile_pool_create: cannot write section header to file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot write section header to file %s, error %d, %s", filename, errno, strerror (errno));
close (fd);
memory_pool_unlock_mutex (pool->lock);
return -1;
if (nblocks > 256) {
/* Just write buffer */
if (write (fd, buf, buflen) == -1) {
- msg_info ("statfile_pool_create: cannot write blocks buffer to file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot write blocks buffer to file %s, error %d, %s", filename, errno, strerror (errno));
close (fd);
memory_pool_unlock_mutex (pool->lock);
g_free (buf);
}
else {
if (write (fd, &block, sizeof (block)) == -1) {
- msg_info ("statfile_pool_create: cannot write block to file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot write block to file %s, error %d, %s", filename, errno, strerror (errno));
close (fd);
if (buf) {
g_free (buf);
for (i = 0; i < CHAIN_LENGTH; i++) {
if (i + blocknum >= file->cur_section.length) {
/* Need to expire some block in chain */
- msg_debug ("statfile_pool_set_block: chain %u is full, starting expire", blocknum);
+ msg_debug ("chain %u is full, starting expire", blocknum);
break;
}
/* First try to find block in chain */
/* Check whether we have a free block in chain */
if (block->hash1 == 0 && block->hash2 == 0) {
/* Write new block here */
- msg_debug ("statfile_pool_set_block: found free block %u in chain %u, set h1=%u, h2=%u", i, blocknum, h1, h2);
+ msg_debug ("found free block %u in chain %u, set h1=%u, h2=%u", i, blocknum, h1, h2);
block->hash1 = h1;
block->hash2 = h2;
block->value = value;
struct stat_file_block block = { 0, 0, 0 };
if (lseek (file->fd, 0, SEEK_END) == -1) {
- msg_info ("statfile_pool_add_section: cannot lseek file %s, error %d, %s", file->filename, errno, strerror (errno));
+ msg_info ("cannot lseek file %s, error %d, %s", file->filename, errno, strerror (errno));
return FALSE;
}
sect.length = length;
if (write (file->fd, §, sizeof (sect)) == -1) {
- msg_info ("statfile_pool_add_section: cannot write block to file %s, error %d, %s", file->filename, errno, strerror (errno));
+ msg_info ("cannot write block to file %s, error %d, %s", file->filename, errno, strerror (errno));
return FALSE;
}
while (length--) {
if (write (file->fd, &block, sizeof (block)) == -1) {
- msg_info ("statfile_pool_add_section: cannot write block to file %s, error %d, %s", file->filename, errno, strerror (errno));
+ msg_info ("cannot write block to file %s, error %d, %s", file->filename, errno, strerror (errno));
return FALSE;
}
}
file->len += length;
if (file->len > pool->max) {
- msg_info ("statfile_pool_open: cannot attach file to pool, too large: %lu", (long int)file->len);
+ msg_info ("cannot attach file to pool, too large: %lu", (long int)file->len);
return FALSE;
}
while (pool->max <= pool->occupied + file->len) {
if (statfile_pool_expire (pool) == -1) {
/* Failed to find any more free space in pool */
- msg_info ("statfile_pool_open: expiration for pool failed, opening file %s failed", file->filename);
+ msg_info ("expiration for pool failed, opening file %s failed", file->filename);
return FALSE;
}
}
if ((file->map = mmap (NULL, file->len, PROT_READ | PROT_WRITE, MAP_SHARED, file->fd, 0)) == NULL) {
- msg_info ("statfile_pool_open: cannot mmap file %s, error %d, %s", file->filename, errno, strerror (errno));
+ msg_info ("cannot mmap file %s, error %d, %s", file->filename, errno, strerror (errno));
return FALSE;
}
statfile_pool_unlock_file (pool, file);
errno = 0;
*val = strtoull (numbuf, NULL, 10);
if (errno != 0) {
- msg_info ("parse_revision_line: cannot parse number %s", strerror (errno));
+ msg_info ("cannot parse number %s", strerror (errno));
return FALSE;
}
state = 2;
case SYNC_STATE_READ_LINE:
/* Try to parse line from server */
if (!parse_revision_line (ctx, in)) {
- msg_info ("sync_read: cannot parse line: %*s", in->len, in->begin);
+ msg_info ("cannot parse line: %*s", in->len, in->begin);
close (ctx->sock);
rspamd_remove_dispatcher (ctx->dispatcher);
ctx->is_busy = FALSE;
}
else {
/* Quit this session */
- msg_info ("sync_read: sync ended for: %s", ctx->st->symbol);
+ msg_info ("sync ended for: %s", ctx->st->symbol);
close (ctx->sock);
rspamd_remove_dispatcher (ctx->dispatcher);
ctx->is_busy = FALSE;
case SYNC_STATE_READ_REV:
/* In now contains all blocks of specified revision, so we can read them directly */
if (!read_blocks (ctx, in)) {
- msg_info ("sync_read: cannot read blocks");
+ msg_info ("cannot read blocks");
close (ctx->sock);
rspamd_remove_dispatcher (ctx->dispatcher);
ctx->is_busy = FALSE;
{
struct rspamd_sync_ctx *ctx = arg;
- msg_info ("sync_err: abnormally closing connection, error: %s", err->message);
+ msg_info ("abnormally closing connection, error: %s", err->message);
ctx->is_busy = FALSE;
close (ctx->sock);
rspamd_remove_dispatcher (ctx->dispatcher);
if (ctx->is_busy) {
/* Sync is in progress */
- msg_info ("sync_timer_callback: syncronization process is in progress, do not start new one");
+ msg_info ("syncronization process is in progress, do not start new one");
return;
}
if ((ctx->sock = make_tcp_socket (&ctx->st->binlog->master_addr, ctx->st->binlog->master_port, FALSE, TRUE)) == -1) {
- msg_info ("sync_timer_callback: cannot connect to %s", inet_ntoa (ctx->st->binlog->master_addr));
+ msg_info ("cannot connect to %s", inet_ntoa (ctx->st->binlog->master_addr));
return;
}
/* Now create and activate dispatcher */
ctx->state = SYNC_STATE_GREETING;
ctx->is_busy = TRUE;
- msg_info ("sync_timer_callback: starting synchronization of %s", ctx->st->symbol);
+ msg_info ("starting synchronization of %s", ctx->st->symbol);
}
/* Open statfile and attach it to pool */
if ((ctx->real_statfile = statfile_pool_is_open (pool, st->path)) == NULL) {
if ((ctx->real_statfile = statfile_pool_open (pool, st->path, st->size, FALSE)) == NULL) {
- msg_warn ("add_statfile_watch: cannot open %s", st->path);
+ msg_warn ("cannot open %s", st->path);
if (statfile_pool_create (pool, st->path, st->size) == -1) {
- msg_err ("add_statfile_watch: cannot create statfile %s", st->path);
+ msg_err ("cannot create statfile %s", st->path);
return FALSE;
}
ctx->real_statfile = statfile_pool_open (pool, st->path, st->size, FALSE);
map = mmap (NULL, cache->used_items * sizeof (struct saved_cache_item), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (map == MAP_FAILED) {
- msg_err ("mmap_cache_file: cannot mmap cache file: %d, %s", errno, strerror (errno));
+ msg_err ("cannot mmap cache file: %d, %s", errno, strerror (errno));
close (fd);
return FALSE;
}
/* Calculate checksum */
cksum = get_mem_cksum (cache);
if (cksum == NULL) {
- msg_err ("load_symbols_cache: cannot calculate checksum for symbols");
+ msg_err ("cannot calculate checksum for symbols");
close (fd);
return FALSE;
}
/* Now write data to file */
for (i = 0; i < cache->used_items; i++) {
if (write (fd, cache->items[i].s, sizeof (struct saved_cache_item)) == -1) {
- msg_err ("create_cache_file: cannot write to file %d, %s", errno, strerror (errno));
+ msg_err ("cannot write to file %d, %s", errno, strerror (errno));
close (fd);
g_checksum_free (cksum);
g_free (digest);
}
/* Write checksum */
if (write (fd, digest, cklen) == -1) {
- msg_err ("create_cache_file: cannot write to file %d, %s", errno, strerror (errno));
+ msg_err ("cannot write to file %d, %s", errno, strerror (errno));
close (fd);
g_checksum_free (cksum);
g_free (digest);
g_free (digest);
/* Reopen for reading */
if ((fd = open (filename, O_RDWR)) == -1) {
- msg_info ("create_cache_file: cannot open file %s, error %d, %s", errno, strerror (errno));
+ msg_info ("cannot open file %s, error %d, %s", errno, strerror (errno));
return FALSE;
}
if (errno == ENOENT) {
/* Try to create file */
if ((fd = open (filename, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)) == -1) {
- msg_info ("load_symbols_cache: cannot create file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot create file %s, error %d, %s", filename, errno, strerror (errno));
return FALSE;
}
else {
}
}
else {
- msg_info ("load_symbols_cache: cannot stat file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot stat file %s, error %d, %s", filename, errno, strerror (errno));
return FALSE;
}
}
else {
if ((fd = open (filename, O_RDWR)) == -1) {
- msg_info ("load_symbols_cache: cannot open file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot open file %s, error %d, %s", filename, errno, strerror (errno));
return FALSE;
}
}
/* Calculate checksum */
cksum = get_mem_cksum (cache);
if (cksum == NULL) {
- msg_err ("load_symbols_cache: cannot calculate checksum for symbols");
+ msg_err ("cannot calculate checksum for symbols");
close (fd);
return FALSE;
}
close (fd);
g_free (mem_sum);
g_checksum_free (cksum);
- msg_err ("load_symbols_cache: cannot seek to read checksum, %d, %s", errno, strerror (errno));
+ msg_err ("cannot seek to read checksum, %d, %s", errno, strerror (errno));
return FALSE;
}
file_sum = g_malloc (cklen);
g_free (mem_sum);
g_free (file_sum);
g_checksum_free (cksum);
- msg_err ("load_symbols_cache: cannot read checksum, %d, %s", errno, strerror (errno));
+ msg_err ("cannot read checksum, %d, %s", errno, strerror (errno));
return FALSE;
}
g_free (mem_sum);
g_free (file_sum);
g_checksum_free (cksum);
- msg_info ("load_symbols_cache: checksum mismatch, recreating file");
+ msg_info ("checksum mismatch, recreating file");
/* Reopen with rw permissions */
if ((fd = open (filename, O_RDWR | O_TRUNC | O_CREAT, S_IWUSR | S_IRUSR)) == -1) {
- msg_info ("load_symbols_cache: cannot create file %s, error %d, %s", filename, errno, strerror (errno));
+ msg_info ("cannot create file %s, error %d, %s", filename, errno, strerror (errno));
return FALSE;
}
else {
return FALSE;
}
if (cache->uses++ >= MAX_USES) {
- msg_info ("call_symbols_callback: resort symbols cache");
+ msg_info ("resort symbols cache");
memory_pool_wlock_rwlock (cache->lock);
cache->uses = 0;
/* Resort while having write lock */
memory_pool_add_destructor (pool, (pool_destruct_func) g_tree_destroy, *tree);
}
- msg_debug ("osb_tokenize_text: got input length: %zd", input->len);
-
while ((res = tokenizer->get_next_word (input, &token)) != NULL) {
/* Skip small words */
if (token.len < MIN_LEN) {
{
if (up->dead) {
if (now - up->time >= revive_timeout) {
- msg_debug ("check_upstream: reviving upstream after %ld seconds", (long int)now - up->time);
U_WLOCK ();
up->dead = 0;
up->errors = 0;
}
else {
if (now - up->time >= error_timeout && up->errors >= max_errors) {
- msg_debug ("check_upstream: marking upstreams as dead after %ld errors", (long int)up->errors);
U_WLOCK ();
up->dead = 1;
up->time = now;
u_char *p;
U_WLOCK ();
- msg_debug ("revive_all_upstreams: starting reviving all upstreams");
p = ups;
for (i = 0; i < members; i++) {
cur = (struct upstream *)p;
alive = members;
}
- msg_debug ("rescan_upstreams: %d upstreams alive", alive);
return alive;
alive = rescan_upstreams (ups, members, msize, now, error_timeout, revive_timeout, max_errors);
selected = rand () % alive;
- msg_debug ("get_random_upstream: return upstream with number %d of %d", selected, alive);
return get_upstream_by_number (ups, members, msize, selected);
}
h = (h >> 16) & 0x7fff;
#endif
h %= members;
- msg_debug ("get_upstream_by_hash: try to select upstream number %d of %zd", h, members);
for (;;) {
p = (char *)ups + msize * h;
h += ht;
#endif
h %= members;
- msg_debug ("get_upstream_by_hash: try to select upstream number %d of %zd, tries: %d", h, members, tries);
tries++;
if (tries > MAX_TRIES) {
- msg_debug ("get_upstream_by_hash: max tries exceed, returning NULL");
return NULL;
}
}
}
U_UNLOCK ();
}
- msg_debug ("get_upstream_round_robin: selecting upstream with weight %d", max_weight);
return selected;
}
p += msize;
}
U_UNLOCK ();
- msg_debug ("get_upstream_master_slave: selecting upstream with priority %d", max_weight);
return selected;
}
if (url_initialized == 0) {
text_re = g_regex_new (text_url, G_REGEX_CASELESS | G_REGEX_MULTILINE | G_REGEX_OPTIMIZE | G_REGEX_EXTENDED, 0, &err);
if (err != NULL) {
- msg_info ("url_init: cannot init text url parsing regexp: %s", err->message);
+ msg_info ("cannot init text url parsing regexp: %s", err->message);
g_error_free (err);
return -1;
}
html_re = g_regex_new (html_url, G_REGEX_CASELESS | G_REGEX_MULTILINE | G_REGEX_OPTIMIZE | G_REGEX_EXTENDED, 0, &err);
if (err != NULL) {
- msg_info ("url_init: cannot init html url parsing regexp: %s", err->message);
+ msg_info ("cannot init html url parsing regexp: %s", err->message);
g_error_free (err);
return -1;
}
return URI_ERRNO_EMPTY;
uri->string = reencode_escapes (uristring, pool);
- msg_debug ("parse_uri: reencoding escapes in original url: '%s'", struri (uri));
+ msg_debug ("reencoding escapes in original url: '%s'", struri (uri));
uri->protocollen = get_protocol_length (struri (uri));
/* Assume http as default protocol */
}
else {
/* Figure out whether the protocol is known */
- msg_debug ("parse_uri: getting protocol from url: %d", uri->protocol);
+ msg_debug ("getting protocol from url: %d", uri->protocol);
prefix_end = struri (uri) + uri->protocollen; /* ':' */
prefix_end++;
}
if (*prefix_end != ':') {
- msg_debug ("parse_uri: invalid protocol in uri");
+ msg_debug ("invalid protocol in uri");
return URI_ERRNO_INVALID_PROTOCOL;
}
prefix_end++;
if (prefix_end[0] == '/' && prefix_end[1] == '/') {
if (prefix_end[2] == '/') {
- msg_debug ("parse_uri: too many '/' in uri");
+ msg_debug ("too many '/' in uri");
return URI_ERRNO_TOO_MANY_SLASHES;
}
}
else {
- msg_debug ("parse_uri: no '/' in uri");
+ msg_debug ("no '/' in uri");
return URI_ERRNO_NO_SLASHES;
}
}
struct uri *new;
if (!part->orig->data || part->orig->len == 0) {
- msg_warn ("url_parse_text: got empty text part");
+ msg_warn ("got empty text part");
return;
}
if (rc) {
while (g_match_info_matches (info)) {
url_str = g_match_info_fetch (info, is_html ? 1 : 0);
- msg_debug ("url_parse_text: extracted string with regexp: '%s', html is %s", url_str, is_html ? "on" : "off");
+ debug_task ("extracted string with regexp: '%s', html is %s", url_str, is_html ? "on" : "off");
if (url_str != NULL) {
if (g_tree_lookup (is_html ? part->html_urls : part->urls, url_str) == NULL) {
new = memory_pool_alloc (pool, sizeof (struct uri));
}
}
else if (err != NULL) {
- msg_debug ("url_parse_text: error matching regexp: %s", err->message);
+ debug_task ("error matching regexp: %s", err->message);
g_free (err);
}
else {
- msg_debug ("url_parse_text: cannot find url pattern in given string");
+ debug_task ("cannot find url pattern in given string");
}
g_match_info_free (info);
}
#define CONNECT_TIMEOUT 3
#ifdef RSPAMD_MAIN
-sig_atomic_t do_reopen_log = 0;
extern rspamd_hash_t *counters;
#endif
-struct logger_params {
- GLogFunc log_func;
- struct config_file *cfg;
-};
-
-static struct logger_params log_params;
-
-/* Here would be put log messages intensity */
-static uint32_t log_written;
-static time_t last_check;
-static char *io_buf = NULL;
-static gboolean log_buffered = FALSE;
static u_char* rspamd_sprintf_num (u_char *buf, u_char *last, uint64_t ui64, u_char zero, unsigned int hexadecimal, unsigned int width);
int
ofl = fcntl (fd, F_GETFL, 0);
if (fcntl (fd, F_SETFL, ofl | O_NONBLOCK) == -1) {
- msg_warn ("make_socket_nonblocking: fcntl failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("fcntl failed: %d, '%s'", errno, strerror (errno));
return -1;
}
return 0;
ofl = fcntl (fd, F_GETFL, 0);
if (fcntl (fd, F_SETFL, ofl & (~O_NONBLOCK)) == -1) {
- msg_warn ("make_socket_nonblocking: fcntl failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("fcntl failed: %d, '%s'", errno, strerror (errno));
return -1;
}
return 0;
/* Create socket */
fd = socket (AF_INET, family, 0);
if (fd == -1) {
- msg_warn ("make_tcp_socket: socket failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("socket failed: %d, '%s'", errno, strerror (errno));
return -1;
}
/* Set close on exec */
if (fcntl (fd, F_SETFD, FD_CLOEXEC) == -1) {
- msg_warn ("make_tcp_socket: fcntl failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("fcntl failed: %d, '%s'", errno, strerror (errno));
goto out;
}
if (r == -1) {
if (errno != EINPROGRESS) {
- msg_warn ("make_tcp_socket: bind/connect failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("bind/connect failed: %d, '%s'", errno, strerror (errno));
goto out;
}
if (!async) {
/* Try to poll */
if (poll_sync_socket (fd, CONNECT_TIMEOUT * 1000, POLLOUT) <= 0) {
errno = ETIMEDOUT;
- msg_warn ("make_tcp_socket: bind/connect failed: timeout");
+ msg_warn ("bind/connect failed: timeout");
goto out;
}
else {
if (errno == EAGAIN) {
return 0;
}
- msg_warn ("accept_from_socket: accept failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("accept failed: %d, '%s'", errno, strerror (errno));
return -1;
}
if (make_socket_nonblocking (nfd) < 0) {
/* Set close on exec */
if (fcntl (nfd, F_SETFD, FD_CLOEXEC) == -1) {
- msg_warn ("accept_from_socket: fcntl failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("fcntl failed: %d, '%s'", errno, strerror (errno));
goto out;
}
fd = socket (PF_LOCAL, SOCK_STREAM, 0);
if (fd == -1) {
- msg_warn ("make_unix_socket: socket failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("socket failed: %d, '%s'", errno, strerror (errno));
return -1;
}
/* Set close on exec */
if (fcntl (fd, F_SETFD, FD_CLOEXEC) == -1) {
- msg_warn ("make_unix_socket: fcntl failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("fcntl failed: %d, '%s'", errno, strerror (errno));
goto out;
}
if (is_server) {
if (r == -1) {
if (errno != EINPROGRESS) {
- msg_warn ("make_unix_socket: bind/connect failed: %d, '%s'", errno, strerror (errno));
+ msg_warn ("bind/connect failed: %d, '%s'", errno, strerror (errno));
goto out;
}
}
}
#endif
-
-/* Logging utility functions */
-int
-open_log (struct config_file *cfg)
-{
- switch (cfg->log_type) {
- case RSPAMD_LOG_CONSOLE:
- /* Do nothing with console */
- return 0;
- case RSPAMD_LOG_SYSLOG:
- openlog ("rspamd", LOG_NDELAY | LOG_PID, cfg->log_facility);
- return 0;
- case RSPAMD_LOG_FILE:
- cfg->log_fd = open (cfg->log_file, O_CREAT | O_WRONLY | O_APPEND, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
- if (cfg->log_fd == -1) {
- fprintf (stderr, "open_log: cannot open desired log file: %s, %s", cfg->log_file, strerror (errno));
- return -1;
- }
- cfg->logf = fdopen (cfg->log_fd, "w");
- /* Set line buffering */
- setvbuf (cfg->logf, (char *)NULL, _IOLBF, 0);
- return 0;
- }
- return -1;
-}
-
-void
-close_log (struct config_file *cfg)
-{
- switch (cfg->log_type) {
- case RSPAMD_LOG_CONSOLE:
- /* Do nothing with console */
- break;
- case RSPAMD_LOG_SYSLOG:
- closelog ();
- break;
- case RSPAMD_LOG_FILE:
- if (cfg->logf != NULL) {
- if (fsync (cfg->log_fd) == -1) {
- msg_err ("close_log: error syncing log file: %s", strerror (errno));
- }
- fclose (cfg->logf);
- }
- break;
- }
-
-}
-
-void
-rspamd_set_logger (GLogFunc func, struct config_file *cfg)
-{
- log_params.log_func = func;
- log_params.cfg = cfg;
-}
-
-int
-reopen_log (struct config_file *cfg)
-{
-#ifdef RSPAMD_MAIN
- do_reopen_log = 0;
-#endif
- close_log (cfg);
- return open_log (cfg);
-}
-
-void
-rspamd_log_function (GLogLevelFlags log_level, const char *fmt, ...)
-{
- static char logbuf[BUFSIZ];
- va_list vp;
- u_char *end;
-
- if (log_level <= log_params.cfg->log_level) {
- va_start (vp, fmt);
- end = rspamd_vsnprintf (logbuf, sizeof (logbuf), fmt, vp);
- *end = '\0';
- va_end (vp);
- log_params.log_func (NULL, log_level, logbuf, log_params.cfg);
- }
-}
-
-void
-syslog_log_function (const gchar * log_domain, GLogLevelFlags log_level, const gchar * message, gpointer arg)
-{
- struct config_file *cfg = (struct config_file *)arg;
-#ifdef RSPAMD_MAIN
- if (do_reopen_log) {
- reopen_log (cfg);
- }
-#endif
-
- if (log_level <= cfg->log_level) {
- if (log_level >= G_LOG_LEVEL_DEBUG) {
- syslog (LOG_DEBUG, "%s", message);
- }
- else if (log_level >= G_LOG_LEVEL_INFO) {
- syslog (LOG_INFO, "%s", message);
- }
- else if (log_level >= G_LOG_LEVEL_WARNING) {
- syslog (LOG_WARNING, "%s", message);
- }
- else if (log_level >= G_LOG_LEVEL_CRITICAL) {
- syslog (LOG_ERR, "%s", message);
- }
- }
-}
-
-void
-file_log_function (const gchar * log_domain, GLogLevelFlags log_level, const gchar * message, gpointer arg)
-{
- struct config_file *cfg = (struct config_file *)arg;
- char tmpbuf[128], timebuf[32];
- time_t now;
- struct tm *tms;
-
- if (cfg->log_fd == -1 || cfg->logf == NULL) {
- return;
- }
-#ifdef RSPAMD_MAIN
- if (do_reopen_log) {
- reopen_log (cfg);
- }
-#endif
-
- if (log_level <= cfg->log_level) {
- now = time (NULL);
- tms = localtime (&now);
-
- if (last_check == 0) {
- last_check = now;
- }
- else if (now - last_check > CHECK_TIME) {
- if (log_written / (now - last_check) > BUF_INTENSITY && !log_buffered) {
- /* Switch to buffered logging */
- if (io_buf == NULL) {
- io_buf = g_malloc (BUFSIZ);
- }
- setvbuf (cfg->logf, io_buf, _IOFBF, BUFSIZ);
- log_buffered = TRUE;
- }
- else if (log_buffered) {
- /* Switch to line buffering */
- setvbuf (cfg->logf, NULL, _IOLBF, 0);
- log_buffered = FALSE;
- }
- last_check = now;
- log_written = 0;
- }
-
- strftime (timebuf, sizeof (timebuf), "%b %d %H:%M:%S", tms);
- rspamd_snprintf (tmpbuf, sizeof (tmpbuf), "#%P: %s rspamd %Z", getpid (), timebuf);
- fprintf (cfg->logf, "%s%s" CRLF, tmpbuf, message);
- log_written++;
- }
-}
-
/* Replace %r with rcpt value and %f with from value, new string is allocated in pool */
char *
resolve_stat_filename (memory_pool_t * pool, char *pattern, char *rcpt, char *from)
ProfilerRegisterThread ();
}
else {
- msg_warn ("gperf_frofiler_init: cannot start google perftools profiler");
+ msg_warn ("cannot start google perftools profiler");
}
#endif
if (async && errno == EAGAIN) {
return FALSE;
}
- msg_warn ("lock_file: lock on file failed: %s", strerror (errno));
+ msg_warn ("lock on file failed: %s", strerror (errno));
return FALSE;
}
if (async && errno == EAGAIN) {
return FALSE;
}
- msg_warn ("lock_file: lock on file failed: %s", strerror (errno));
+ msg_warn ("lock on file failed: %s", strerror (errno));
return FALSE;
}
if (async && (errno == EAGAIN || errno == EACCES)) {
return FALSE;
}
- msg_warn ("lock_file: lock on file failed: %s", strerror (errno));
+ msg_warn ("lock on file failed: %s", strerror (errno));
return FALSE;
}
if (async && (errno == EAGAIN || errno == EACCES)) {
return FALSE;
}
- msg_warn ("lock_file: lock on file failed: %s", strerror (errno));
+ msg_warn ("lock on file failed: %s", strerror (errno));
return FALSE;
}
GList *cur;
if (pool == NULL || ccf == NULL || symbol == NULL) {
- msg_err ("get_statfile_by_symbol: invalid input arguments");
+ msg_err ("invalid input arguments");
return NULL;
}
cur = g_list_next (cur);
}
if (*st == NULL) {
- msg_info ("get_statfile_by_symbol: cannot find statfile with symbol %s", symbol);
+ msg_info ("cannot find statfile with symbol %s", symbol);
return NULL;
}
if ((res = statfile_pool_is_open (pool, (*st)->path)) == NULL) {
if ((res = statfile_pool_open (pool, (*st)->path, (*st)->size, FALSE)) == NULL) {
- msg_warn ("get_statfile_by_symbol: cannot open %s", (*st)->path);
+ msg_warn ("cannot open %s", (*st)->path);
if (try_create) {
if (statfile_pool_create (pool, (*st)->path, (*st)->size) == -1) {
- msg_err ("get_statfile_by_symbol: cannot create statfile %s", (*st)->path);
+ msg_err ("cannot create statfile %s", (*st)->path);
return NULL;
}
res = statfile_pool_open (pool, (*st)->path, (*st)->size, FALSE);
if (res == NULL) {
- msg_err ("get_statfile_by_symbol: cannot open statfile %s after creation", (*st)->path);
+ msg_err ("cannot open statfile %s after creation", (*st)->path);
}
}
}
int pidfile_remove(struct pidfh *pfh);
#endif
-void rspamd_set_logger (GLogFunc func, struct config_file *cfg);
-int open_log (struct config_file *cfg);
-void close_log (struct config_file *cfg);
-int reopen_log (struct config_file *cfg);
-void rspamd_log_function (GLogLevelFlags log_level, const char *fmt, ...);
-void syslog_log_function (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer arg);
-void file_log_function (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer arg);
-
/* Replace %r with rcpt value and %f with from value, new string is allocated in pool */
char* resolve_stat_filename (memory_pool_t *pool, char *pattern, char *rcpt, char *from);
const char* calculate_check_time (struct timespec *begin, int resolution);
switch (signo) {
case SIGINT:
case SIGTERM:
+ close_log ();
#ifdef WITH_GPERF_TOOLS
ProfilerStop ();
#endif
struct mime_part *p;
if (task) {
- msg_debug ("free_task: free pointer %p", task);
+ debug_task ("free pointer %p", task);
if (task->memc_ctx) {
memc_close_ctx (task->memc_ctx);
}
task->msg = memory_pool_alloc (task->task_pool, sizeof (f_str_t));
task->msg->begin = in->begin;
task->msg->len = in->len;
- msg_debug ("read_socket: got string of length %ld", (long int)task->msg->len);
+ debug_task ("got string of length %ld", (long int)task->msg->len);
r = process_message (task);
if (r == -1) {
- msg_warn ("read_socket: processing of message failed");
+ msg_warn ("processing of message failed");
task->last_error = "MIME processing error";
task->error_code = RSPAMD_FILTER_ERROR;
task->state = WRITE_ERROR;
}
break;
default:
- msg_debug ("read_socket: invalid state on reading stage");
+ debug_task ("invalid state on reading stage");
break;
}
return FALSE;
break;
case CLOSING_CONNECTION:
- msg_debug ("write_socket: normally closing connection");
+ debug_task ("normally closing connection");
destroy_session (task->s);
return FALSE;
break;
default:
- msg_info ("write_socket: abnormally closing connection");
+ msg_info ("abnormally closing connection");
destroy_session (task->s);
return FALSE;
break;
err_socket (GError * err, void *arg)
{
struct worker_task *task = (struct worker_task *)arg;
- msg_info ("err_socket: abnormally closing connection, error: %s", err->message);
+ msg_info ("abnormally closing connection, error: %s", err->message);
/* Free buffers */
destroy_session (task->s);
}
new_task = g_malloc (sizeof (struct worker_task));
- msg_debug ("accept_socket: new task allocated: %p", new_task);
bzero (new_task, sizeof (struct worker_task));
new_task->worker = worker;
new_task->state = READ_COMMAND;
int nfd;
if ((nfd = accept_from_socket (fd, (struct sockaddr *)&ss, &addrlen)) == -1) {
- msg_warn ("accept_socket: accept failed: %s", strerror (errno));
+ msg_warn ("accept failed: %s", strerror (errno));
return;
}
/* Check for EAGAIN */
if (nfd == 0) {
- msg_debug ("accept_socket: cannot accept socket as it was already accepted by other worker");
return;
}
new_task = construct_task (worker);
if (ss.ss_family == AF_UNIX) {
- msg_info ("accept_socket: accepted connection from unix socket");
+ msg_info ("accepted connection from unix socket");
new_task->client_addr.s_addr = INADDR_NONE;
}
else if (ss.ss_family == AF_INET) {
sin = (struct sockaddr_in *)&ss;
- msg_info ("accept_socket: accepted connection from %s port %d", inet_ntoa (sin->sin_addr), ntohs (sin->sin_port));
+ msg_info ("accepted connection from %s port %d", inet_ntoa (sin->sin_addr), ntohs (sin->sin_port));
memcpy (&new_task->client_addr, &sin->sin_addr, sizeof (struct in_addr));
}
/* Set up dispatcher */
new_task->dispatcher = rspamd_create_dispatcher (nfd, BUFFER_LINE, read_socket, write_socket, err_socket, &io_tv, (void *)new_task);
+ new_task->dispatcher->peer_addr = new_task->client_addr.s_addr;
}
}
event_loop (0);
+
+ close_log ();
exit (EXIT_SUCCESS);
}
}
task.cfg = memory_pool_alloc0 (task.task_pool, sizeof (struct config_file));
- task.cfg->log_level = G_LOG_LEVEL_CRITICAL;
- task.cfg->log_fd = STDERR_FILENO;
- g_log_set_default_handler (file_log_function, task.cfg);
task.msg = memory_pool_alloc (task.task_pool, sizeof (f_str_t));
task.msg->begin = buf;