Skip to content

Commit

Permalink
Make grey_tuple more descriptive and fix it
Browse files Browse the repository at this point in the history
- Use the terms 'user' and 'server' which is more descriptive than the
  terms 'normal' and 'loose'.

- Fix the previous commit to actually use 'grey_tuple' as keyword in config.

- Fix a segfault for the case when grey_tuple was not specified at all in
  gross.conf.
  • Loading branch information
natanael.copa@gmail.com committed Jul 11, 2011
1 parent 0166594 commit a14b5a6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions doc/examples/grossd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ protocol = postfix
# DEFAULT: update = grey

# 'grey_tuple' is the way greylisting tuples are created. Valid options are
# 'normal' and 'loose'. If 'grey_tuple = normal' the tuple for grey listing
# 'user' and 'server'. If 'grey_tuple = user' the tuple for grey listing
# will be: masked client-ip, sender email, recipient email. If 'grey_tuple =
# loose' the tuple for greylisting will be client-ip, domain of sender email
# server' the tuple for greylisting will be client-ip, domain of sender email
# and helo.
# DEFAULT: grey_tuple = normal
# DEFAULT: grey_tuple = user

# 'grey_mask' is the mask for grossd to use when matching client_ip
# against the database. Default is 24, so grossd treats addresses
Expand Down
4 changes: 2 additions & 2 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ typedef int bool;

typedef enum
{
GREY_TUPLE_NORMAL = 0,
GREY_TUPLE_LOOSE,
GREY_TUPLE_USER = 0,
GREY_TUPLE_SERVER,
} greytupletype_t;

typedef struct peer_s
Expand Down
4 changes: 2 additions & 2 deletions include/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"stat_type", "status", \
"grey_mask", "24", \
"grey_delay", "10", \
"grey_type", "normal", \
"grey_tuple", "user", \
"syslog_facility", "mail", \
"blocker_port", "4466", \
"blocker_weight", "1", \
Expand Down Expand Up @@ -81,7 +81,7 @@
"log_level", \
"grey_mask", \
"grey_delay", \
"grey_type", \
"grey_tuple", \
"check", \
"protocol", \
"syslog_facility", \
Expand Down
6 changes: 3 additions & 3 deletions man/grossd.conf.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ is the way server updates the database. Valid options are
`\s-1STATUS_GREY\s+1'. Setting it to `always' may reduce the impact on
\s-1DNS\s+1 servers.
.IP "\fBgrey_tuple\fP" 4
is the greylisting tuple. Valid options are `normal' and `loose'. If set to
`normal', which is the default, \fIgrossd\fP\|(8) will create the tuple from
is the greylisting tuple. Valid options are `user' and `server'. If set to
`user', which is the default, \fIgrossd\fP\|(8) will create the tuple from
the masked `smtp\-client\-ip', sender email and recipient email. If set to
`loose' it will create the tuple from the masked `smtp\-client\-ip', the sender
`server' it will create the tuple from the masked `smtp\-client\-ip', the sender
email domain and helo message.
.IP "\fBgrey_mask\fP" 4
is the mask for \fIgrossd\fP\|(8) to use when matching the
Expand Down
12 changes: 6 additions & 6 deletions src/gross.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,12 @@ configure_grossd(configlist_t *config)
}

greytuplestr = CONF("grey_tuple");
if (strncmp(greytuplestr, "loose", 6) == 0) {
logstr(GLOG_DEBUG, "grey_tuple: LOOSE");
ctx->config.grey_tuple = GREY_TUPLE_LOOSE;
} else if ((greytuplestr == NULL) || (strncmp(greytuplestr, "normal", 7) == 0)) {
logstr(GLOG_DEBUG, "grey_tuple: NORMAL");
ctx->config.grey_tuple = GREY_TUPLE_NORMAL;
if ((greytuplestr == NULL) || (strcmp(greytuplestr, "user") == 0)) {
logstr(GLOG_DEBUG, "grey_tuple: USER");
ctx->config.grey_tuple = GREY_TUPLE_USER;
} else if (strcmp(greytuplestr, "server") == 0) {
logstr(GLOG_DEBUG, "grey_tuple: SERVER");
ctx->config.grey_tuple = GREY_TUPLE_SERVER;
} else {
daemon_shutdown(EXIT_CONFIG, "Invalid grey_tuple: %s", greytuplestr);
}
Expand Down
4 changes: 2 additions & 2 deletions src/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@ test_tuple(final_status_t *final, grey_tuple_t *request, tmout_action_t *ta)

/* greylist */
switch (ctx->config.grey_tuple) {
case GREY_TUPLE_NORMAL:
case GREY_TUPLE_USER:
snprintf(maskedtuple, MSGSZ, "%s %s %s", chkipstr, request->sender, request->recipient);
break;
case GREY_TUPLE_LOOSE:
case GREY_TUPLE_SERVER:
snprintf(maskedtuple, MSGSZ, "%s %s %s", chkipstr, domain_part(request->sender), request->helo_name);
break;
}
Expand Down

0 comments on commit a14b5a6

Please sign in to comment.