diff options
Diffstat (limited to 'mfd')
-rw-r--r-- | mfd/Makefile.am | 1 | ||||
-rw-r--r-- | mfd/callout.c | 10 | ||||
-rw-r--r-- | mfd/engine.c | 6 | ||||
-rw-r--r-- | mfd/mailfromd.h | 15 | ||||
-rw-r--r-- | mfd/main.c | 55 | ||||
-rw-r--r-- | mfd/savclt.c | 275 | ||||
-rw-r--r-- | mfd/savsrv.c | 14 | ||||
-rw-r--r-- | mfd/srvman.c | 11 | ||||
-rw-r--r-- | mfd/srvman.h | 7 |
9 files changed, 364 insertions, 30 deletions
diff --git a/mfd/Makefile.am b/mfd/Makefile.am index 962c22a0..c68afcff 100644 --- a/mfd/Makefile.am +++ b/mfd/Makefile.am | |||
@@ -72,6 +72,7 @@ mailfromd_SOURCES = \ | |||
72 | pragma.c\ | 72 | pragma.c\ |
73 | prog.c\ | 73 | prog.c\ |
74 | prog.h\ | 74 | prog.h\ |
75 | savclt.c\ | ||
75 | savsrv.c\ | 76 | savsrv.c\ |
76 | srvman.c\ | 77 | srvman.c\ |
77 | srvman.h\ | 78 | srvman.h\ |
diff --git a/mfd/callout.c b/mfd/callout.c index c028838e..acecb26f 100644 --- a/mfd/callout.c +++ b/mfd/callout.c | |||
@@ -129,8 +129,8 @@ smtp_io_free(struct smtp_io_data *iop) | |||
129 | free(iop); | 129 | free(iop); |
130 | } | 130 | } |
131 | 131 | ||
132 | static void | 132 | void |
133 | transcript(struct smtp_io_data *io, char *prefix, const char *msg) | 133 | transcript(const char *id, char *prefix, const char *msg) |
134 | { | 134 | { |
135 | if (do_transcript) { | 135 | if (do_transcript) { |
136 | int len = strlen(msg); | 136 | int len = strlen(msg); |
@@ -141,7 +141,7 @@ transcript(struct smtp_io_data *io, char *prefix, const char *msg) | |||
141 | } | 141 | } |
142 | if (len) | 142 | if (len) |
143 | logmsg(LOG_INFO, "%s: %s %*.*s", | 143 | logmsg(LOG_INFO, "%s: %s %*.*s", |
144 | io->id, | 144 | id, |
145 | prefix, len, len, msg); | 145 | prefix, len, len, msg); |
146 | } | 146 | } |
147 | } | 147 | } |
@@ -216,7 +216,7 @@ smtp_send(struct smtp_io_data *iop, const char *command) | |||
216 | init_timeout_ctl (&tctl, io_timeout); | 216 | init_timeout_ctl (&tctl, io_timeout); |
217 | 217 | ||
218 | iop->reply = NULL; /* Clear reply for logging purposes */ | 218 | iop->reply = NULL; /* Clear reply for logging purposes */ |
219 | transcript(iop, "SEND:", command); | 219 | transcript(iop->id, "SEND:", command); |
220 | do { | 220 | do { |
221 | size_t nb; | 221 | size_t nb; |
222 | int rc; | 222 | int rc; |
@@ -343,7 +343,7 @@ smtp_recv(struct smtp_io_data *iop, enum smtp_timeout to) | |||
343 | int rc = smtp_recvline(iop, to); | 343 | int rc = smtp_recvline(iop, to); |
344 | if (rc) | 344 | if (rc) |
345 | return -1; | 345 | return -1; |
346 | transcript(iop, "RECV:", iop->reply); | 346 | transcript(iop->id, "RECV:", iop->reply); |
347 | code = strtoul(iop->reply, &p, 0); | 347 | code = strtoul(iop->reply, &p, 0); |
348 | if (p - iop->reply != 3 || (*p != '-' && *p != ' ')) { | 348 | if (p - iop->reply != 3 || (*p != '-' && *p != ' ')) { |
349 | mu_error(_("unexpected reply from server: %s"), | 349 | mu_error(_("unexpected reply from server: %s"), |
diff --git a/mfd/engine.c b/mfd/engine.c index e1f2de06..c9741c1b 100644 --- a/mfd/engine.c +++ b/mfd/engine.c | |||
@@ -271,6 +271,7 @@ mfl_smtp_io_callback(void *data, const char *key, const char *value) | |||
271 | set_last_poll_recv(env, value); | 271 | set_last_poll_recv(env, value); |
272 | } | 272 | } |
273 | 273 | ||
274 | |||
274 | /* Method "strict". Verifies whether EMAIL is understood either by | 275 | /* Method "strict". Verifies whether EMAIL is understood either by |
275 | host CLIENT_ADDR or one of MX servers of its domain */ | 276 | host CLIENT_ADDR or one of MX servers of its domain */ |
276 | mf_status | 277 | mf_status |
@@ -299,6 +300,8 @@ method_strict(eval_environ_t env, char *email, char *client_addr, | |||
299 | 300 | ||
300 | if (mf_resolved(rc)) | 301 | if (mf_resolved(rc)) |
301 | cache_insert2(email, client_addr, rc); | 302 | cache_insert2(email, client_addr, rc); |
303 | else if (rc == mf_temp_failure) | ||
304 | schedule_callout(email, ehlo, mailfrom, client_addr); | ||
302 | } else { | 305 | } else { |
303 | set_last_poll_helo(env, ""); | 306 | set_last_poll_helo(env, ""); |
304 | set_last_poll_greeting(env, ""); | 307 | set_last_poll_greeting(env, ""); |
@@ -330,10 +333,13 @@ method_standard(eval_environ_t env, char *email, char *ehlo, char *mailfrom) | |||
330 | smtp_timeout_soft, | 333 | smtp_timeout_soft, |
331 | mfl_smtp_io_callback, | 334 | mfl_smtp_io_callback, |
332 | env); | 335 | env); |
336 | smtp_io_setup_callout(io, email, ehlo, mailfrom); | ||
333 | rc = callout_standard(io); | 337 | rc = callout_standard(io); |
334 | smtp_io_free(io); | 338 | smtp_io_free(io); |
335 | if (mf_resolved(rc)) | 339 | if (mf_resolved(rc)) |
336 | cache_insert(email, rc); | 340 | cache_insert(email, rc); |
341 | else if (rc == mf_temp_failure) | ||
342 | schedule_callout(email, ehlo, mailfrom, NULL); | ||
337 | } else { | 343 | } else { |
338 | set_last_poll_helo(env, ""); | 344 | set_last_poll_helo(env, ""); |
339 | set_last_poll_greeting(env, ""); | 345 | set_last_poll_greeting(env, ""); |
diff --git a/mfd/mailfromd.h b/mfd/mailfromd.h index 5df54636..74cf1079 100644 --- a/mfd/mailfromd.h +++ b/mfd/mailfromd.h | |||
@@ -986,10 +986,6 @@ void milter_settimeout(time_t t); | |||
986 | int xeval(eval_environ_t env, enum smtp_state tag); | 986 | int xeval(eval_environ_t env, enum smtp_state tag); |
987 | 987 | ||
988 | mf_status listens_on (const char *client_addr, int port, time_t timeout); | 988 | mf_status listens_on (const char *client_addr, int port, time_t timeout); |
989 | mf_status check_on_host(eval_environ_t env, char *email, char *client_addr, | ||
990 | char *ehlo, char *mailfrom); | ||
991 | mf_status check_mx_records(eval_environ_t env, char *email, char *client_addr, | ||
992 | char *ehlo, char *mailfrom, int *pcount); | ||
993 | mf_status method_strict(eval_environ_t env, char *email, char *client_addr, | 989 | mf_status method_strict(eval_environ_t env, char *email, char *client_addr, |
994 | char *ehlo, char *mailfrom); | 990 | char *ehlo, char *mailfrom); |
995 | mf_status method_standard(eval_environ_t env, char *email, char *ehlo, | 991 | mf_status method_standard(eval_environ_t env, char *email, char *ehlo, |
@@ -1147,9 +1143,18 @@ mf_status callout_host(struct smtp_io_data *, const char *); | |||
1147 | mf_status callout_mx(struct smtp_io_data *, const char *, int *); | 1143 | mf_status callout_mx(struct smtp_io_data *, const char *, int *); |
1148 | mf_status callout_strict(struct smtp_io_data *, const char *); | 1144 | mf_status callout_strict(struct smtp_io_data *, const char *); |
1149 | mf_status callout_standard(struct smtp_io_data *); | 1145 | mf_status callout_standard(struct smtp_io_data *); |
1150 | 1146 | ||
1147 | void transcript(const char *id, char *prefix, const char *msg); | ||
1148 | |||
1151 | /* savsrv.c */ | 1149 | /* savsrv.c */ |
1152 | int callout_session_server(const char *id, int fd, | 1150 | int callout_session_server(const char *id, int fd, |
1153 | struct sockaddr const *sa, socklen_t len, | 1151 | struct sockaddr const *sa, socklen_t len, |
1154 | void *server_data, void *srvman_data); | 1152 | void *server_data, void *srvman_data); |
1155 | 1153 | ||
1154 | /* savclt.c */ | ||
1155 | void schedule_callout(const char *email, const char *ehlo, | ||
1156 | const char *mailfrom, | ||
1157 | const char *client_addr); | ||
1158 | extern struct sockaddr *callout_server_sa; | ||
1159 | extern socklen_t callout_server_sa_len; | ||
1160 | |||
@@ -70,9 +70,9 @@ int do_trace; /* Enable tracing configuration */ | |||
70 | int mtasim_option; /* mtasim compatibility mode */ | 70 | int mtasim_option; /* mtasim compatibility mode */ |
71 | unsigned optimization_level = 1; /* Optimization level */ | 71 | unsigned optimization_level = 1; /* Optimization level */ |
72 | int log_to_stderr; /* Use stderr for logging */ | 72 | int log_to_stderr; /* Use stderr for logging */ |
73 | int force_remove = 1; /* Remove local communication socket if it already | ||
74 | exists */ | ||
75 | int foreground; /* Stay in foreground */ | 73 | int foreground; /* Stay in foreground */ |
74 | int force_remove; /* Remove local communication socket if it already | ||
75 | exists */ | ||
76 | int single_process_option; /* Run in single process mode. */ | 76 | int single_process_option; /* Run in single process mode. */ |
77 | unsigned long source_address = INADDR_ANY; /* Source address for TCP | 77 | unsigned long source_address = INADDR_ANY; /* Source address for TCP |
78 | connections */ | 78 | connections */ |
@@ -622,7 +622,8 @@ add_legacy_milter_port(const char *str, mu_debug_t dbg) | |||
622 | url = parse_milter_url(dbg, str); | 622 | url = parse_milter_url(dbg, str); |
623 | if (url) { | 623 | if (url) { |
624 | mfd_server_t srv = mfd_server_new(id, url, | 624 | mfd_server_t srv = mfd_server_new(id, url, |
625 | milter_session_server); | 625 | milter_session_server, |
626 | 0); | ||
626 | if (srv) | 627 | if (srv) |
627 | mfd_srvman_attach_server(srv); | 628 | mfd_srvman_attach_server(srv); |
628 | else | 629 | else |
@@ -1381,7 +1382,6 @@ parse_opt(int key, char *arg, struct argp_state *state) | |||
1381 | break; | 1382 | break; |
1382 | 1383 | ||
1383 | case 'r': | 1384 | case 'r': |
1384 | /*FIXME*/ | ||
1385 | force_remove = 1; | 1385 | force_remove = 1; |
1386 | break; | 1386 | break; |
1387 | 1387 | ||
@@ -2099,6 +2099,8 @@ struct server_config_stmt { | |||
2099 | mu_acl_t acl; | 2099 | mu_acl_t acl; |
2100 | size_t max_children; | 2100 | size_t max_children; |
2101 | mfd_server_func_t server; | 2101 | mfd_server_func_t server; |
2102 | int single_process; | ||
2103 | int reuseaddr; | ||
2102 | }; | 2104 | }; |
2103 | 2105 | ||
2104 | static struct server_config_stmt server_config_stmt; | 2106 | static struct server_config_stmt server_config_stmt; |
@@ -2126,6 +2128,12 @@ struct mu_cfg_param server_section_param[] = { | |||
2126 | &server_config_stmt.max_children, 0, | 2128 | &server_config_stmt.max_children, 0, |
2127 | NULL, | 2129 | NULL, |
2128 | N_("Maximum number of instances allowed for this server.") }, | 2130 | N_("Maximum number of instances allowed for this server.") }, |
2131 | { "single-process", mu_cfg_bool, | ||
2132 | &server_config_stmt.single_process, 0, NULL, | ||
2133 | N_("Single-process mode.") }, | ||
2134 | { "reuseaddr", mu_cfg_bool, | ||
2135 | &server_config_stmt.reuseaddr, 0, NULL, | ||
2136 | N_("Reuse existing socket (default).") }, | ||
2129 | { "acl", mu_cfg_section, | 2137 | { "acl", mu_cfg_section, |
2130 | &server_config_stmt.acl }, | 2138 | &server_config_stmt.acl }, |
2131 | { NULL } | 2139 | { NULL } |
@@ -2141,6 +2149,7 @@ server_section_parser(enum mu_cfg_section_stage stage, | |||
2141 | switch (stage) { | 2149 | switch (stage) { |
2142 | case mu_cfg_section_start: | 2150 | case mu_cfg_section_start: |
2143 | memset(&server_config_stmt, 0, sizeof(server_config_stmt)); | 2151 | memset(&server_config_stmt, 0, sizeof(server_config_stmt)); |
2152 | server_config_stmt.reuseaddr = 1; | ||
2144 | if (mu_cfg_assert_value_type (node->label, MU_CFG_STRING, | 2153 | if (mu_cfg_assert_value_type (node->label, MU_CFG_STRING, |
2145 | tree->debug)) | 2154 | tree->debug)) |