projects
/
apps
/
pfixtools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add hostname match on recipient_domain and sender_domain.
[apps/pfixtools.git]
/
postlicyd
/
strlist.c
diff --git
a/postlicyd/strlist.c
b/postlicyd/strlist.c
index
4ca2057
..
19fd0b2
100644
(file)
--- a/
postlicyd/strlist.c
+++ b/
postlicyd/strlist.c
@@
-49,10
+49,11
@@
typedef struct strlist_config_t {
int hard_threshold;
unsigned is_email :1;
int hard_threshold;
unsigned is_email :1;
+ unsigned is_hostname :1;
+
unsigned match_sender :1;
unsigned match_recipient :1;
unsigned match_sender :1;
unsigned match_recipient :1;
- unsigned is_hostname :1;
unsigned match_helo :1;
unsigned match_client :1;
unsigned match_reverse :1;
unsigned match_helo :1;
unsigned match_client :1;
unsigned match_reverse :1;
@@
-111,8
+112,8
@@
static trie_t *strlist_create(const char *file, bool reverse, bool lock)
--end;
}
if (end != map.end) {
--end;
}
if (end != map.end) {
-
syslog(LOG_WARNING,
"file %s miss a final \\n, ignoring last line",
-
file);
+
warn(
"file %s miss a final \\n, ignoring last line",
+ file);
}
db = trie_new();
}
db = trie_new();
@@
-122,7
+123,7
@@
static trie_t *strlist_create(const char *file, bool reverse, bool lock)
eol = end;
}
if (eol - p >= BUFSIZ) {
eol = end;
}
if (eol - p >= BUFSIZ) {
-
syslog(LOG_ERR,
"unreasonnable long line");
+
err(
"unreasonnable long line");
file_map_close(&map);
trie_delete(&db);
return NULL;
file_map_close(&map);
trie_delete(&db);
return NULL;
@@
-154,7
+155,7
@@
static bool strlist_filter_constructor(filter_t *filter)
#define PARSE_CHECK(Expr, Str, ...) \
if (!(Expr)) { \
#define PARSE_CHECK(Expr, Str, ...) \
if (!(Expr)) { \
-
syslog(LOG_ERR, Str, ##__VA_ARGS__);
\
+
err(Str, ##__VA_ARGS__);
\
strlist_config_delete(&config); \
return false; \
}
strlist_config_delete(&config); \
return false; \
}
@@
-276,6
+277,8
@@
static bool strlist_filter_constructor(filter_t *filter)
CASE(HELO_NAME, helo, hostname);
CASE(CLIENT_NAME, client, hostname);
CASE(REVERSE_CLIENT_NAME, reverse, hostname);
CASE(HELO_NAME, helo, hostname);
CASE(CLIENT_NAME, client, hostname);
CASE(REVERSE_CLIENT_NAME, reverse, hostname);
+ CASE(SENDER_DOMAIN, sender, hostname);
+ CASE(RECIPIENT_DOMAIN, recipient, hostname);
CASE(SENDER, sender, email);
CASE(RECIPIENT, recipient, email);
#undef CASE
CASE(SENDER, sender, email);
CASE(RECIPIENT, recipient, email);
#undef CASE
@@
-319,12
+322,11
@@
static filter_result_t strlist_filter(const filter_t *filter, const query_t *que
if (config->is_email &&
((config->match_sender && query->state < SMTP_MAIL)
|| (config->match_recipient && query->state != SMTP_RCPT))) {
if (config->is_email &&
((config->match_sender && query->state < SMTP_MAIL)
|| (config->match_recipient && query->state != SMTP_RCPT))) {
-
syslog(LOG_WARNING,
"trying to match an email against a field that is not "
-
"available in current protocol state");
+
warn(
"trying to match an email against a field that is not "
+ "available in current protocol state");
return HTK_ABORT;
} else if (config->is_hostname && config->match_helo && query->state < SMTP_HELO) {
return HTK_ABORT;
} else if (config->is_hostname && config->match_helo && query->state < SMTP_HELO) {
- syslog(LOG_WARNING, "trying to match hostname against helo before helo "
- "is received");
+ warn("trying to match hostname against helo before helo is received");
return HTK_ABORT;
}
#define LOOKUP(Flag, Field) \
return HTK_ABORT;
}
#define LOOKUP(Flag, Field) \
@@
-340,6
+342,9
@@
static filter_result_t strlist_filter(const filter_t *filter, const query_t *que
if ((!part && trie_lookup(trie, rev ? reverse : normal)) \
|| (part && trie_prefix(trie, rev ? reverse : normal))) { \
sum += weight; \
if ((!part && trie_lookup(trie, rev ? reverse : normal)) \
|| (part && trie_prefix(trie, rev ? reverse : normal))) { \
sum += weight; \
+ if (sum >= config->hard_threshold) { \
+ return HTK_HARD_MATCH; \
+ } \
} \
} \
}
} \
} \
}
@@
-350,6
+355,8
@@
static filter_result_t strlist_filter(const filter_t *filter, const query_t *que
LOOKUP(helo, helo_name);
LOOKUP(client, client_name);
LOOKUP(reverse, reverse_client_name);
LOOKUP(helo, helo_name);
LOOKUP(client, client_name);
LOOKUP(reverse, reverse_client_name);
+ LOOKUP(recipient, recipient_domain);
+ LOOKUP(sender, sender_domain);
}
#undef LOOKUP
if (sum >= config->hard_threshold) {
}
#undef LOOKUP
if (sum >= config->hard_threshold) {