summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
b6e435b)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
static const filter_t *next_filter(client_t *pcy, const filter_t *filter,
const query_t *query, const filter_hook_t *hook, bool *ok) {
static const filter_t *next_filter(client_t *pcy, const filter_t *filter,
const query_t *query, const filter_hook_t *hook, bool *ok) {
+#define MESSAGE_FORMAT "request client=%s from=<%s> to=<%s> at %s: "
+#define MESSAGE_PARAMS query->client_name, \
+ query->sender == NULL ? "undefined" : query->sender, \
+ query->recipient == NULL ? "undefined" : query->recipient, \
+ smtp_state_names[query->state]
+
if (hook != NULL) {
query_context_t *context = client_data(pcy);
if (hook->counter >= 0 && hook->counter < MAX_COUNTERS && hook->cost > 0) {
context->context.counters[hook->counter] += hook->cost;
if (hook != NULL) {
query_context_t *context = client_data(pcy);
if (hook->counter >= 0 && hook->counter < MAX_COUNTERS && hook->cost > 0) {
context->context.counters[hook->counter] += hook->cost;
- debug("request client=%s, from=<%s>, to=<%s>: added %d to counter %d (now %u)",
- query->client_name,
- query->sender == NULL ? "undefined" : query->sender,
- query->recipient == NULL ? "undefined" : query->recipient,
+ debug(MESSAGE_FORMAT "added %d to counter %d (now %u)", MESSAGE_PARAMS,
hook->cost, hook->counter, context->context.counters[hook->counter]);
}
}
if (hook == NULL) {
hook->cost, hook->counter, context->context.counters[hook->counter]);
}
}
if (hook == NULL) {
- warn("request client=%s, from=<%s>, to=<%s>: aborted",
- query->client_name,
- query->sender == NULL ? "undefined" : query->sender,
- query->recipient == NULL ? "undefined" : query->recipient);
+ warn(MESSAGE_FORMAT "aborted", MESSAGE_PARAMS);
*ok = false;
return NULL;
} else if (hook->async) {
*ok = false;
return NULL;
} else if (hook->async) {
- debug("request client=%s, from=<%s>, to=<%s>: "
- "asynchronous filter from filter %s",
- query->client_name,
- query->sender == NULL ? "undefined" : query->sender,
- query->recipient == NULL ? "undefined" : query->recipient,
- filter->name);
+ debug(MESSAGE_FORMAT "asynchronous filter from filter %s",
+ MESSAGE_PARAMS, filter->name);
*ok = true;
return NULL;
} else if (hook->postfix) {
*ok = true;
return NULL;
} else if (hook->postfix) {
- info("request client=%s, from=<%s>, to=<%s>: "
- "awswer %s from filter %s: \"%s\"",
- query->client_name,
- query->sender == NULL ? "undefined" : query->sender,
- query->recipient == NULL ? "undefined" : query->recipient,
+ info(MESSAGE_FORMAT "awswer %s from filter %s: \"%s\"", MESSAGE_PARAMS,
htokens[hook->type], filter->name, hook->value);
policy_answer(pcy, hook->value);
*ok = true;
return NULL;
} else {
htokens[hook->type], filter->name, hook->value);
policy_answer(pcy, hook->value);
*ok = true;
return NULL;
} else {
- debug("request client=%s, from=<%s>, to=<%s>: "
- "awswer %s from filter %s: next filter %s",
- query->client_name,
- query->sender == NULL ? "undefined" : query->sender,
- query->recipient == NULL ? "undefined" : query->recipient,
- htokens[hook->type], filter->name,
- (array_ptr(config->filters, hook->filter_id))->name);
+ debug(MESSAGE_FORMAT "awswer %s from filter %s: next filter %s",
+ MESSAGE_PARAMS, htokens[hook->type], filter->name,
+ (array_ptr(config->filters, hook->filter_id))->name);
return array_ptr(config->filters, hook->filter_id);
}
return array_ptr(config->filters, hook->filter_id);
}
+#undef MESSAGE_PARAMS
+#undef MESSAGE_FORMAT
}
static bool policy_process(client_t *pcy, const config_t *mconfig)
}
static bool policy_process(client_t *pcy, const config_t *mconfig)
const query_t* query = &context->query;
const filter_t *filter;
if (mconfig->entry_points[query->state] == -1) {
const query_t* query = &context->query;
const filter_t *filter;
if (mconfig->entry_points[query->state] == -1) {
- warn("no filter defined for current protocol_state (%d)", query->state);
+ warn("no filter defined for current protocol_state (%s)", smtp_state_names[query->state]);
return false;
}
if (context->context.current_filter != NULL) {
return false;
}
if (context->context.current_filter != NULL) {
#include "policy_tokens.h"
#include "str.h"
#include "policy_tokens.h"
#include "str.h"
+const char *smtp_state_names[SMTP_count] = {
+ "CONNECT",
+ "HELO",
+ "MAIL",
+ "RCPT",
+ "DATA",
+ "END-OF-MESSAGE",
+ "VRFY",
+ "ETRN",
+};
+
bool query_parse(query_t *query, char *p)
{
#define PARSE_CHECK(expr, error, ...) \
bool query_parse(query_t *query, char *p)
{
#define PARSE_CHECK(expr, error, ...) \
CASE(ETRN_DOMAIN, etrn_domain)
CASE(STRESS, stress)
#undef CASE
CASE(ETRN_DOMAIN, etrn_domain)
CASE(STRESS, stress)
#undef CASE
+ case PTK_PROTOCOL_NAME:
+ return query->esmtp ? "ESMTP" : "SMTP";
+
+ case PTK_PROTOCOL_STATE:
+ return smtp_state_names[query->state];
+
default: return NULL;
}
}
default: return NULL;
}
}
+extern const char *smtp_state_names[SMTP_count];
+
/* \see http://www.postfix.org/SMTPD_POLICY_README.html */
typedef struct query_t {
unsigned state : 4;
/* \see http://www.postfix.org/SMTPD_POLICY_README.html */
typedef struct query_t {
unsigned state : 4;