From: Stephan Bosch Date: Thu, 12 Sep 2019 23:57:18 +0000 (+0200) Subject: lib-smtp: smtp-address - Add raw field to struct smtp_address. X-Git-Tag: 2.3.9~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4be323bdea2f256436187f168e288af2a9d5b124;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-address - Add raw field to struct smtp_address. --- diff --git a/src/lda/main.c b/src/lda/main.c index 63392443c0..7076460db4 100644 --- a/src/lda/main.c +++ b/src/lda/main.c @@ -33,7 +33,7 @@ #include const struct smtp_address default_envelope_sender = { - "MAILER-DAEMON", NULL + .localpart = "MAILER-DAEMON", }; /* After buffer grows larger than this, create a temporary file to /tmp diff --git a/src/lib-smtp/smtp-address.h b/src/lib-smtp/smtp-address.h index d3cb224933..03c914f0fa 100644 --- a/src/lib-smtp/smtp-address.h +++ b/src/lib-smtp/smtp-address.h @@ -24,8 +24,17 @@ enum smtp_address_parse_flags { }; struct smtp_address { + /* Localpart */ const char *localpart; + /* Domain */ const char *domain; + /* Raw, unparsed address. If localpart == NULL, the value of this field + is syntactically invalid and MUST NOT be used for any purposes that + may be visible to external systems. It can be e.g. used for logging. + This is always in mailbox format, meaning that there are no + surrounding '<' and '>'. + */ + const char *raw; }; ARRAY_DEFINE_TYPE(smtp_address, struct smtp_address *); diff --git a/src/lib-smtp/test-smtp-client-errors.c b/src/lib-smtp/test-smtp-client-errors.c index f3c28d2279..db0a43987e 100644 --- a/src/lib-smtp/test-smtp-client-errors.c +++ b/src/lib-smtp/test-smtp-client-errors.c @@ -743,12 +743,14 @@ test_client_broken_payload( SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0], SMTP_CLIENT_SSL_MODE_NONE, NULL); strans = smtp_client_transaction_create(sconn, - &((struct smtp_address){"sender", "example.com"}), NULL, 0, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"}), NULL, 0, test_client_broken_payload_finished, NULL); smtp_client_connection_unref(&sconn); smtp_client_transaction_add_rcpt(strans, - &((struct smtp_address){"rcpt", "example.com"}), NULL, + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"}), NULL, test_client_broken_payload_rcpt_to_cb, test_client_broken_payload_rcpt_data_cb, NULL); smtp_client_transaction_send(strans, input, @@ -802,12 +804,14 @@ test_client_broken_payload_later( SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0], SMTP_CLIENT_SSL_MODE_NONE, NULL); strans = smtp_client_transaction_create(sconn, - &((struct smtp_address){"sender", "example.com"}), NULL, 0, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"}), NULL, 0, test_client_broken_payload_finished, NULL); smtp_client_connection_unref(&sconn); smtp_client_transaction_add_rcpt(strans, - &((struct smtp_address){"rcpt", "example.com"}), NULL, + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"}), NULL, test_client_broken_payload_rcpt_to_cb, test_client_broken_payload_rcpt_data_cb, NULL); smtp_client_transaction_send @@ -1026,12 +1030,14 @@ test_client_connection_lost_submit(struct _connection_lost *ctx, SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index], SMTP_CLIENT_SSL_MODE_NONE, NULL); strans = smtp_client_transaction_create(sconn, - &((struct smtp_address){"sender", "example.com"}), NULL, 0, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"}), NULL, 0, test_client_connection_lost_finished, pctx); smtp_client_connection_unref(&sconn); smtp_client_transaction_add_rcpt(strans, - &((struct smtp_address){"rcpt", "example.com"}), NULL, + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"}), NULL, test_client_connection_lost_rcpt_to_cb, test_client_connection_lost_rcpt_data_cb, pctx); smtp_client_transaction_send @@ -1339,7 +1345,8 @@ test_client_unexpected_reply_submit1(struct _unexpected_reply_peer *pctx) timeout_remove(&pctx->to); smtp_client_transaction_add_rcpt(pctx->trans, - &((struct smtp_address){"rcpt", "example.com"}), NULL, + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"}), NULL, test_client_unexpected_reply_rcpt_to_cb, test_client_unexpected_reply_rcpt_data_cb, pctx); @@ -1361,7 +1368,8 @@ test_client_unexpected_reply_submit(struct _unexpected_reply *ctx, SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index], SMTP_CLIENT_SSL_MODE_NONE, NULL); pctx->trans = smtp_client_transaction_create(pctx->conn, - &((struct smtp_address){"sender", "example.com"}), NULL, 0, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"}), NULL, 0, test_client_unexpected_reply_finished, pctx); smtp_client_connection_connect(pctx->conn, test_client_unexpected_reply_login_cb, (void *)pctx); @@ -1800,7 +1808,8 @@ test_client_premature_reply_submit2(struct _premature_reply_peer *pctx) i_debug("SUBMIT2[%u]", pctx->index); smtp_client_transaction_add_rcpt(pctx->trans, - &((struct smtp_address){"rcpt", "example.com"}), NULL, + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"}), NULL, test_client_premature_reply_rcpt_to_cb, test_client_premature_reply_rcpt_data_cb, pctx); @@ -1839,7 +1848,8 @@ test_client_premature_reply_submit(struct _premature_reply *ctx, SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index], SMTP_CLIENT_SSL_MODE_NONE, NULL); pctx->trans = smtp_client_transaction_create(conn, - &((struct smtp_address){"sender", "example.com"}), NULL, 0, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"}), NULL, 0, test_client_premature_reply_finished, pctx); smtp_client_connection_connect(conn, test_client_premature_reply_login_cb, (void *)pctx); @@ -2124,10 +2134,12 @@ test_client_early_data_reply_submit(struct _early_data_reply *ctx, test_client_early_data_reply_login_cb, (void *)pctx); pctx->trans = smtp_client_transaction_create(conn, - &((struct smtp_address){"sender", "example.com"}), NULL, 0, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"}), NULL, 0, test_client_early_data_reply_finished, pctx); smtp_client_transaction_add_rcpt(pctx->trans, - &((struct smtp_address){"rcpt", "example.com"}), NULL, + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"}), NULL, test_client_early_data_reply_rcpt_to_cb, test_client_early_data_reply_rcpt_data_cb, pctx); smtp_client_transaction_start(pctx->trans, @@ -3152,7 +3164,8 @@ test_client_authentication_failed_submit(struct _authentication_failed *ctx, SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index], SMTP_CLIENT_SSL_MODE_NONE, &smtp_set); pctx->trans = smtp_client_transaction_create(pctx->conn, - &((struct smtp_address){"sender", "example.com"}), NULL, 0, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"}), NULL, 0, test_client_authentication_failed_finished, pctx); smtp_client_connection_connect(pctx->conn, test_client_authentication_failed_login_cb, (void *)pctx); @@ -3161,7 +3174,8 @@ test_client_authentication_failed_submit(struct _authentication_failed *ctx, smtp_client_connection_unref(&pctx->conn); smtp_client_transaction_add_rcpt(pctx->trans, - &((struct smtp_address){"rcpt", "example.com"}), NULL, + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"}), NULL, test_client_authentication_failed_rcpt_to_cb, test_client_authentication_failed_rcpt_data_cb, pctx); @@ -3403,7 +3417,8 @@ test_client_transaction_timeout_submit1(struct _transaction_timeout_peer *pctx) timeout_remove(&pctx->to); smtp_client_transaction_add_rcpt(pctx->trans, - &((struct smtp_address){"rcpt", "example.com"}), NULL, + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"}), NULL, test_client_transaction_timeout_rcpt_to_cb, test_client_transaction_timeout_rcpt_data_cb, pctx); @@ -3425,7 +3440,8 @@ test_client_transaction_timeout_submit(struct _transaction_timeout *ctx, SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index], SMTP_CLIENT_SSL_MODE_NONE, NULL); pctx->trans = smtp_client_transaction_create(pctx->conn, - &((struct smtp_address){"sender", "example.com"}), NULL, 0, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"}), NULL, 0, test_client_transaction_timeout_finished, pctx); smtp_client_transaction_set_timeout(pctx->trans, 1000); smtp_client_transaction_start(pctx->trans, diff --git a/src/lib-smtp/test-smtp-payload.c b/src/lib-smtp/test-smtp-payload.c index d9e7733978..72a8464a61 100644 --- a/src/lib-smtp/test-smtp-payload.c +++ b/src/lib-smtp/test-smtp-payload.c @@ -754,7 +754,8 @@ static void test_client_continue(void *dummy ATTR_UNUSED) tctrans->conn->trans = smtp_client_transaction_create( tctrans->conn->conn, - &((struct smtp_address){"user", "example.com"}), + &((struct smtp_address){.localpart = "user", + .domain = "example.com"}), &mail_params, 0, test_client_transaction_finish, tctrans); diff --git a/src/lib-smtp/test-smtp-submit.c b/src/lib-smtp/test-smtp-submit.c index 6165be5eab..5ddf97194d 100644 --- a/src/lib-smtp/test-smtp-submit.c +++ b/src/lib-smtp/test-smtp-submit.c @@ -760,13 +760,17 @@ test_client_denied_second_rcpt(const struct smtp_submit_settings *submit_set) smtp_submit_set.submission_timeout = 1000; i_zero(&smtp_input); - smtp_submit = smtp_submit_init_simple(&smtp_input, &smtp_submit_set, - &((struct smtp_address){"sender", "example.com"})); + smtp_submit = smtp_submit_init_simple( + &smtp_input, &smtp_submit_set, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit, - &((struct smtp_address){"rcpt", "example.com"})); + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit, - &((struct smtp_address){"rcpt2", "example.com"})); + &((struct smtp_address){.localpart = "rcpt2", + .domain = "example.com"})); output = smtp_submit_send(smtp_submit); o_stream_nsend_str(output, test_message1); @@ -1475,11 +1479,14 @@ test_client_parallel_delivery(const struct smtp_submit_settings *submit_set) i_zero(&smtp_input); smtp_submit_set.submission_host = t_strdup_printf("127.0.0.1:%u", bind_ports[0]); - smtp_submit1 = smtp_submit_init_simple(&smtp_input, &smtp_submit_set, - &((struct smtp_address){"sender", "example.com"})); + smtp_submit1 = smtp_submit_init_simple( + &smtp_input, &smtp_submit_set, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit1, - &((struct smtp_address){"rcpt", "example.com"})); + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"})); output = smtp_submit_send(smtp_submit1); o_stream_nsend_str(output, test_message1); @@ -1491,10 +1498,12 @@ test_client_parallel_delivery(const struct smtp_submit_settings *submit_set) smtp_submit_set.submission_host = t_strdup_printf("127.0.0.1:%u", bind_ports[1]); smtp_submit2 = smtp_submit_init_simple(&smtp_input, &smtp_submit_set, - &((struct smtp_address){"sender", "example.com"})); + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit2, - &((struct smtp_address){"rcpt", "example.com"})); + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"})); output = smtp_submit_send(smtp_submit2); o_stream_nsend_str(output, test_message2); @@ -1567,10 +1576,12 @@ test_client_failed_sendmail(const struct smtp_submit_settings *submit_set) i_zero(&smtp_input); smtp_submit = smtp_submit_init_simple(&smtp_input, &smtp_submit_set, - &((struct smtp_address){"sender", "example.com"})); + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit, - &((struct smtp_address){"rcpt", "example.com"})); + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"})); output = smtp_submit_send(smtp_submit); o_stream_nsend_str(output, test_message1); @@ -1624,10 +1635,12 @@ test_client_successful_sendmail(const struct smtp_submit_settings *submit_set) i_zero(&smtp_input); smtp_submit = smtp_submit_init_simple(&smtp_input, &smtp_submit_set, - &((struct smtp_address){"sender", "example.com"})); + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit, - &((struct smtp_address){"rcpt", "example.com"})); + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"})); output = smtp_submit_send(smtp_submit); o_stream_nsend_str(output, test_message1); @@ -1709,11 +1722,14 @@ test_client_parallel_sendmail(const struct smtp_submit_settings *submit_set) /* submit 1 */ i_zero(&smtp_input); smtp_submit_set.sendmail_path = sendmail_path1; - smtp_submit1 = smtp_submit_init_simple(&smtp_input, &smtp_submit_set, - &((struct smtp_address){"sender", "example.com"})); + smtp_submit1 = smtp_submit_init_simple( + &smtp_input, &smtp_submit_set, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit1, - &((struct smtp_address){"rcpt", "example.com"})); + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"})); output = smtp_submit_send(smtp_submit1); o_stream_nsend_str(output, test_message1); @@ -1723,11 +1739,14 @@ test_client_parallel_sendmail(const struct smtp_submit_settings *submit_set) /* submit 2 */ i_zero(&smtp_input); smtp_submit_set.sendmail_path = sendmail_path2; - smtp_submit2 = smtp_submit_init_simple(&smtp_input, &smtp_submit_set, - &((struct smtp_address){"sender", "example.com"})); + smtp_submit2 = smtp_submit_init_simple( + &smtp_input, &smtp_submit_set, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit2, - &((struct smtp_address){"rcpt", "example.com"})); + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"})); output = smtp_submit_send(smtp_submit2); o_stream_nsend_str(output, test_message2); @@ -1823,11 +1842,14 @@ test_client_smtp_send_simple(const struct smtp_submit_settings *smtp_set, smtp_submit_set.submission_host = host, i_zero(&smtp_input); - smtp_submit = smtp_submit_init_simple(&smtp_input, &smtp_submit_set, - &((struct smtp_address){"sender", "example.com"})); + smtp_submit = smtp_submit_init_simple( + &smtp_input, &smtp_submit_set, + &((struct smtp_address){.localpart = "sender", + .domain = "example.com"})); smtp_submit_add_rcpt(smtp_submit, - &((struct smtp_address){"rcpt", "example.com"})); + &((struct smtp_address){.localpart = "rcpt", + .domain = "example.com"})); output = smtp_submit_send(smtp_submit); o_stream_nsend_str(output, message);