Add support for the stress parameter of postfix 2.5+.
Can mlock rbl data.
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
const char *size;
const char *ccert_subject;
const char *ccert_issuer;
- const char *ccsert_fingerprint;
+ const char *ccert_fingerprint;
/* postfix 2.3+ */
const char *encryption_protocol;
const char *encryption_keysize;
const char *etrn_domain;
+ /* postfix 2.5+ */
+ const char *stress;
+
const char *eoq;
} query_t;
CASE(SIZE, size);
CASE(CCERT_SUBJECT, ccert_subject);
CASE(CCERT_ISSUER, ccert_issuer);
- CASE(CCSERT_FINGERPRINT, ccsert_fingerprint);
+ CASE(CCERT_FINGERPRINT, ccert_fingerprint);
CASE(ENCRYPTION_PROTOCOL, encryption_protocol);
CASE(ENCRYPTION_CIPHER, encryption_cipher);
CASE(ENCRYPTION_KEYSIZE, encryption_keysize);
CASE(ETRN_DOMAIN, etrn_domain);
+ CASE(STRESS, stress);
#undef CASE
case PTK_REQUEST:
{
va_list args;
va_start(args, fmt);
+ buffer_addstr(&pcy->obuf, "action=");
buffer_addvf(&pcy->obuf, fmt, args);
va_end(args);
buffer_addstr(&pcy->obuf, "\n\n");
struct rbldb_t {
uint32_t len, size;
uint32_t *ips;
+ bool locked;
};
static int get_o(const char *s, const char **out)
return 0;
}
-rbldb_t *rbldb_create(const char *file)
+rbldb_t *rbldb_create(const char *file, bool lock)
{
rbldb_t *db;
const char *map, *p, *end;
}
munmap((void*)map, st.st_size);
+ /* Lookup may perform serveral I/O, so avoid swap.
+ */
+ db->locked = lock && mlock(db->ips, db->len * sizeof(*(db->ips))) == 0;
+
if (db->len) {
# define QSORT_TYPE uint32_t
# define QSORT_BASE db->ips
void rbldb_delete(rbldb_t **db)
{
if (*db) {
+ if ((*db)->locked) {
+ (void)munlock((*db)->ips, (*db)->len * sizeof(*(*db)->ips));
+ }
p_delete(&(*db)->ips);
p_delete(&(*db));
}
typedef struct rbldb_t rbldb_t;
-rbldb_t *rbldb_create(const char *file);
+rbldb_t *rbldb_create(const char *file, bool lock);
void rbldb_delete(rbldb_t **);
uint32_t rbldb_stats(rbldb_t *rbl);
## size
## ccert_subject
## ccert_issuer
-## ccsert_fingerprint
+## ccert_fingerprint
#
# postfix 2.3+
## encryption_protocol
## encryption_keysize
## etrn_domain
#
+# postfix 2.5+
+## stress
+#
# request value
## smtpd_access_policy
#
int main(int argc, char *argv[])
{
if (argc > 1) {
- rbldb_t *db = rbldb_create(argv[1]);
+ rbldb_t *db = rbldb_create(argv[1], false);
printf("loaded: %s, %d ips, %d o\n", argv[1], rbldb_stats(db),
rbldb_stats(db) * 4);
rbldb_delete(&db);