aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2005-06-07 12:29:34 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2005-06-07 12:29:34 +0000
commit779e4100bac7952d9586ef587e39de0713719ba2 (patch)
tree8f2304644a00c142872aa5c57b947a2f2ecce459
parente0adf091e2ab1b9af52d63630fc7bc0b6fcb931e (diff)
downloadmailfromd-779e4100bac7952d9586ef587e39de0713719ba2.tar.gz
mailfromd-779e4100bac7952d9586ef587e39de0713719ba2.tar.bz2
(method_fp,method_standard,method_strict): Changed
return type. All callers updated. (check_on_host): Issue EHLO if remote party refuses HELO. git-svn-id: file:///svnroot/mailfromd/trunk@57 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r--src/main.c57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/main.c b/src/main.c
index 5f5019b4..cf110a8f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -67,10 +67,13 @@
/* Verification methods */
-typedef sfsistat (*method_fp)(SMFICTX *ctx, char *email, char *client_addr);
+typedef getmx_status (*method_fp)(SMFICTX *ctx, char *email,
+ char *client_addr);
-static sfsistat method_standard(SMFICTX *ctx, char *email, char *client_addr);
-static sfsistat method_strict(SMFICTX *ctx, char *email, char *client_addr);
+static getmx_status method_standard(SMFICTX *ctx, char *email,
+ char *client_addr);
+static getmx_status method_strict(SMFICTX *ctx, char *email,
+ char *client_addr);
struct method_tab {
char *name;
@@ -724,7 +727,18 @@ check_on_host(SMFICTX *ctx, char *email, char *client_addr)
break;
}
smtp_send2(&io, "HELO ", smtp_domain);
- if (smtp_recv(&io) || SMTP_MAJOR(io.code) != 2) {
+ if (smtp_recv(&io)) {
+ status = getmx_not_found;
+ break;
+ } else if (SMTP_MAJOR(io.code) == 5) {
+ /* Let's try EHLO, then */
+ smtp_send2(&io, "EHLO ", smtp_domain);
+ if (smtp_recv(&io)) {
+ status = getmx_not_found;
+ break;
+ }
+ }
+ if (SMTP_MAJOR(io.code) != 2) {
status = getmx_not_found;
break;
}
@@ -735,7 +749,8 @@ check_on_host(SMFICTX *ctx, char *email, char *client_addr)
}
smtp_send3(&io, "RCPT TO: <", email, ">");
if (smtp_recv(&io)
- || (SMTP_MAJOR(io.code) != 2 && SMTP_MAJOR(io.code) != 4)) {
+ || (SMTP_MAJOR(io.code) != 2
+ && SMTP_MAJOR(io.code) != 4)) {
status = getmx_not_found;
break;
}
@@ -781,7 +796,7 @@ check_mx_records(SMFICTX *ctx, char *email, char *client_addr)
/* Method "strict". Verifies whether EMAIL is understood either by
host CLIENT_ADDR or one of MX servers of its domain */
-sfsistat
+getmx_status
method_strict(SMFICTX *ctx, char *email, char *client_addr)
{
getmx_status rc = cache_get2(email, client_addr);
@@ -793,12 +808,12 @@ method_strict(SMFICTX *ctx, char *email, char *client_addr)
if (getmx_resolved(rc))
cache_insert2(email, client_addr, rc);
}
- return run_action(ctx, rc);
+ return rc;
}
/* Method "standard". Verifies whether EMAIL is understood by
any of its MXs */
-sfsistat
+getmx_status
method_standard(SMFICTX *ctx, char *email, char *client_addr)
{
getmx_status rc = cache_get(email);
@@ -816,7 +831,7 @@ method_standard(SMFICTX *ctx, char *email, char *client_addr)
if (getmx_resolved(rc))
cache_insert(email, rc);
}
- return run_action(ctx, rc);
+ return rc;
}
/* Cleanup functions */
@@ -840,23 +855,21 @@ mlfi_envfrom(SMFICTX *ctx, char **argv)
{
char *mail_addr = smfi_getsymval(ctx, "f");
char *client = smfi_getsymval(ctx, "{client_addr}");
- sfsistat status;
+ getmx_status rc;
if (!mail_addr) {
mu_error("$f is not available. Fix your confMILTER_MACROS_ENVFROM settings");
- return action_failure(ctx, &action_failure_data);
- }
- if (mail_addr[0] == 0)
- return SMFIS_ACCEPT;
- if (!client) {
+ rc = getmx_failure;
+ } else if (mail_addr[0] == 0)
+ rc = getmx_success;
+ else if (!client) {
mu_error("${client_addr} is not available. Fix your confMILTER_MACROS_ENVFROM settings");
- return action_failure(ctx, &action_failure_data);
- }
-
- if (host_in_relayed_domain_p(client))
- return SMFIS_ACCEPT;
-
- return (*method)(ctx, mail_addr, client);
+ rc = getmx_failure;
+ } else if (host_in_relayed_domain_p(client))
+ rc = getmx_success;
+ else
+ rc = (*method)(ctx, mail_addr, client);
+ return run_action(ctx, rc);
}
sfsistat

Return to:

Send suggestions and report system problems to the System administrator.