diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-10-06 09:28:56 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-10-06 09:28:56 +0000 |
commit | 51f9de1f4d6f821a9c284086633306a7ea8d4bbc (patch) | |
tree | e9e52dc3c9864ce162fcd75ad285466b5a77280e /src/main.c | |
parent | 2e874899b60e3561cd013ff4a40cb697e03a7ebb (diff) | |
download | mailfromd-51f9de1f4d6f821a9c284086633306a7ea8d4bbc.tar.gz mailfromd-51f9de1f4d6f821a9c284086633306a7ea8d4bbc.tar.bz2 |
(smtp_send): Clear reply before proceeding
(smtp_last_sent,smtp_last_received): Return literal "nothing" if
nothing was sent/received.
(check_mx_records,method_strict)
(method_standard): Change first argument type to eval_environ_t
(check_on_host): Change first argument type to eval_environ_t.
Return last polled host, sent command and received reply in
variables last_poll_host, last_poll_send and last_poll_recv.
git-svn-id: file:///svnroot/mailfromd/trunk@601 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -512,6 +512,7 @@ smtp_send(struct smtp_io_data *dat, char *command) int attempt = 0; size_t len = strlen(command); + dat->reply = NULL; /* Clear reply for logging purposes */ transcript(dat, "SEND:", command); do { size_t nb; @@ -668,7 +669,7 @@ smtp_last_sent(struct smtp_io_data *dat) dat->command[len] = 0; return dat->command; } - return ""; + return "nothing"; } const char * @@ -679,7 +680,7 @@ smtp_last_received(struct smtp_io_data *dat) dat->reply[len] = 0; return dat->reply; } - return dat->reply ? dat->reply : ""; + return dat->reply ? dat->reply : "nothing"; } @@ -688,7 +689,7 @@ smtp_last_received(struct smtp_io_data *dat) /* Verify whether EMAIL address is served by host CLIENT_ADDR. */ mf_status -check_on_host(SMFICTX *ctx, char *email, char *client_addr, +check_on_host(eval_environ_t env, char *email, char *client_addr, char *ehlo, char *mailfrom) { int rc; @@ -696,7 +697,8 @@ check_on_host(SMFICTX *ctx, char *email, char *client_addr, struct smtp_io_data io; mf_status status = mf_success; int count = 0; - + SMFICTX *ctx = env_get_context(env); + debug2(10, "email = %s, client_addr = %s", email, client_addr); rc = mu_tcp_stream_create_with_source_ip (&stream, client_addr, 25, source_address, @@ -775,6 +777,11 @@ check_on_host(SMFICTX *ctx, char *email, char *client_addr, } } while (0); + set_last_poll_result(env, + client_addr, + smtp_last_sent(&io), + smtp_last_received(&io)); + debug4(1, "%spoll exited with status: %s; sent \"%s\", got \"%s\"", mailfromd_msgid(ctx), @@ -790,7 +797,7 @@ check_on_host(SMFICTX *ctx, char *email, char *client_addr, } mf_status -check_mx_records(SMFICTX *ctx, char *email, char *client_addr, +check_mx_records(eval_environ_t env, char *email, char *client_addr, char *ehlo, char *mailfrom) { int i; @@ -811,7 +818,7 @@ check_mx_records(SMFICTX *ctx, char *email, char *client_addr, debug1(2,"Checking MX servers for %s", email); rc = mf_not_found; for (i = 0; i < MAXMXCOUNT && mxbuf[i]; i++) { - rc = check_on_host(ctx, email, mxbuf[i], + rc = check_on_host(env, email, mxbuf[i], ehlo, mailfrom); if (mf_resolved(rc)) break; @@ -828,7 +835,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 */ mf_status -method_strict(SMFICTX *ctx, char *email, char *client_addr, +method_strict(eval_environ_t env, char *email, char *client_addr, char *ehlo, char *mailfrom) { mf_status rc = cache_get2(email, client_addr); @@ -837,10 +844,10 @@ method_strict(SMFICTX *ctx, char *email, char *client_addr, return mf_success; if (!mf_resolved(rc)) { - rc = check_on_host(ctx, email, client_addr, ehlo, mailfrom); + rc = check_on_host(env, email, client_addr, ehlo, mailfrom); if (!mf_resolved(rc)) { mf_status mx_stat; - mx_stat = check_mx_records(ctx, email, client_addr, + mx_stat = check_mx_records(env, email, client_addr, ehlo, mailfrom); if (mf_resolved(mx_stat) || mx_stat == mf_temp_failure) @@ -855,7 +862,7 @@ method_strict(SMFICTX *ctx, char *email, char *client_addr, /* Method "standard". Verifies whether EMAIL is understood by any of its MXs */ mf_status -method_standard(SMFICTX *ctx, char *email, char *ehlo, char *mailfrom) +method_standard(eval_environ_t env, char *email, char *ehlo, char *mailfrom) { mf_status rc = cache_get(email); @@ -867,10 +874,10 @@ method_standard(SMFICTX *ctx, char *email, char *ehlo, char *mailfrom) mu_error("Invalid address: %s", email); rc = mf_not_found; } else { - rc = check_mx_records(ctx, email, p+1, ehlo, mailfrom); + rc = check_mx_records(env, email, p+1, ehlo, mailfrom); if (rc != mf_success) { mf_status host_stat; - host_stat = check_on_host(ctx, email, p+1, + host_stat = check_on_host(env, email, p+1, ehlo, mailfrom); if (mf_resolved(host_stat) || host_stat == mf_temp_failure) @@ -898,7 +905,8 @@ listens_on (const char *client_addr, int port) source_address, MU_STREAM_NONBLOCK); if (rc) { - debug1 (10, "mu_tcp_stream_create_with_source_ip: %s", mu_strerror (rc)); + debug1 (10, "mu_tcp_stream_create_with_source_ip: %s", + mu_strerror (rc)); return mf_failure; } |