Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow relaxed localpart size verification #53

Merged
merged 3 commits into from Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion smf-spf.c
Expand Up @@ -50,6 +50,7 @@
#define QUARANTINE_BOX "postmaster"
#define SYSLOG_FACILITY LOG_MAIL
#define SPF_TTL 3600
#define RELAXED_LOCALPART 0
#define REFUSE_FAIL 1
#define REFUSE_NONE 0
#define REFUSE_NONE_HELO 0
Expand Down Expand Up @@ -135,6 +136,7 @@ typedef struct config {
STR *ptrs;
STR *froms;
STR *tos;
int relaxed_locapart;
int refuse_fail;
int refuse_none;
int refuse_none_helo;
Expand Down Expand Up @@ -377,6 +379,7 @@ static int load_config(void) {
conf.sendmail_socket = strdup(OCONN);
conf.syslog_facility = SYSLOG_FACILITY;
conf.refuse_fail = REFUSE_FAIL;
conf.relaxed_locapart = RELAXED_LOCALPART;
conf.refuse_none = REFUSE_NONE;
conf.refuse_none_helo = REFUSE_NONE_HELO;
conf.soft_fail = SOFT_FAIL;
Expand Down Expand Up @@ -484,6 +487,10 @@ static int load_config(void) {
conf.refuse_none_helo = 1;
continue;
}
if (!strcasecmp(key, "relaxedlocalpart") && !strcasecmp(val, "on")) {
conf.relaxed_locapart= 1;
continue;
}
if (!strcasecmp(key, "refusefail") && !strcasecmp(val, "off")) {
conf.refuse_fail = 0;
continue;
Expand Down Expand Up @@ -634,7 +641,8 @@ static int address_preparation(register char *dst, register const char *src) {
if ((dst[0] >= 0x07 && dst[0] <= 0x0d) || dst[0] == 0x20) return 0;
if ((dst[tail] >= 0x07 && dst[tail] <= 0x0d) || dst[tail] == 0x20) return 0;
local = strchr(start, '@');
if (!local || ((local - start) > MAXLOCALPART)) return 0;
if (!local) return 0;
if (!conf.relaxed_locapart && ((local - start) > MAXLOCALPART)) return 0;
return 1;
}

Expand Down
8 changes: 8 additions & 0 deletions smf-spf.conf
Expand Up @@ -36,6 +36,14 @@ WhitelistIP 192.168.0.0/16
#WhitelistTo @yourspamloverdomain.tld
#WhitelistTo spamlover@yourdomain.tld

# Don't check localpart size. RFC 821/2821/5321 states
# localpart must be less that 64 octects. With relaxed on
# only total mailfrom ( localpart @ domain.tld ) size is checked
#
# Default: off
#
#RelaxedLocalPart off # (on|off)

# Refuse e-Mail messages at SPF None results
# On empty senders this restriction will not be applied
#
Expand Down