From: Wietse Venema Date: Wed, 3 May 2000 00:00:00 +0000 (+0000) Subject: snapshot-20000503 X-Git-Tag: v20010228~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17e2c5a67a6ab93984ba0454990b48ae8535bf96;p=thirdparty%2Fpostfix.git snapshot-20000503 --- diff --git a/postfix/.indent.pro b/postfix/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/.indent.pro +++ b/postfix/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/HISTORY b/postfix/HISTORY index 3c10bba81..055ee7b09 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -3833,3 +3833,49 @@ Apologies for any names omitted. Bugfix: removed the () from the tokenized representation of RFC 822 comments, so that comments with \( or \) can be unparsed correctly. Problem reported by Bodo Moeller. + +20000423 + + Bugfix: mail_copy() could prepend > or . in the middle of + long lines. Found by code inspection. + +20000427 + + New code: unescape module that translates C escape sequences + into their equivalent character values. File: util/unescape.c. + + Feature: the pipe mailer now has a way to specify the output + record delimiter (for example, eol=\r\n). This is necessary + for transports that require CRLF instead of UNIX-style LF. + +20000428 + + New code: added support to the vstring module for fixed-size + buffers. This may help to avoid clumsy code that would have + to prevent memory leaks. The buffers cause a fatal error + when they turn out too small. File: util/vstring.[hc]. + +20000502 + + In order to support timeouts with SSL more conveniently, + VSTREAMs now have built into them the concept of timeout. + Instead of calling read() and write(), the low-level VSTREAM + interface now uses timed_read() and timed_write() which + have an additional timeout parameter; vstream_ctl(stream, + VSTREAM_CTL_TIMEOUT) sets the timeout deadline on a stream, + and vstream_ftimeout(stream) queries a stream for timeout + errors. This change simplified timeout handling considerably. + Files: util/vbuf.h, util/vstrean.[hc], global/smtp_stream.c, + global/timed_ipc.c. + +20000504 + + In order to support application-specific state, VSTREAMs + now provide an optional open attribute list. An example is + the per-stream jump buffer that was needed in order to + clean up the smtp_stream module. Files: util/vstream.[hc], + util/binattr.[hc]. + + Cleaned up the smtp_stream module further and got rid of + the global state that limited the use of this module to + one stream per process. Files: global/smtp_stream.[hc]. diff --git a/postfix/base64/.indent.pro b/postfix/base64/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/base64/.indent.pro +++ b/postfix/base64/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/base64/base64encode.c b/postfix/base64/base64encode.c index 3b2138a03..73ee0dc11 100644 --- a/postfix/base64/base64encode.c +++ b/postfix/base64/base64encode.c @@ -36,7 +36,6 @@ static VSTRING *unescape(VSTRING *unescaped, VSTRING *input) while ((ch = *UCHAR(cp++)) != 0) { switch (ch) { case '\\': - oval = 0; for (oval = 0, i = 0; i < 3 && (ch = *UCHAR(cp)) != 0; i++) { if (!ISDIGIT(ch) || ch == '8' || ch == '9') break; diff --git a/postfix/bounce/.indent.pro b/postfix/bounce/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/bounce/.indent.pro +++ b/postfix/bounce/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/bounce/Makefile.in b/postfix/bounce/Makefile.in index 1298eee45..4922ed1e7 100644 --- a/postfix/bounce/Makefile.in +++ b/postfix/bounce/Makefile.in @@ -62,6 +62,7 @@ bounce.o: ../include/msg.h bounce.o: ../include/vstring.h bounce.o: ../include/vbuf.h bounce.o: ../include/vstream.h +bounce.o: ../include/binattr.h bounce.o: ../include/stringops.h bounce.o: ../include/mail_proto.h bounce.o: ../include/iostuff.h @@ -77,6 +78,7 @@ bounce_append_service.o: ../include/msg.h bounce_append_service.o: ../include/vstring.h bounce_append_service.o: ../include/vbuf.h bounce_append_service.o: ../include/vstream.h +bounce_append_service.o: ../include/binattr.h bounce_append_service.o: ../include/stringops.h bounce_append_service.o: ../include/mail_queue.h bounce_append_service.o: ../include/quote_822_local.h @@ -90,6 +92,7 @@ bounce_cleanup.o: ../include/vstring.h bounce_cleanup.o: ../include/vbuf.h bounce_cleanup.o: ../include/mail_queue.h bounce_cleanup.o: ../include/vstream.h +bounce_cleanup.o: ../include/binattr.h bounce_cleanup.o: bounce_service.h bounce_notify_service.o: bounce_notify_service.c bounce_notify_service.o: ../include/sys_defs.h @@ -97,6 +100,7 @@ bounce_notify_service.o: ../include/msg.h bounce_notify_service.o: ../include/vstring.h bounce_notify_service.o: ../include/vbuf.h bounce_notify_service.o: ../include/vstream.h +bounce_notify_service.o: ../include/binattr.h bounce_notify_service.o: ../include/vstring_vstream.h bounce_notify_service.o: ../include/mymalloc.h bounce_notify_service.o: ../include/stringops.h @@ -125,6 +129,7 @@ bounce_recip_service.o: ../include/msg.h bounce_recip_service.o: ../include/vstring.h bounce_recip_service.o: ../include/vbuf.h bounce_recip_service.o: ../include/vstream.h +bounce_recip_service.o: ../include/binattr.h bounce_recip_service.o: ../include/vstring_vstream.h bounce_recip_service.o: ../include/mymalloc.h bounce_recip_service.o: ../include/stringops.h diff --git a/postfix/cleanup/.indent.pro b/postfix/cleanup/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/cleanup/.indent.pro +++ b/postfix/cleanup/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/cleanup/Makefile.in b/postfix/cleanup/Makefile.in index 8b1da52c8..5c632a5f9 100644 --- a/postfix/cleanup/Makefile.in +++ b/postfix/cleanup/Makefile.in @@ -67,6 +67,7 @@ cleanup.o: ../include/vstring.h cleanup.o: ../include/vbuf.h cleanup.o: ../include/dict.h cleanup.o: ../include/vstream.h +cleanup.o: ../include/binattr.h cleanup.o: ../include/argv.h cleanup.o: ../include/mail_conf.h cleanup.o: ../include/cleanup_user.h @@ -91,6 +92,7 @@ cleanup_api.o: ../include/mymalloc.h cleanup_api.o: ../include/cleanup_user.h cleanup_api.o: ../include/mail_queue.h cleanup_api.o: ../include/vstream.h +cleanup_api.o: ../include/binattr.h cleanup_api.o: ../include/mail_proto.h cleanup_api.o: ../include/iostuff.h cleanup_api.o: ../include/bounce.h @@ -110,6 +112,7 @@ cleanup_envelope.o: ../include/msg.h cleanup_envelope.o: ../include/vstring.h cleanup_envelope.o: ../include/vbuf.h cleanup_envelope.o: ../include/vstream.h +cleanup_envelope.o: ../include/binattr.h cleanup_envelope.o: ../include/mymalloc.h cleanup_envelope.o: ../include/record.h cleanup_envelope.o: ../include/rec_type.h @@ -131,6 +134,7 @@ cleanup_extracted.o: ../include/msg.h cleanup_extracted.o: ../include/vstring.h cleanup_extracted.o: ../include/vbuf.h cleanup_extracted.o: ../include/vstream.h +cleanup_extracted.o: ../include/binattr.h cleanup_extracted.o: ../include/argv.h cleanup_extracted.o: ../include/mymalloc.h cleanup_extracted.o: ../include/cleanup_user.h @@ -157,6 +161,7 @@ cleanup_init.o: cleanup.h cleanup_init.o: ../include/vstring.h cleanup_init.o: ../include/vbuf.h cleanup_init.o: ../include/vstream.h +cleanup_init.o: ../include/binattr.h cleanup_init.o: ../include/argv.h cleanup_init.o: ../include/maps.h cleanup_init.o: ../include/dict.h @@ -172,6 +177,7 @@ cleanup_map11.o: ../include/vstring.h cleanup_map11.o: ../include/vbuf.h cleanup_map11.o: ../include/dict.h cleanup_map11.o: ../include/vstream.h +cleanup_map11.o: ../include/binattr.h cleanup_map11.o: ../include/argv.h cleanup_map11.o: ../include/mymalloc.h cleanup_map11.o: ../include/cleanup_user.h @@ -193,6 +199,7 @@ cleanup_map1n.o: ../include/vstring.h cleanup_map1n.o: ../include/vbuf.h cleanup_map1n.o: ../include/dict.h cleanup_map1n.o: ../include/vstream.h +cleanup_map1n.o: ../include/binattr.h cleanup_map1n.o: ../include/mail_addr_map.h cleanup_map1n.o: ../include/maps.h cleanup_map1n.o: ../include/cleanup_user.h @@ -218,6 +225,7 @@ cleanup_masquerade.o: ../include/resolve_clnt.h cleanup_masquerade.o: ../include/quote_822_local.h cleanup_masquerade.o: cleanup.h cleanup_masquerade.o: ../include/vstream.h +cleanup_masquerade.o: ../include/binattr.h cleanup_masquerade.o: ../include/maps.h cleanup_masquerade.o: ../include/dict.h cleanup_masquerade.o: ../include/been_here.h @@ -229,6 +237,7 @@ cleanup_message.o: ../include/msg.h cleanup_message.o: ../include/vstring.h cleanup_message.o: ../include/vbuf.h cleanup_message.o: ../include/vstream.h +cleanup_message.o: ../include/binattr.h cleanup_message.o: ../include/argv.h cleanup_message.o: ../include/split_at.h cleanup_message.o: ../include/mymalloc.h @@ -256,6 +265,7 @@ cleanup_out.o: ../include/msg.h cleanup_out.o: ../include/vstring.h cleanup_out.o: ../include/vbuf.h cleanup_out.o: ../include/vstream.h +cleanup_out.o: ../include/binattr.h cleanup_out.o: ../include/record.h cleanup_out.o: ../include/rec_type.h cleanup_out.o: ../include/cleanup_user.h @@ -279,6 +289,7 @@ cleanup_out_recipient.o: cleanup.h cleanup_out_recipient.o: ../include/vstring.h cleanup_out_recipient.o: ../include/vbuf.h cleanup_out_recipient.o: ../include/vstream.h +cleanup_out_recipient.o: ../include/binattr.h cleanup_out_recipient.o: ../include/maps.h cleanup_out_recipient.o: ../include/dict.h cleanup_out_recipient.o: ../include/tok822.h @@ -296,6 +307,7 @@ cleanup_rewrite.o: ../include/rewrite_clnt.h cleanup_rewrite.o: ../include/quote_822_local.h cleanup_rewrite.o: cleanup.h cleanup_rewrite.o: ../include/vstream.h +cleanup_rewrite.o: ../include/binattr.h cleanup_rewrite.o: ../include/argv.h cleanup_rewrite.o: ../include/maps.h cleanup_rewrite.o: ../include/dict.h @@ -312,6 +324,7 @@ cleanup_state.o: ../include/been_here.h cleanup_state.o: ../include/mail_params.h cleanup_state.o: cleanup.h cleanup_state.o: ../include/vstream.h +cleanup_state.o: ../include/binattr.h cleanup_state.o: ../include/maps.h cleanup_state.o: ../include/dict.h cleanup_state.o: ../include/tok822.h diff --git a/postfix/cleanup/cleanup_message.c b/postfix/cleanup/cleanup_message.c index 678612544..c29808f00 100644 --- a/postfix/cleanup/cleanup_message.c +++ b/postfix/cleanup/cleanup_message.c @@ -379,7 +379,8 @@ static void cleanup_missing_headers(CLEANUP_STATE *state) /* * Add a missing destination header. */ -#define VISIBLE_RCPT (HDR_TO | HDR_RESENT_TO | HDR_CC | HDR_RESENT_CC) +#define VISIBLE_RCPT ((1 << HDR_TO) | (1 << HDR_RESENT_TO) \ + | (1 << HDR_CC) | (1 << HDR_RESENT_CC)) if ((state->headers_seen & VISIBLE_RCPT) == 0) cleanup_out_format(state, REC_TYPE_NORM, "%s", var_rcpt_witheld); diff --git a/postfix/dns/.indent.pro b/postfix/dns/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/dns/.indent.pro +++ b/postfix/dns/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/dns/Makefile.in b/postfix/dns/Makefile.in index 245fc77ee..b628a4ca3 100644 --- a/postfix/dns/Makefile.in +++ b/postfix/dns/Makefile.in @@ -101,4 +101,5 @@ test_dns_lookup.o: ../include/vbuf.h test_dns_lookup.o: ../include/msg.h test_dns_lookup.o: ../include/msg_vstream.h test_dns_lookup.o: ../include/vstream.h +test_dns_lookup.o: ../include/binattr.h test_dns_lookup.o: dns.h diff --git a/postfix/error/.indent.pro b/postfix/error/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/error/.indent.pro +++ b/postfix/error/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/error/Makefile.in b/postfix/error/Makefile.in index 7d43663d0..86b2e3108 100644 --- a/postfix/error/Makefile.in +++ b/postfix/error/Makefile.in @@ -58,6 +58,7 @@ error.o: ../include/sys_defs.h error.o: ../include/msg.h error.o: ../include/vstream.h error.o: ../include/vbuf.h +error.o: ../include/binattr.h error.o: ../include/deliver_request.h error.o: ../include/vstring.h error.o: ../include/recipient_list.h diff --git a/postfix/fsstone/.indent.pro b/postfix/fsstone/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/fsstone/.indent.pro +++ b/postfix/fsstone/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/global/.indent.pro b/postfix/global/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/global/.indent.pro +++ b/postfix/global/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/global/Makefile.in b/postfix/global/Makefile.in index 724159e88..9f904dcba 100644 --- a/postfix/global/Makefile.in +++ b/postfix/global/Makefile.in @@ -243,6 +243,7 @@ bounce.o: ../include/vbuf.h bounce.o: mail_params.h bounce.o: mail_proto.h bounce.o: ../include/vstream.h +bounce.o: ../include/binattr.h bounce.o: ../include/iostuff.h bounce.o: defer.h bounce.o: bounce.h @@ -264,6 +265,7 @@ clnt_stream.o: ../include/msg.h clnt_stream.o: ../include/mymalloc.h clnt_stream.o: ../include/vstream.h clnt_stream.o: ../include/vbuf.h +clnt_stream.o: ../include/binattr.h clnt_stream.o: ../include/events.h clnt_stream.o: ../include/iostuff.h clnt_stream.o: mail_proto.h @@ -288,6 +290,7 @@ defer.o: ../include/vstring.h defer.o: ../include/vbuf.h defer.o: mail_queue.h defer.o: ../include/vstream.h +defer.o: ../include/binattr.h defer.o: mail_proto.h defer.o: ../include/iostuff.h defer.o: bounce.h @@ -297,6 +300,7 @@ deliver_completed.o: ../include/sys_defs.h deliver_completed.o: ../include/msg.h deliver_completed.o: ../include/vstream.h deliver_completed.o: ../include/vbuf.h +deliver_completed.o: ../include/binattr.h deliver_completed.o: record.h deliver_completed.o: ../include/vstring.h deliver_completed.o: rec_type.h @@ -314,6 +318,7 @@ deliver_pass.o: ../include/msg.h deliver_pass.o: ../include/vstring.h deliver_pass.o: ../include/vbuf.h deliver_pass.o: ../include/vstream.h +deliver_pass.o: ../include/binattr.h deliver_pass.o: deliver_pass.h deliver_pass.o: deliver_request.h deliver_pass.o: recipient_list.h @@ -324,6 +329,7 @@ deliver_request.o: ../include/sys_defs.h deliver_request.o: ../include/msg.h deliver_request.o: ../include/vstream.h deliver_request.o: ../include/vbuf.h +deliver_request.o: ../include/binattr.h deliver_request.o: ../include/vstring.h deliver_request.o: ../include/mymalloc.h deliver_request.o: ../include/iostuff.h @@ -384,6 +390,8 @@ local_transport.o: local_transport.h mail_addr.o: mail_addr.c mail_addr.o: ../include/sys_defs.h mail_addr.o: ../include/stringops.h +mail_addr.o: ../include/vstring.h +mail_addr.o: ../include/vbuf.h mail_addr.o: mail_params.h mail_addr.o: mail_addr.h mail_addr_crunch.o: mail_addr_crunch.c @@ -402,10 +410,11 @@ mail_addr_find.o: ../include/msg.h mail_addr_find.o: ../include/dict.h mail_addr_find.o: ../include/vstream.h mail_addr_find.o: ../include/vbuf.h +mail_addr_find.o: ../include/binattr.h mail_addr_find.o: ../include/argv.h mail_addr_find.o: ../include/stringops.h -mail_addr_find.o: ../include/mymalloc.h mail_addr_find.o: ../include/vstring.h +mail_addr_find.o: ../include/mymalloc.h mail_addr_find.o: mail_params.h mail_addr_find.o: split_addr.h mail_addr_find.o: mail_addr_find.h @@ -418,6 +427,7 @@ mail_addr_map.o: ../include/vstring.h mail_addr_map.o: ../include/vbuf.h mail_addr_map.o: ../include/dict.h mail_addr_map.o: ../include/vstream.h +mail_addr_map.o: ../include/binattr.h mail_addr_map.o: ../include/argv.h mail_addr_map.o: ../include/mymalloc.h mail_addr_map.o: mail_addr_find.h @@ -429,12 +439,14 @@ mail_command_read.o: ../include/sys_defs.h mail_command_read.o: ../include/vstring.h mail_command_read.o: ../include/vbuf.h mail_command_read.o: ../include/vstream.h +mail_command_read.o: ../include/binattr.h mail_command_read.o: mail_proto.h mail_command_read.o: ../include/iostuff.h mail_command_write.o: mail_command_write.c mail_command_write.o: ../include/sys_defs.h mail_command_write.o: ../include/vstream.h mail_command_write.o: ../include/vbuf.h +mail_command_write.o: ../include/binattr.h mail_command_write.o: mail_proto.h mail_command_write.o: ../include/iostuff.h mail_conf.o: mail_conf.c @@ -443,6 +455,7 @@ mail_conf.o: ../include/msg.h mail_conf.o: ../include/mymalloc.h mail_conf.o: ../include/vstream.h mail_conf.o: ../include/vbuf.h +mail_conf.o: ../include/binattr.h mail_conf.o: ../include/vstring.h mail_conf.o: ../include/dict.h mail_conf.o: ../include/argv.h @@ -456,6 +469,7 @@ mail_conf_bool.o: ../include/msg.h mail_conf_bool.o: ../include/dict.h mail_conf_bool.o: ../include/vstream.h mail_conf_bool.o: ../include/vbuf.h +mail_conf_bool.o: ../include/binattr.h mail_conf_bool.o: ../include/argv.h mail_conf_bool.o: mail_conf.h mail_conf_int.o: mail_conf_int.c @@ -465,8 +479,10 @@ mail_conf_int.o: ../include/mymalloc.h mail_conf_int.o: ../include/dict.h mail_conf_int.o: ../include/vstream.h mail_conf_int.o: ../include/vbuf.h +mail_conf_int.o: ../include/binattr.h mail_conf_int.o: ../include/argv.h mail_conf_int.o: ../include/stringops.h +mail_conf_int.o: ../include/vstring.h mail_conf_int.o: mail_conf.h mail_conf_raw.o: mail_conf_raw.c mail_conf_raw.o: ../include/sys_defs.h @@ -483,6 +499,7 @@ mail_connect.o: ../include/sys_defs.h mail_connect.o: ../include/msg.h mail_connect.o: ../include/vstream.h mail_connect.o: ../include/vbuf.h +mail_connect.o: ../include/binattr.h mail_connect.o: ../include/connect.h mail_connect.o: ../include/iostuff.h mail_connect.o: ../include/mymalloc.h @@ -494,6 +511,7 @@ mail_copy.o: ../include/msg.h mail_copy.o: ../include/htable.h mail_copy.o: ../include/vstream.h mail_copy.o: ../include/vbuf.h +mail_copy.o: ../include/binattr.h mail_copy.o: ../include/vstring.h mail_copy.o: ../include/vstring_vstream.h mail_copy.o: ../include/stringops.h @@ -519,6 +537,7 @@ mail_flush.o: ../include/sys_defs.h mail_flush.o: mail_proto.h mail_flush.o: ../include/vstream.h mail_flush.o: ../include/vbuf.h +mail_flush.o: ../include/binattr.h mail_flush.o: ../include/iostuff.h mail_flush.o: mail_flush.h mail_open_ok.o: mail_open_ok.c @@ -528,6 +547,7 @@ mail_open_ok.o: mail_queue.h mail_open_ok.o: ../include/vstring.h mail_open_ok.o: ../include/vbuf.h mail_open_ok.o: ../include/vstream.h +mail_open_ok.o: ../include/binattr.h mail_open_ok.o: mail_open_ok.h mail_params.o: mail_params.c mail_params.o: ../include/sys_defs.h @@ -535,6 +555,8 @@ mail_params.o: ../include/msg.h mail_params.o: ../include/get_hostname.h mail_params.o: ../include/valid_hostname.h mail_params.o: ../include/stringops.h +mail_params.o: ../include/vstring.h +mail_params.o: ../include/vbuf.h mail_params.o: mynetworks.h mail_params.o: mail_conf.h mail_params.o: mail_version.h @@ -542,9 +564,11 @@ mail_params.o: mail_params.h mail_pathname.o: mail_pathname.c mail_pathname.o: ../include/sys_defs.h mail_pathname.o: ../include/stringops.h +mail_pathname.o: ../include/vstring.h +mail_pathname.o: ../include/vbuf.h mail_pathname.o: mail_proto.h mail_pathname.o: ../include/vstream.h -mail_pathname.o: ../include/vbuf.h +mail_pathname.o: ../include/binattr.h mail_pathname.o: ../include/iostuff.h mail_print.o: mail_print.c mail_print.o: ../include/sys_defs.h @@ -552,6 +576,7 @@ mail_print.o: ../include/msg.h mail_print.o: ../include/mymalloc.h mail_print.o: ../include/vstream.h mail_print.o: ../include/vbuf.h +mail_print.o: ../include/binattr.h mail_print.o: mail_proto.h mail_print.o: ../include/iostuff.h mail_queue.o: mail_queue.c @@ -560,6 +585,7 @@ mail_queue.o: ../include/msg.h mail_queue.o: ../include/vstring.h mail_queue.o: ../include/vbuf.h mail_queue.o: ../include/vstream.h +mail_queue.o: ../include/binattr.h mail_queue.o: ../include/mymalloc.h mail_queue.o: ../include/argv.h mail_queue.o: ../include/dir_forest.h @@ -573,6 +599,8 @@ mail_run.o: mail_run.c mail_run.o: ../include/sys_defs.h mail_run.o: ../include/msg.h mail_run.o: ../include/stringops.h +mail_run.o: ../include/vstring.h +mail_run.o: ../include/vbuf.h mail_run.o: ../include/mymalloc.h mail_run.o: mail_params.h mail_run.o: mail_run.h @@ -582,6 +610,7 @@ mail_scan.o: ../include/msg.h mail_scan.o: ../include/vstring.h mail_scan.o: ../include/vbuf.h mail_scan.o: ../include/vstream.h +mail_scan.o: ../include/binattr.h mail_scan.o: ../include/vstring_vstream.h mail_scan.o: ../include/mymalloc.h mail_scan.o: mail_proto.h @@ -597,6 +626,7 @@ mail_stream.o: ../include/mymalloc.h mail_stream.o: ../include/vstring.h mail_stream.o: ../include/vbuf.h mail_stream.o: ../include/vstream.h +mail_stream.o: ../include/binattr.h mail_stream.o: ../include/stringops.h mail_stream.o: cleanup_user.h mail_stream.o: mail_proto.h @@ -620,6 +650,7 @@ mail_trigger.o: mail_params.h mail_trigger.o: mail_proto.h mail_trigger.o: ../include/vstream.h mail_trigger.o: ../include/vbuf.h +mail_trigger.o: ../include/binattr.h mail_version.o: mail_version.c maps.o: maps.c maps.o: ../include/sys_defs.h @@ -629,7 +660,9 @@ maps.o: ../include/msg.h maps.o: ../include/dict.h maps.o: ../include/vstream.h maps.o: ../include/vbuf.h +maps.o: ../include/binattr.h maps.o: ../include/stringops.h +maps.o: ../include/vstring.h maps.o: ../include/split_at.h maps.o: mail_conf.h maps.o: maps.h @@ -638,6 +671,7 @@ mark_corrupt.o: ../include/sys_defs.h mark_corrupt.o: ../include/msg.h mark_corrupt.o: ../include/vstream.h mark_corrupt.o: ../include/vbuf.h +mark_corrupt.o: ../include/binattr.h mark_corrupt.o: mail_queue.h mark_corrupt.o: ../include/vstring.h mark_corrupt.o: mark_corrupt.h @@ -646,9 +680,11 @@ mkmap_db.o: ../include/sys_defs.h mkmap_db.o: ../include/msg.h mkmap_db.o: ../include/mymalloc.h mkmap_db.o: ../include/stringops.h +mkmap_db.o: ../include/vstring.h +mkmap_db.o: ../include/vbuf.h mkmap_db.o: ../include/dict.h mkmap_db.o: ../include/vstream.h -mkmap_db.o: ../include/vbuf.h +mkmap_db.o: ../include/binattr.h mkmap_db.o: ../include/argv.h mkmap_db.o: ../include/dict_db.h mkmap_db.o: mkmap.h @@ -657,9 +693,11 @@ mkmap_dbm.o: ../include/sys_defs.h mkmap_dbm.o: ../include/msg.h mkmap_dbm.o: ../include/mymalloc.h mkmap_dbm.o: ../include/stringops.h +mkmap_dbm.o: ../include/vstring.h +mkmap_dbm.o: ../include/vbuf.h mkmap_dbm.o: ../include/dict.h mkmap_dbm.o: ../include/vstream.h -mkmap_dbm.o: ../include/vbuf.h +mkmap_dbm.o: ../include/binattr.h mkmap_dbm.o: ../include/argv.h mkmap_dbm.o: ../include/dict_dbm.h mkmap_dbm.o: mkmap.h @@ -669,6 +707,7 @@ mkmap_open.o: ../include/msg.h mkmap_open.o: ../include/dict.h mkmap_open.o: ../include/vstream.h mkmap_open.o: ../include/vbuf.h +mkmap_open.o: ../include/binattr.h mkmap_open.o: ../include/argv.h mkmap_open.o: ../include/sigdelay.h mkmap_open.o: ../include/mymalloc.h @@ -714,6 +753,8 @@ own_inet_addr.o: ../include/inet_addr_list.h own_inet_addr.o: ../include/inet_addr_local.h own_inet_addr.o: ../include/inet_addr_host.h own_inet_addr.o: ../include/stringops.h +own_inet_addr.o: ../include/vstring.h +own_inet_addr.o: ../include/vbuf.h own_inet_addr.o: mail_params.h own_inet_addr.o: own_inet_addr.h peer_name.o: peer_name.c @@ -726,6 +767,7 @@ pipe_command.o: ../include/sys_defs.h pipe_command.o: ../include/msg.h pipe_command.o: ../include/vstream.h pipe_command.o: ../include/vbuf.h +pipe_command.o: ../include/binattr.h pipe_command.o: ../include/vstring.h pipe_command.o: ../include/stringops.h pipe_command.o: ../include/iostuff.h @@ -743,6 +785,7 @@ post_mail.o: ../include/sys_defs.h post_mail.o: ../include/msg.h post_mail.o: ../include/vstream.h post_mail.o: ../include/vbuf.h +post_mail.o: ../include/binattr.h post_mail.o: ../include/vstring.h post_mail.o: mail_params.h post_mail.o: record.h @@ -762,6 +805,7 @@ rec2stream.o: ../include/sys_defs.h rec2stream.o: ../include/vstring.h rec2stream.o: ../include/vbuf.h rec2stream.o: ../include/vstream.h +rec2stream.o: ../include/binattr.h rec2stream.o: record.h rec2stream.o: rec_streamlf.h rec2stream.o: rec_type.h @@ -770,6 +814,7 @@ rec_streamlf.o: ../include/sys_defs.h rec_streamlf.o: ../include/vstring.h rec_streamlf.o: ../include/vbuf.h rec_streamlf.o: ../include/vstream.h +rec_streamlf.o: ../include/binattr.h rec_streamlf.o: record.h rec_streamlf.o: rec_type.h rec_streamlf.o: rec_streamlf.h @@ -780,6 +825,7 @@ recdump.o: ../include/sys_defs.h recdump.o: ../include/msg_vstream.h recdump.o: ../include/vstream.h recdump.o: ../include/vbuf.h +recdump.o: ../include/binattr.h recdump.o: record.h recdump.o: ../include/vstring.h recdump.o: rec_streamlf.h @@ -793,6 +839,7 @@ record.o: ../include/msg.h record.o: ../include/mymalloc.h record.o: ../include/vstream.h record.o: ../include/vbuf.h +record.o: ../include/binattr.h record.o: ../include/vstring.h record.o: record.h remove.o: remove.c @@ -805,6 +852,7 @@ resolve_clnt.o: ../include/sys_defs.h resolve_clnt.o: ../include/msg.h resolve_clnt.o: ../include/vstream.h resolve_clnt.o: ../include/vbuf.h +resolve_clnt.o: ../include/binattr.h resolve_clnt.o: ../include/vstring.h resolve_clnt.o: ../include/vstring_vstream.h resolve_clnt.o: ../include/events.h @@ -827,6 +875,7 @@ rewrite_clnt.o: ../include/msg.h rewrite_clnt.o: ../include/vstring.h rewrite_clnt.o: ../include/vbuf.h rewrite_clnt.o: ../include/vstream.h +rewrite_clnt.o: ../include/binattr.h rewrite_clnt.o: ../include/vstring_vstream.h rewrite_clnt.o: ../include/events.h rewrite_clnt.o: ../include/iostuff.h @@ -846,6 +895,7 @@ smtp_stream.o: ../include/sys_defs.h smtp_stream.o: ../include/vstring.h smtp_stream.o: ../include/vbuf.h smtp_stream.o: ../include/vstream.h +smtp_stream.o: ../include/binattr.h smtp_stream.o: ../include/vstring_vstream.h smtp_stream.o: ../include/msg.h smtp_stream.o: ../include/iostuff.h @@ -860,6 +910,7 @@ stream2rec.o: stream2rec.c stream2rec.o: ../include/sys_defs.h stream2rec.o: ../include/vstream.h stream2rec.o: ../include/vbuf.h +stream2rec.o: ../include/binattr.h stream2rec.o: ../include/vstring.h stream2rec.o: record.h stream2rec.o: rec_streamlf.h @@ -878,7 +929,7 @@ timed_ipc.o: ../include/sys_defs.h timed_ipc.o: ../include/msg.h timed_ipc.o: ../include/vstream.h timed_ipc.o: ../include/vbuf.h -timed_ipc.o: ../include/iostuff.h +timed_ipc.o: ../include/binattr.h timed_ipc.o: mail_params.h timed_ipc.o: timed_ipc.h tok822_find.o: tok822_find.c diff --git a/postfix/global/mail_copy.c b/postfix/global/mail_copy.c index e91bf8bf5..a2e26aa86 100644 --- a/postfix/global/mail_copy.c +++ b/postfix/global/mail_copy.c @@ -6,12 +6,13 @@ /* SYNOPSIS /* #include /* -/* int mail_copy(sender, delivered, src, dst, flags, why) +/* int mail_copy(sender, delivered, src, dst, flags, eol, why) /* const char *sender; /* const char *delivered; /* VSTREAM *src; /* VSTREAM *dst; /* int flags; +/* const char *eol; /* VSTRING *why; /* DESCRIPTION /* mail_copy() copies a mail message from record stream to stream-lf @@ -53,6 +54,8 @@ /* The manifest constant MAIL_COPY_MBOX is a convenient shorthand for /* all MAIL_COPY_XXX options that are appropriate for mailbox delivery. /* Use MAIL_COPY_NONE to copy a message without any options enabled. +/* .IP eol +/* Record delimiter, for example, LF or CF LF. /* .IP why /* A null pointer, or storage for the reason of failure. /* DIAGNOSTICS @@ -101,7 +104,7 @@ int mail_copy(const char *sender, const char *delivered, VSTREAM *src, VSTREAM *dst, - int flags, VSTRING *why) + int flags, const char *eol, VSTRING *why) { char *myname = "mail_copy"; VSTRING *buf; @@ -139,15 +142,16 @@ int mail_copy(const char *sender, const char *delivered, asctime(localtime(&now))); } if (flags & MAIL_COPY_RETURN_PATH) { - vstream_fprintf(dst, "Return-Path: <%s>\n", - *sender ? vstring_str(buf) : ""); + vstream_fprintf(dst, "Return-Path: <%s>%s", + *sender ? vstring_str(buf) : "", eol); } } if (flags & MAIL_COPY_DELIVERED) { if (delivered == 0) msg_panic("%s: null delivered", myname); quote_822_local(buf, delivered); - vstream_fprintf(dst, "Delivered-To: %s\n", lowercase(vstring_str(buf))); + vstream_fprintf(dst, "Delivered-To: %s%s", + lowercase(vstring_str(buf)), eol); } /* @@ -166,13 +170,15 @@ int mail_copy(const char *sender, const char *delivered, if (type != REC_TYPE_NORM && type != REC_TYPE_CONT) break; bp = vstring_str(buf); - if ((flags & MAIL_COPY_QUOTE) && *bp == 'F' && !strncmp(bp, "From ", 5)) - VSTREAM_PUTC('>', dst); - if ((flags & MAIL_COPY_DOT) && *bp == '.') - VSTREAM_PUTC('.', dst); + if (prev_type == REC_TYPE_NORM) { + if ((flags & MAIL_COPY_QUOTE) && *bp == 'F' && !strncmp(bp, "From ", 5)) + VSTREAM_PUTC('>', dst); + if ((flags & MAIL_COPY_DOT) && *bp == '.') + VSTREAM_PUTC('.', dst); + } if (VSTRING_LEN(buf) && VSTREAM_FWRITE_BUF(dst, buf) != VSTRING_LEN(buf)) break; - if (type == REC_TYPE_NORM && VSTREAM_PUTC('\n', dst) == VSTREAM_EOF) + if (type == REC_TYPE_NORM && vstream_fputs(eol, dst) == VSTREAM_EOF) break; prev_type = type; } @@ -180,9 +186,9 @@ int mail_copy(const char *sender, const char *delivered, if (type != REC_TYPE_XTRA) corrupt_error = mark_corrupt(src); if (prev_type != REC_TYPE_NORM) - VSTREAM_PUTC('\n', dst); + vstream_fputs(eol, dst); if (flags & MAIL_COPY_FROM) - VSTREAM_PUTC('\n', dst); + vstream_fputs(eol, dst); } vstring_free(buf); diff --git a/postfix/global/mail_copy.h b/postfix/global/mail_copy.h index a121b90e1..2c0c743bb 100644 --- a/postfix/global/mail_copy.h +++ b/postfix/global/mail_copy.h @@ -21,7 +21,7 @@ * External interface. */ extern int mail_copy(const char *, const char *, VSTREAM *, VSTREAM *, - int, VSTRING *); + int, const char *, VSTRING *); #define MAIL_COPY_QUOTE (1<<0) /* prepend > to From_ */ #define MAIL_COPY_TOFILE (1<<1) /* fsync, ftruncate() */ diff --git a/postfix/global/mail_version.h b/postfix/global/mail_version.h index a3549f4de..087b0c4f1 100644 --- a/postfix/global/mail_version.h +++ b/postfix/global/mail_version.h @@ -15,7 +15,7 @@ * Version of this program. */ #define VAR_MAIL_VERSION "mail_version" -#define DEF_MAIL_VERSION "Snapshot-20000422" +#define DEF_MAIL_VERSION "Snapshot-20000503" extern char *var_mail_version; /* LICENSE diff --git a/postfix/global/mkmap_dbm.c b/postfix/global/mkmap_dbm.c index 618af3b72..db0d6f19e 100644 --- a/postfix/global/mkmap_dbm.c +++ b/postfix/global/mkmap_dbm.c @@ -47,7 +47,11 @@ #include "mkmap.h" #ifdef HAS_DBM +#ifdef PATH_NDBM_H +#include PATH_NDBM_H +#else #include +#endif /* mkmap_dbm_open - create or open database */ diff --git a/postfix/global/pipe_command.c b/postfix/global/pipe_command.c index da1b37b7b..a816ef956 100644 --- a/postfix/global/pipe_command.c +++ b/postfix/global/pipe_command.c @@ -51,6 +51,8 @@ /* .IP "PIPE_CMD_DELIVERED (char *)" /* The recipient envelope address, which is passed on to the /* \fImail_copy\fR() routine. +/* .IP "PIPE_CMD_EOL (char *)" +/* End-of-line delimiter. The default is to use the newline character. /* .IP "PIPE_CMD_UID (int)" /* The user ID to execute the command as. The default is /* the user ID corresponding to the \fIdefault_privs\fR @@ -138,6 +140,7 @@ struct pipe_args { int flags; /* see mail_copy.h */ char *sender; /* envelope sender */ char *delivered; /* envelope recipient */ + char *eol; /* carriagecontrol */ char **argv; /* either an array */ char *command; /* or a plain string */ uid_t uid; /* privileges */ @@ -162,6 +165,7 @@ static void get_pipe_args(struct pipe_args * args, va_list ap) args->flags = 0; args->sender = 0; args->delivered = 0; + args->eol = "\n"; args->argv = 0; args->command = 0; args->uid = var_default_uid; @@ -185,6 +189,9 @@ static void get_pipe_args(struct pipe_args * args, va_list ap) case PIPE_CMD_DELIVERED: args->delivered = va_arg(ap, char *); break; + case PIPE_CMD_EOL: + args->eol = va_arg(ap, char *); + break; case PIPE_CMD_ARGV: if (args->command) msg_panic("%s: got PIPE_CMD_ARGV and PIPE_CMD_COMMAND", myname); @@ -434,7 +441,8 @@ int pipe_command(VSTREAM *src, VSTRING *why,...) #define DONT_CARE_WHY ((VSTRING *) 0) write_status = mail_copy(args.sender, args.delivered, src, - cmd_in_stream, args.flags, DONT_CARE_WHY); + cmd_in_stream, args.flags, + args.eol, DONT_CARE_WHY); /* * Capture a limited amount of command output, for inclusion in a diff --git a/postfix/global/pipe_command.h b/postfix/global/pipe_command.h index cf75aa117..822167935 100644 --- a/postfix/global/pipe_command.h +++ b/postfix/global/pipe_command.h @@ -36,6 +36,7 @@ #define PIPE_CMD_TIME_LIMIT 8 /* time limit */ #define PIPE_CMD_ENV 9 /* extra environment */ #define PIPE_CMD_SHELL 10 /* alternative shell */ +#define PIPE_CMD_EOL 11 /* record delimiter */ /* * Command completion status. diff --git a/postfix/global/smtp_stream.c b/postfix/global/smtp_stream.c index ce7cefe37..0f60200c1 100644 --- a/postfix/global/smtp_stream.c +++ b/postfix/global/smtp_stream.c @@ -6,7 +6,9 @@ /* SYNOPSIS /* #include /* -/* jmp_buf smtp_timeout_buf; +/* void smtp_jump_setup(stream, jbuf) +/* VSTREAM *stream; +/* jmp_buf *jbuf; /* /* void smtp_timeout_setup(stream, timeout) /* VSTREAM *stream; @@ -44,6 +46,11 @@ /* with error detection: timeouts or unexpected end-of-file. /* A trailing CR LF is added upon writing and removed upon reading. /* +/* smtp_jump_setup() registers a caller context that will be +/* jumped to (with longjmp()) when any routine in this module +/* experiences an error condition (timeout, I/O error, or +/* unexpected EOF). +/* /* smtp_timeout_setup() arranges for a time limit on the smtp read /* and write operations described below. /* This routine alters the behavior of streams as follows: @@ -83,18 +90,18 @@ /* .fi /* .ad /* In case of error, a longjmp() is performed to the context -/* saved in the global \fIsmtp_timeout_buf\fR. +/* specified with the smtp_jump_setup() call. /* Error codes passed along with longjmp() are: /* .IP SMTP_ERR_EOF -/* The peer has disconnected unexpectedly. +/* An I/O error happened, or the peer has disconnected unexpectedly. /* .IP SMTP_ERR_TIME /* The time limit specified to smtp_timeout_setup() was exceeded. /* BUGS -/* The timeout etc. context is static, so this module can handle -/* only one SMTP session at a time. +/* The timeout deadline affects all I/O on the named stream, not +/* just the I/O done on behalf of this module. /* -/* The timeout protection, including longjmp(), affects all I/O -/* on the named stream, not just the I/O done by this module. +/* The timeout deadline and exception handling context overwrite +/* any previously set up state on the named stream. /* LICENSE /* .ad /* .fi @@ -130,72 +137,45 @@ #include "smtp_stream.h" -jmp_buf smtp_timeout_buf; - /* - * Timeout handling. When a timeout happens, we shut down the connection in - * the appropriate direction, to force the I/O operation to fail. + * Our private VSTREAM attribute name for keeping track of the + * caller-supplied context for exception handling. */ -static int smtp_timeout_done; -static int smtp_maxtime; +#define SMTP_ATTR_JBUF "smtp_timeout_buf" -#define SMTP_DIR_READ 0 /* read direction */ -#define SMTP_DIR_WRITE 1 /* write direction */ +/* smtp_timeout_jump - release timeout trap */ -/* smtp_timeout_event - timeout handler */ - -static void smtp_timeout_event(int fd, int direction) +static void smtp_timeout_jump(VSTREAM *stream, int what) { + char *myname = "smtp_timeout_jump"; + jmp_buf *jbuf; - /* - * Yes, this is gross, but we cannot longjump() away. Although timeouts - * are restricted to read() and write() operations, we could still leave - * things in an inconsistent state. Instead, we set a flag and force an - * I/O error on the smtp stream. - */ - if (shutdown(fd, direction) < 0) - if (errno != ENOTCONN) - msg_warn("smtp_timeout_event: shutdown: %m"); - smtp_timeout_done = 1; -} - -/* smtp_read - read with timeout */ - -static int smtp_read(int fd, void *buf, unsigned len) -{ - if (read_wait(fd, smtp_maxtime) < 0) { - smtp_timeout_event(fd, SMTP_DIR_READ); - return (-1); - } else { - return (read(fd, buf, len)); - } + if ((jbuf = (jmp_buf *) vstream_attr_get(stream, SMTP_ATTR_JBUF)) == 0) + msg_panic("%s: no jump buffer", myname); + longjmp(jbuf[0], what); } -/* smtp_write - write with timeout */ +/* smtp_jump_setup - configure exception handling context */ -static int smtp_write(int fd, void *buf, unsigned len) +void smtp_jump_setup(VSTREAM *stream, jmp_buf * jbuf) { - if (write_wait(fd, smtp_maxtime) < 0) { - smtp_timeout_event(fd, SMTP_DIR_WRITE); - return (-1); - } else { - return (write(fd, buf, len)); - } + vstream_attr_set(stream, SMTP_ATTR_JBUF, + (char *) jbuf, (VSTREAM_ATTR_FREE_FN) 0); } -/* smtp_timeout_protect - setup timeout trap for specified stream. */ +/* smtp_timeout_protect - reset per-stream timeout flag */ -static void smtp_timeout_protect(void) +static void smtp_timeout_protect(VSTREAM *stream) { - smtp_timeout_done = 0; + vstream_clearerr(stream); } -/* smtp_timeout_unprotect - finish timeout trap */ +/* smtp_timeout_detect - test the per-stream timeout flag */ -static void smtp_timeout_unprotect(void) +static void smtp_timeout_detect(VSTREAM *stream) { - if (smtp_timeout_done) - longjmp(smtp_timeout_buf, SMTP_ERR_TIME); + if (vstream_ftimeout(stream)) + smtp_timeout_jump(stream, SMTP_ERR_TIME); } /* smtp_timeout_setup - configure timeout trap */ @@ -204,21 +184,15 @@ void smtp_timeout_setup(VSTREAM *stream, int maxtime) { /* - * XXX The timeout etc. state is static, so a process can have at most - * one SMTP session at a time. We could use the VSTREAM file descriptor - * number as key into a BINHASH table with per-stream contexts. This - * would allow us to talk to multiple SMTP streams at the same time. - * Another possibility is to use the file descriptor as an index into a - * linear table of structure pointers. In either case we would need to - * provide an smtp_timeout_cleanup() routine to dispose of memory that is - * no longer needed. + * Stick your TLS/whatever read-write routines here. Notice that the + * read/write interface now includes a timeout parameter, and that a + * read/write routine is supposed to set errno to ETIMEDOUT when the + * alarm clock goes off. */ vstream_control(stream, - VSTREAM_CTL_READ_FN, smtp_read, - VSTREAM_CTL_WRITE_FN, smtp_write, + VSTREAM_CTL_TIMEOUT, maxtime, VSTREAM_CTL_DOUBLE, VSTREAM_CTL_END); - smtp_maxtime = maxtime; } /* smtp_vprintf - write one line to SMTP peer */ @@ -230,11 +204,11 @@ void smtp_vprintf(VSTREAM *stream, const char *fmt, va_list ap) /* * Do the I/O, protected against timeout. */ - smtp_timeout_protect(); + smtp_timeout_protect(stream); vstream_vfprintf(stream, fmt, ap); vstream_fputs("\r\n", stream); err = vstream_fflush(stream); - smtp_timeout_unprotect(); + smtp_timeout_detect(stream); /* * See if there was a problem. @@ -242,7 +216,7 @@ void smtp_vprintf(VSTREAM *stream, const char *fmt, va_list ap) if (err != 0) { if (msg_verbose) msg_info("smtp_vprintf: EOF"); - longjmp(smtp_timeout_buf, SMTP_ERR_EOF); + smtp_timeout_jump(stream, SMTP_ERR_EOF); } } @@ -270,7 +244,7 @@ int smtp_get(VSTRING *vp, VSTREAM *stream, int bound) * allow for lines ending in bare LF. The idea is to be liberal in what * we accept, strict in what we send. */ - smtp_timeout_protect(); + smtp_timeout_protect(stream); last_char = (bound == 0 ? vstring_get(vp, stream) : vstring_get_bound(vp, stream, bound)); @@ -308,7 +282,7 @@ int smtp_get(VSTRING *vp, VSTREAM *stream, int bound) default: break; } - smtp_timeout_unprotect(); + smtp_timeout_detect(stream); /* * EOF is bad, whether or not it happens in the middle of a record. Don't @@ -317,7 +291,7 @@ int smtp_get(VSTRING *vp, VSTREAM *stream, int bound) if (vstream_feof(stream) || vstream_ferror(stream)) { if (msg_verbose) msg_info("smtp_get: EOF"); - longjmp(smtp_timeout_buf, SMTP_ERR_EOF); + smtp_timeout_jump(stream, SMTP_ERR_EOF); } return (last_char); } @@ -334,10 +308,10 @@ void smtp_fputs(const char *cp, int todo, VSTREAM *stream) /* * Do the I/O, protected against timeout. */ - smtp_timeout_protect(); + smtp_timeout_protect(stream); err = (vstream_fwrite(stream, cp, todo) != todo || vstream_fputs("\r\n", stream) == VSTREAM_EOF); - smtp_timeout_unprotect(); + smtp_timeout_detect(stream); /* * See if there was a problem. @@ -345,7 +319,7 @@ void smtp_fputs(const char *cp, int todo, VSTREAM *stream) if (err != 0) { if (msg_verbose) msg_info("smtp_fputs: EOF"); - longjmp(smtp_timeout_buf, SMTP_ERR_EOF); + smtp_timeout_jump(stream, SMTP_ERR_EOF); } } @@ -361,9 +335,9 @@ void smtp_fwrite(const char *cp, int todo, VSTREAM *stream) /* * Do the I/O, protected against timeout. */ - smtp_timeout_protect(); + smtp_timeout_protect(stream); err = (vstream_fwrite(stream, cp, todo) != todo); - smtp_timeout_unprotect(); + smtp_timeout_detect(stream); /* * See if there was a problem. @@ -371,7 +345,7 @@ void smtp_fwrite(const char *cp, int todo, VSTREAM *stream) if (err != 0) { if (msg_verbose) msg_info("smtp_fwrite: EOF"); - longjmp(smtp_timeout_buf, SMTP_ERR_EOF); + smtp_timeout_jump(stream, SMTP_ERR_EOF); } } @@ -384,9 +358,9 @@ void smtp_fputc(int ch, VSTREAM *stream) /* * Do the I/O, protected against timeout. */ - smtp_timeout_protect(); + smtp_timeout_protect(stream); stat = VSTREAM_PUTC(ch, stream); - smtp_timeout_unprotect(); + smtp_timeout_detect(stream); /* * See if there was a problem. @@ -394,6 +368,6 @@ void smtp_fputc(int ch, VSTREAM *stream) if (stat == VSTREAM_EOF) { if (msg_verbose) msg_info("smtp_fputc: EOF"); - longjmp(smtp_timeout_buf, SMTP_ERR_EOF); + smtp_timeout_jump(stream, SMTP_ERR_EOF); } } diff --git a/postfix/global/smtp_stream.h b/postfix/global/smtp_stream.h index f149e54e8..296eae28a 100644 --- a/postfix/global/smtp_stream.h +++ b/postfix/global/smtp_stream.h @@ -29,8 +29,7 @@ #define SMTP_ERR_EOF 1 /* unexpected client disconnect */ #define SMTP_ERR_TIME 2 /* time out */ -extern jmp_buf smtp_timeout_buf; - +extern void smtp_jump_setup(VSTREAM *, jmp_buf *); extern void smtp_timeout_setup(VSTREAM *, int); extern void smtp_printf(VSTREAM *, const char *,...); extern int smtp_get(VSTRING *, VSTREAM *, int); diff --git a/postfix/global/timed_ipc.c b/postfix/global/timed_ipc.c index 588f3aa3a..a4640e083 100644 --- a/postfix/global/timed_ipc.c +++ b/postfix/global/timed_ipc.c @@ -31,37 +31,17 @@ /* System library. */ #include -#include /* Utility library. */ #include #include -#include /* Global library. */ #include "mail_params.h" #include "timed_ipc.h" -/* timed_ipc_read - read with timeout */ - -static int timed_ipc_read(int fd, void *buf, unsigned len) -{ - if (read_wait(fd, var_ipc_timeout) < 0) - msg_fatal("timed_ipc_read: command read timeout"); - return (read(fd, buf, len)); -} - -/* timed_ipc_write - read with timeout */ - -static int timed_ipc_write(int fd, void *buf, unsigned len) -{ - if (write_wait(fd, var_ipc_timeout) < 0) - msg_fatal("timed_ipc_write: command write timeout"); - return (write(fd, buf, len)); -} - /* timed_ipc_setup - enable ipc with timeout */ void timed_ipc_setup(VSTREAM *stream) @@ -70,7 +50,6 @@ void timed_ipc_setup(VSTREAM *stream) msg_panic("timed_ipc_setup: bad ipc_timeout %d", var_ipc_timeout); vstream_control(stream, - VSTREAM_CTL_READ_FN, timed_ipc_read, - VSTREAM_CTL_WRITE_FN, timed_ipc_write, + VSTREAM_CTL_TIMEOUT, var_ipc_timeout, VSTREAM_CTL_END); } diff --git a/postfix/html/cleanup.8.html b/postfix/html/cleanup.8.html index ae6741158..9ad4103f1 100644 --- a/postfix/html/cleanup.8.html +++ b/postfix/html/cleanup.8.html @@ -92,7 +92,7 @@ CLEANUP(8) CLEANUP(8) hopcount_limit Limit the number of Received: message headers. - recipients_witheld_header + undisclosed_recipients_header The header line that is inserted when no recipients were specified in (Resent-)To: or (Resent-)Cc: mes- sage headers. diff --git a/postfix/html/pipe.8.html b/postfix/html/pipe.8.html index f3a535472..f18c24f49 100644 --- a/postfix/html/pipe.8.html +++ b/postfix/html/pipe.8.html @@ -71,6 +71,11 @@ PIPE(8) PIPE(8) PIPE(8) PIPE(8) + eol=string (default: \n) + The output record delimiter. Typically one would + use either \r\n or \n. You can specify the usual C- + style backslash escape sequences. + argv=command... (required) The command to be executed. This must be specified as the last command attribute. The command is exe- @@ -121,11 +126,6 @@ PIPE(8) PIPE(8) ${user} expands into as many command-line arguments as there are recipients. - In addition to the form ${name}, the forms $name and - $(name) are also recognized. Specify $$ where a single $ - is wanted. - - 2 @@ -137,6 +137,10 @@ PIPE(8) PIPE(8) PIPE(8) PIPE(8) + In addition to the form ${name}, the forms $name and + $(name) are also recognized. Specify $$ where a single $ + is wanted. + DIAGNOSTICS Command exit status codes are expected to follow the con- ventions defined in <sysexits.h>. @@ -187,10 +191,6 @@ PIPE(8) PIPE(8) ter. The limit is enforced by the Postfix queue manager. -SEE ALSO - bounce(8) non-delivery status reports - master(8) process manager - qmgr(8) queue manager @@ -203,6 +203,10 @@ PIPE(8) PIPE(8) PIPE(8) PIPE(8) +SEE ALSO + bounce(8) non-delivery status reports + master(8) process manager + qmgr(8) queue manager syslogd(8) system logging LICENSE @@ -251,10 +255,6 @@ PIPE(8) PIPE(8) - - - - diff --git a/postfix/local/.indent.pro b/postfix/local/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/local/.indent.pro +++ b/postfix/local/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/local/Makefile.in b/postfix/local/Makefile.in index 4d9338529..5535f1646 100644 --- a/postfix/local/Makefile.in +++ b/postfix/local/Makefile.in @@ -67,10 +67,11 @@ alias.o: ../include/htable.h alias.o: ../include/dict.h alias.o: ../include/vstream.h alias.o: ../include/vbuf.h +alias.o: ../include/binattr.h alias.o: ../include/argv.h alias.o: ../include/stringops.h -alias.o: ../include/mymalloc.h alias.o: ../include/vstring.h +alias.o: ../include/mymalloc.h alias.o: ../include/mail_params.h alias.o: ../include/mail_addr.h alias.o: ../include/sent.h @@ -96,6 +97,7 @@ command.o: ../include/htable.h command.o: ../include/vstring.h command.o: ../include/vbuf.h command.o: ../include/vstream.h +command.o: ../include/binattr.h command.o: ../include/argv.h command.o: ../include/defer.h command.o: ../include/bounce.h @@ -114,6 +116,7 @@ deliver_attr.o: ../include/sys_defs.h deliver_attr.o: ../include/msg.h deliver_attr.o: ../include/vstream.h deliver_attr.o: ../include/vbuf.h +deliver_attr.o: ../include/binattr.h deliver_attr.o: local.h deliver_attr.o: ../include/htable.h deliver_attr.o: ../include/vstring.h @@ -129,6 +132,7 @@ delivered.o: ../include/htable.h delivered.o: ../include/vstring.h delivered.o: ../include/vbuf.h delivered.o: ../include/vstream.h +delivered.o: ../include/binattr.h delivered.o: ../include/vstring_vstream.h delivered.o: ../include/stringops.h delivered.o: ../include/record.h @@ -148,6 +152,7 @@ dotforward.o: ../include/msg.h dotforward.o: ../include/vstring.h dotforward.o: ../include/vbuf.h dotforward.o: ../include/vstream.h +dotforward.o: ../include/binattr.h dotforward.o: ../include/htable.h dotforward.o: ../include/open_as.h dotforward.o: ../include/lstat_as.h @@ -174,6 +179,7 @@ file.o: ../include/htable.h file.o: ../include/vstring.h file.o: ../include/vbuf.h file.o: ../include/vstream.h +file.o: ../include/binattr.h file.o: ../include/deliver_flock.h file.o: ../include/open_as.h file.o: ../include/mail_copy.h @@ -197,6 +203,7 @@ forward.o: ../include/argv.h forward.o: ../include/vstring.h forward.o: ../include/vbuf.h forward.o: ../include/vstream.h +forward.o: ../include/binattr.h forward.o: ../include/vstring_vstream.h forward.o: ../include/iostuff.h forward.o: ../include/stringops.h @@ -221,6 +228,7 @@ include.o: ../include/htable.h include.o: ../include/mymalloc.h include.o: ../include/vstream.h include.o: ../include/vbuf.h +include.o: ../include/binattr.h include.o: ../include/open_as.h include.o: ../include/stat_as.h include.o: ../include/iostuff.h @@ -247,6 +255,7 @@ indirect.o: ../include/been_here.h indirect.o: local.h indirect.o: ../include/vstream.h indirect.o: ../include/vbuf.h +indirect.o: ../include/binattr.h indirect.o: ../include/vstring.h indirect.o: ../include/tok822.h indirect.o: ../include/resolve_clnt.h @@ -260,6 +269,7 @@ local.o: ../include/htable.h local.o: ../include/vstring.h local.o: ../include/vbuf.h local.o: ../include/vstream.h +local.o: ../include/binattr.h local.o: ../include/iostuff.h local.o: ../include/name_mask.h local.o: ../include/set_eugid.h @@ -287,6 +297,7 @@ local_expand.o: ../include/mail_params.h local_expand.o: local.h local_expand.o: ../include/htable.h local_expand.o: ../include/vstream.h +local_expand.o: ../include/binattr.h local_expand.o: ../include/been_here.h local_expand.o: ../include/tok822.h local_expand.o: ../include/resolve_clnt.h @@ -299,6 +310,7 @@ mailbox.o: ../include/htable.h mailbox.o: ../include/vstring.h mailbox.o: ../include/vbuf.h mailbox.o: ../include/vstream.h +mailbox.o: ../include/binattr.h mailbox.o: ../include/mymalloc.h mailbox.o: ../include/stringops.h mailbox.o: ../include/set_eugid.h @@ -325,9 +337,10 @@ maildir.o: ../include/sys_defs.h maildir.o: ../include/msg.h maildir.o: ../include/mymalloc.h maildir.o: ../include/stringops.h -maildir.o: ../include/vstream.h -maildir.o: ../include/vbuf.h maildir.o: ../include/vstring.h +maildir.o: ../include/vbuf.h +maildir.o: ../include/vstream.h +maildir.o: ../include/binattr.h maildir.o: ../include/make_dirs.h maildir.o: ../include/set_eugid.h maildir.o: ../include/get_hostname.h @@ -350,16 +363,17 @@ recipient.o: ../include/mymalloc.h recipient.o: ../include/htable.h recipient.o: ../include/split_at.h recipient.o: ../include/stringops.h +recipient.o: ../include/vstring.h +recipient.o: ../include/vbuf.h recipient.o: ../include/dict.h recipient.o: ../include/vstream.h -recipient.o: ../include/vbuf.h +recipient.o: ../include/binattr.h recipient.o: ../include/argv.h recipient.o: ../include/bounce.h recipient.o: ../include/mail_params.h recipient.o: ../include/split_addr.h recipient.o: ../include/ext_prop.h recipient.o: local.h -recipient.o: ../include/vstring.h recipient.o: ../include/been_here.h recipient.o: ../include/tok822.h recipient.o: ../include/resolve_clnt.h @@ -373,6 +387,7 @@ resolve.o: ../include/vbuf.h resolve.o: ../include/htable.h resolve.o: ../include/mail_proto.h resolve.o: ../include/vstream.h +resolve.o: ../include/binattr.h resolve.o: ../include/iostuff.h resolve.o: ../include/resolve_clnt.h resolve.o: ../include/rewrite_clnt.h @@ -388,6 +403,7 @@ token.o: ../include/msg.h token.o: ../include/vstring.h token.o: ../include/vbuf.h token.o: ../include/vstream.h +token.o: ../include/binattr.h token.o: ../include/htable.h token.o: ../include/readlline.h token.o: ../include/mymalloc.h @@ -405,13 +421,14 @@ unknown.o: unknown.c unknown.o: ../include/sys_defs.h unknown.o: ../include/msg.h unknown.o: ../include/stringops.h -unknown.o: ../include/mymalloc.h unknown.o: ../include/vstring.h unknown.o: ../include/vbuf.h +unknown.o: ../include/mymalloc.h unknown.o: ../include/been_here.h unknown.o: ../include/mail_params.h unknown.o: ../include/mail_proto.h unknown.o: ../include/vstream.h +unknown.o: ../include/binattr.h unknown.o: ../include/iostuff.h unknown.o: ../include/bounce.h unknown.o: local.h diff --git a/postfix/local/file.c b/postfix/local/file.c index 488c5df01..75a716e20 100644 --- a/postfix/local/file.c +++ b/postfix/local/file.c @@ -181,7 +181,7 @@ int deliver_file(LOCAL_STATE state, USER_ATTR usr_attr, char *path) path, STR(why)); #endif } else if (mail_copy(COPY_ATTR(state.msg_attr), dst, S_ISREG(st.st_mode) ? - copy_flags : (copy_flags & ~MAIL_COPY_TOFILE), why)) { + copy_flags : (copy_flags & ~MAIL_COPY_TOFILE), "\n", why)) { status = defer_append(BOUNCE_FLAG_KEEP, BOUNCE_ATTR(state.msg_attr), "cannot append destination file %s: %s", path, STR(why)); diff --git a/postfix/local/mailbox.c b/postfix/local/mailbox.c index 31beaa179..51e0ac437 100644 --- a/postfix/local/mailbox.c +++ b/postfix/local/mailbox.c @@ -191,7 +191,7 @@ static int deliver_mailbox_file(LOCAL_STATE state, USER_ATTR usr_attr) if (deliver_flock(vstream_fileno(dst), why) < 0) vstream_fclose(dst); else if (mail_copy(COPY_ATTR(state.msg_attr), dst, - copy_flags, why) == 0) { + copy_flags, "\n", why) == 0) { status = 0; if (var_biff) { biff = vstring_alloc(100); diff --git a/postfix/local/maildir.c b/postfix/local/maildir.c index 40fe847d5..24f2ff8f4 100644 --- a/postfix/local/maildir.c +++ b/postfix/local/maildir.c @@ -136,7 +136,7 @@ int deliver_maildir(LOCAL_STATE state, USER_ATTR usr_attr, char *path) || (dst = vstream_fopen(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0600)) == 0)) { vstring_sprintf(why, "create %s: %m", tmpfile); } else { - if (mail_copy(COPY_ATTR(state.msg_attr), dst, copy_flags, why) == 0) { + if (mail_copy(COPY_ATTR(state.msg_attr), dst, copy_flags, "\n", why) == 0) { if (sane_link(tmpfile, newfile) < 0 && (errno != ENOENT || (make_dirs(curdir, 0700), make_dirs(newdir, 0700)) < 0 diff --git a/postfix/man/man8/cleanup.8 b/postfix/man/man8/cleanup.8 index 50f019bfb..e96116fa8 100644 --- a/postfix/man/man8/cleanup.8 +++ b/postfix/man/man8/cleanup.8 @@ -81,7 +81,7 @@ a configuration change. Address to send a copy of each message that enters the system. .IP \fBhopcount_limit\fR Limit the number of \fBReceived:\fR message headers. -.IP \fBrecipients_witheld_header\fR +.IP \fBundisclosed_recipients_header\fR The header line that is inserted when no recipients were specified in (Resent-)To: or (Resent-)Cc: message headers. .SH "Address transformations" diff --git a/postfix/man/man8/pipe.8 b/postfix/man/man8/pipe.8 index 6a19a549c..f9f77422d 100644 --- a/postfix/man/man8/pipe.8 +++ b/postfix/man/man8/pipe.8 @@ -57,6 +57,10 @@ commands with root privileges, or with the privileges of the mail system owner. If \fIgroupname\fR is specified, the corresponding group ID is used instead of the group ID of \fIusername\fR. +.IP "\fBeol=string\fR (default: \fB\en\fR)" +The output record delimiter. Typically one would use either +\fB\er\en\fR or \fB\en\fR. You can specify the usual C-style +backslash escape sequences. .IP "\fBargv\fR=\fIcommand\fR... (required)" The command to be executed. This must be specified as the last command attribute. diff --git a/postfix/master/.indent.pro b/postfix/master/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/master/.indent.pro +++ b/postfix/master/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/master/Makefile.in b/postfix/master/Makefile.in index 31a0e36c4..00bfd0545 100644 --- a/postfix/master/Makefile.in +++ b/postfix/master/Makefile.in @@ -88,6 +88,7 @@ master.o: ../include/vbuf.h master.o: ../include/mymalloc.h master.o: ../include/iostuff.h master.o: ../include/vstream.h +master.o: ../include/binattr.h master.o: ../include/stringops.h master.o: ../include/myflock.h master.o: ../include/watchdog.h @@ -115,6 +116,7 @@ master_ent.o: ../include/mymalloc.h master_ent.o: ../include/vstring.h master_ent.o: ../include/vbuf.h master_ent.o: ../include/vstream.h +master_ent.o: ../include/binattr.h master_ent.o: ../include/argv.h master_ent.o: ../include/stringops.h master_ent.o: ../include/readlline.h @@ -132,6 +134,8 @@ master_listen.o: ../include/listen.h master_listen.o: ../include/iostuff.h master_listen.o: ../include/mymalloc.h master_listen.o: ../include/stringops.h +master_listen.o: ../include/vstring.h +master_listen.o: ../include/vbuf.h master_listen.o: ../include/inet_addr_list.h master_listen.o: ../include/set_eugid.h master_listen.o: ../include/mail_params.h @@ -171,6 +175,8 @@ master_vars.o: master_vars.c master_vars.o: ../include/sys_defs.h master_vars.o: ../include/msg.h master_vars.o: ../include/stringops.h +master_vars.o: ../include/vstring.h +master_vars.o: ../include/vbuf.h master_vars.o: ../include/mymalloc.h master_vars.o: ../include/mail_conf.h master_vars.o: ../include/mail_params.h @@ -183,6 +189,7 @@ master_wakeup.o: ../include/events.h master_wakeup.o: ../include/mail_proto.h master_wakeup.o: ../include/vstream.h master_wakeup.o: ../include/vbuf.h +master_wakeup.o: ../include/binattr.h master_wakeup.o: ../include/iostuff.h master_wakeup.o: mail_server.h master_wakeup.o: master.h @@ -197,6 +204,7 @@ multi_server.o: ../include/events.h multi_server.o: ../include/vstring.h multi_server.o: ../include/vbuf.h multi_server.o: ../include/vstream.h +multi_server.o: ../include/binattr.h multi_server.o: ../include/msg_vstream.h multi_server.o: ../include/mymalloc.h multi_server.o: ../include/stringops.h @@ -204,6 +212,7 @@ multi_server.o: ../include/sane_accept.h multi_server.o: ../include/myflock.h multi_server.o: ../include/safe_open.h multi_server.o: ../include/watchdog.h +multi_server.o: ../include/split_at.h multi_server.o: ../include/mail_task.h multi_server.o: ../include/debug_process.h multi_server.o: ../include/mail_params.h @@ -220,6 +229,7 @@ single_server.o: ../include/chroot_uid.h single_server.o: ../include/vstring.h single_server.o: ../include/vbuf.h single_server.o: ../include/vstream.h +single_server.o: ../include/binattr.h single_server.o: ../include/msg_vstream.h single_server.o: ../include/mymalloc.h single_server.o: ../include/events.h @@ -230,6 +240,7 @@ single_server.o: ../include/myflock.h single_server.o: ../include/safe_open.h single_server.o: ../include/listen.h single_server.o: ../include/watchdog.h +single_server.o: ../include/split_at.h single_server.o: ../include/mail_params.h single_server.o: ../include/mail_task.h single_server.o: ../include/debug_process.h @@ -246,6 +257,7 @@ trigger_server.o: ../include/chroot_uid.h trigger_server.o: ../include/vstring.h trigger_server.o: ../include/vbuf.h trigger_server.o: ../include/vstream.h +trigger_server.o: ../include/binattr.h trigger_server.o: ../include/msg_vstream.h trigger_server.o: ../include/mymalloc.h trigger_server.o: ../include/events.h @@ -256,6 +268,7 @@ trigger_server.o: ../include/myflock.h trigger_server.o: ../include/safe_open.h trigger_server.o: ../include/listen.h trigger_server.o: ../include/watchdog.h +trigger_server.o: ../include/split_at.h trigger_server.o: ../include/mail_params.h trigger_server.o: ../include/mail_task.h trigger_server.o: ../include/debug_process.h diff --git a/postfix/master/multi_server.c b/postfix/master/multi_server.c index 1f58f2170..fb87793fd 100644 --- a/postfix/master/multi_server.c +++ b/postfix/master/multi_server.c @@ -153,6 +153,7 @@ #include #include #include +#include /* Global library. */ @@ -354,6 +355,7 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) VSTRING *why; int alone = 0; WATCHDOG *watchdog; + char *oval; /* * Process environment options as early as we can. @@ -368,7 +370,7 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) */ signal(SIGPIPE, SIG_IGN); - /* + /* * Don't die for frivolous reasons. */ #ifdef SIGXFSZ @@ -435,7 +437,7 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) * stderr, because no-one is going to see them. */ opterr = 0; - while ((c = GETOPT(argc, argv, "cDi:lm:n:s:St:uv")) > 0) { + while ((c = GETOPT(argc, argv, "cDi:lm:n:o:s:St:uv")) > 0) { switch (c) { case 'c': root_dir = var_queue_dir; @@ -457,6 +459,11 @@ NORETURN multi_server_main(int argc, char **argv, MULTI_SERVER_FN service,...) case 'n': service_name = optarg; break; + case 'o': + mail_conf_update(optarg, + (oval = split_at(optarg, '=')) ? oval : ""); + mail_params_init(); /* XXX */ + break; case 's': if ((socket_count = atoi(optarg)) <= 0) msg_fatal("invalid socket_count: %s", optarg); diff --git a/postfix/master/single_server.c b/postfix/master/single_server.c index 7f64733c6..70424a95f 100644 --- a/postfix/master/single_server.c +++ b/postfix/master/single_server.c @@ -129,6 +129,7 @@ #ifdef STRCASECMP_IN_STRINGS_H #include #endif + /* Utility library. */ #include @@ -146,6 +147,7 @@ #include #include #include +#include /* Global library. */ @@ -325,6 +327,7 @@ NORETURN single_server_main(int argc, char **argv, SINGLE_SERVER_FN service,...) VSTRING *why; int alone = 0; WATCHDOG *watchdog; + char *oval; /* * Process environment options as early as we can. @@ -339,7 +342,7 @@ NORETURN single_server_main(int argc, char **argv, SINGLE_SERVER_FN service,...) */ signal(SIGPIPE, SIG_IGN); - /* + /* * Don't die for frivolous reasons. */ #ifdef SIGXFSZ @@ -406,7 +409,7 @@ NORETURN single_server_main(int argc, char **argv, SINGLE_SERVER_FN service,...) * stderr, because no-one is going to see them. */ opterr = 0; - while ((c = GETOPT(argc, argv, "cDi:lm:n:s:St:uv")) > 0) { + while ((c = GETOPT(argc, argv, "cDi:lm:n:o:s:St:uv")) > 0) { switch (c) { case 'c': root_dir = var_queue_dir; @@ -428,6 +431,11 @@ NORETURN single_server_main(int argc, char **argv, SINGLE_SERVER_FN service,...) case 'n': service_name = optarg; break; + case 'o': + mail_conf_update(optarg, + (oval = split_at(optarg, '=')) ? oval : ""); + mail_params_init(); /* XXX */ + break; case 's': if ((socket_count = atoi(optarg)) <= 0) msg_fatal("invalid socket_count: %s", optarg); diff --git a/postfix/master/trigger_server.c b/postfix/master/trigger_server.c index 60a00f880..340977f4c 100644 --- a/postfix/master/trigger_server.c +++ b/postfix/master/trigger_server.c @@ -137,6 +137,7 @@ #ifdef STRCASECMP_IN_STRINGS_H #include #endif + /* Utility library. */ #include @@ -154,6 +155,7 @@ #include #include #include +#include /* Global library. */ @@ -326,6 +328,7 @@ NORETURN trigger_server_main(int argc, char **argv, TRIGGER_SERVER_FN service,.. VSTRING *why; int alone = 0; WATCHDOG *watchdog; + char *oval; /* * Process environment options as early as we can. @@ -340,7 +343,7 @@ NORETURN trigger_server_main(int argc, char **argv, TRIGGER_SERVER_FN service,.. */ signal(SIGPIPE, SIG_IGN); - /* + /* * Don't die for frivolous reasons. */ #ifdef SIGXFSZ @@ -407,7 +410,7 @@ NORETURN trigger_server_main(int argc, char **argv, TRIGGER_SERVER_FN service,.. * stderr, because no-one is going to see them. */ opterr = 0; - while ((c = GETOPT(argc, argv, "cDi:lm:n:s:St:uv")) > 0) { + while ((c = GETOPT(argc, argv, "cDi:lm:n:o:s:St:uv")) > 0) { switch (c) { case 'c': root_dir = var_queue_dir; @@ -429,6 +432,11 @@ NORETURN trigger_server_main(int argc, char **argv, TRIGGER_SERVER_FN service,.. case 'n': service_name = optarg; break; + case 'o': + mail_conf_update(optarg, + (oval = split_at(optarg, '=')) ? oval : ""); + mail_params_init(); /* XXX */ + break; case 's': if ((socket_count = atoi(optarg)) <= 0) msg_fatal("invalid socket_count: %s", optarg); diff --git a/postfix/pickup/.indent.pro b/postfix/pickup/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/pickup/.indent.pro +++ b/postfix/pickup/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/pickup/Makefile.in b/postfix/pickup/Makefile.in index 1f20f1934..f43aa9885 100644 --- a/postfix/pickup/Makefile.in +++ b/postfix/pickup/Makefile.in @@ -60,6 +60,7 @@ pickup.o: ../include/scan_dir.h pickup.o: ../include/vstring.h pickup.o: ../include/vbuf.h pickup.o: ../include/vstream.h +pickup.o: ../include/binattr.h pickup.o: ../include/open_as.h pickup.o: ../include/set_eugid.h pickup.o: ../include/mail_queue.h diff --git a/postfix/pickup/pickup.c b/postfix/pickup/pickup.c index 0f1b30bf5..dca0bbb44 100644 --- a/postfix/pickup/pickup.c +++ b/postfix/pickup/pickup.c @@ -206,7 +206,7 @@ static int pickup_copy(VSTREAM *qfile, VSTREAM *cleanup, * network clients that mount the maildrop remotely - especially clients * that can't get their daylight savings offsets right. */ -#define DAY_SECONDS 864000 +#define DAY_SECONDS 86400 #define HOUR_SECONDS 3600 if (info->st.st_mtime > now + 2 * HOUR_SECONDS) { diff --git a/postfix/pipe/.indent.pro b/postfix/pipe/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/pipe/.indent.pro +++ b/postfix/pipe/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/pipe/Makefile.in b/postfix/pipe/Makefile.in index f6879fa0a..72383694a 100644 --- a/postfix/pipe/Makefile.in +++ b/postfix/pipe/Makefile.in @@ -58,6 +58,7 @@ pipe.o: ../include/sys_defs.h pipe.o: ../include/msg.h pipe.o: ../include/vstream.h pipe.o: ../include/vbuf.h +pipe.o: ../include/binattr.h pipe.o: ../include/vstring.h pipe.o: ../include/argv.h pipe.o: ../include/htable.h diff --git a/postfix/pipe/pipe.c b/postfix/pipe/pipe.c index 870bbbdd2..a1127d36e 100644 --- a/postfix/pipe/pipe.c +++ b/postfix/pipe/pipe.c @@ -49,6 +49,10 @@ /* mail system owner. If \fIgroupname\fR is specified, the /* corresponding group ID is used instead of the group ID of /* \fIusername\fR. +/* .IP "\fBeol=string\fR (default: \fB\en\fR)" +/* The output record delimiter. Typically one would use either +/* \fB\er\en\fR or \fB\en\fR. You can specify the usual C-style +/* backslash escape sequences. /* .IP "\fBargv\fR=\fIcommand\fR... (required)" /* The command to be executed. This must be specified as the /* last command attribute. @@ -249,6 +253,7 @@ typedef struct { uid_t uid; /* command privileges */ gid_t gid; /* command privileges */ int flags; /* mail_copy() flags */ + VSTRING *eol; /* output record delimiter */ } PIPE_ATTR; /* parse_callback - callback for mac_parse() */ @@ -418,6 +423,7 @@ static void get_service_attr(PIPE_ATTR *attr, char **argv) group = 0; attr->command = 0; attr->flags = 0; + attr->eol = vstring_strcpy(vstring_alloc(1), "\n"); /* * Iterate over the command-line attribute list. @@ -469,6 +475,13 @@ static void get_service_attr(PIPE_ATTR *attr, char **argv) } } + /* + * eol=string + */ + else if (strncasecmp("eol=", *argv, sizeof("eol=") - 1) == 0) { + unescape(attr->eol, *argv + sizeof("eol=") -1); + } + /* * argv=command... */ @@ -627,6 +640,7 @@ static int deliver_message(DELIVER_REQUEST *request, char *service, char **argv) PIPE_CMD_COPY_FLAGS, attr.flags, PIPE_CMD_ARGV, expanded_argv->argv, PIPE_CMD_TIME_LIMIT, conf.time_limit, + PIPE_CMD_EOL, STR(attr.eol), PIPE_CMD_END); deliver_status = eval_command_status(command_status, service, request, diff --git a/postfix/postalias/.indent.pro b/postfix/postalias/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postalias/.indent.pro +++ b/postfix/postalias/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postalias/Makefile.in b/postfix/postalias/Makefile.in index 1ffd12352..bce6b3822 100644 --- a/postfix/postalias/Makefile.in +++ b/postfix/postalias/Makefile.in @@ -60,6 +60,7 @@ postalias.o: ../include/mymalloc.h postalias.o: ../include/vstring.h postalias.o: ../include/vbuf.h postalias.o: ../include/vstream.h +postalias.o: ../include/binattr.h postalias.o: ../include/msg_vstream.h postalias.o: ../include/readlline.h postalias.o: ../include/stringops.h diff --git a/postfix/postcat/.indent.pro b/postfix/postcat/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postcat/.indent.pro +++ b/postfix/postcat/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postcat/Makefile.in b/postfix/postcat/Makefile.in index 09a495884..0b54c63ba 100644 --- a/postfix/postcat/Makefile.in +++ b/postfix/postcat/Makefile.in @@ -58,6 +58,7 @@ postcat.o: ../include/sys_defs.h postcat.o: ../include/msg.h postcat.o: ../include/vstream.h postcat.o: ../include/vbuf.h +postcat.o: ../include/binattr.h postcat.o: ../include/vstring.h postcat.o: ../include/msg_vstream.h postcat.o: ../include/vstring_vstream.h diff --git a/postfix/postconf/.indent.pro b/postfix/postconf/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postconf/.indent.pro +++ b/postfix/postconf/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postconf/Makefile.in b/postfix/postconf/Makefile.in index 47aab60d0..90ee91269 100644 --- a/postfix/postconf/Makefile.in +++ b/postfix/postconf/Makefile.in @@ -69,9 +69,11 @@ postconf.o: ../include/sys_defs.h postconf.o: ../include/msg.h postconf.o: ../include/vstream.h postconf.o: ../include/vbuf.h +postconf.o: ../include/binattr.h postconf.o: ../include/msg_vstream.h postconf.o: ../include/get_hostname.h postconf.o: ../include/stringops.h +postconf.o: ../include/vstring.h postconf.o: ../include/htable.h postconf.o: ../include/dict.h postconf.o: ../include/argv.h @@ -79,7 +81,6 @@ postconf.o: ../include/safe.h postconf.o: ../include/mymalloc.h postconf.o: ../include/split_at.h postconf.o: ../include/readlline.h -postconf.o: ../include/vstring.h postconf.o: ../include/myflock.h postconf.o: ../include/mynetworks.h postconf.o: ../include/mail_conf.h diff --git a/postfix/postdrop/.indent.pro b/postfix/postdrop/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postdrop/.indent.pro +++ b/postfix/postdrop/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postdrop/Makefile.in b/postfix/postdrop/Makefile.in index 8f24b00c0..f56560015 100644 --- a/postfix/postdrop/Makefile.in +++ b/postfix/postdrop/Makefile.in @@ -59,6 +59,7 @@ postdrop.o: ../include/msg.h postdrop.o: ../include/mymalloc.h postdrop.o: ../include/vstream.h postdrop.o: ../include/vbuf.h +postdrop.o: ../include/binattr.h postdrop.o: ../include/vstring.h postdrop.o: ../include/msg_vstream.h postdrop.o: ../include/msg_syslog.h diff --git a/postfix/postfix/.indent.pro b/postfix/postfix/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postfix/.indent.pro +++ b/postfix/postfix/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postfix/Makefile.in b/postfix/postfix/Makefile.in index b1f63de7c..a35382acb 100644 --- a/postfix/postfix/Makefile.in +++ b/postfix/postfix/Makefile.in @@ -61,9 +61,11 @@ postfix.o: postfix.c postfix.o: ../include/sys_defs.h postfix.o: ../include/vstream.h postfix.o: ../include/vbuf.h +postfix.o: ../include/binattr.h postfix.o: ../include/msg.h postfix.o: ../include/msg_vstream.h postfix.o: ../include/msg_syslog.h postfix.o: ../include/stringops.h +postfix.o: ../include/vstring.h postfix.o: ../include/mail_conf.h postfix.o: ../include/mail_params.h diff --git a/postfix/postkick/.indent.pro b/postfix/postkick/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postkick/.indent.pro +++ b/postfix/postkick/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postkick/Makefile.in b/postfix/postkick/Makefile.in index c846ca697..46036d384 100644 --- a/postfix/postkick/Makefile.in +++ b/postfix/postkick/Makefile.in @@ -59,6 +59,7 @@ postkick.o: ../include/msg.h postkick.o: ../include/mymalloc.h postkick.o: ../include/vstream.h postkick.o: ../include/vbuf.h +postkick.o: ../include/binattr.h postkick.o: ../include/msg_vstream.h postkick.o: ../include/safe.h postkick.o: ../include/mail_proto.h diff --git a/postfix/postlock/.indent.pro b/postfix/postlock/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postlock/.indent.pro +++ b/postfix/postlock/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postlock/Makefile.in b/postfix/postlock/Makefile.in index 0d194091b..571d36d9c 100644 --- a/postfix/postlock/Makefile.in +++ b/postfix/postlock/Makefile.in @@ -59,6 +59,7 @@ postlock.o: ../include/msg.h postlock.o: ../include/vstring.h postlock.o: ../include/vbuf.h postlock.o: ../include/vstream.h +postlock.o: ../include/binattr.h postlock.o: ../include/msg_vstream.h postlock.o: ../include/iostuff.h postlock.o: ../include/mail_params.h diff --git a/postfix/postlog/.indent.pro b/postfix/postlog/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postlog/.indent.pro +++ b/postfix/postlog/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postlog/Makefile.in b/postfix/postlog/Makefile.in index e3f00e469..ed5c75e46 100644 --- a/postfix/postlog/Makefile.in +++ b/postfix/postlog/Makefile.in @@ -63,6 +63,7 @@ postlog.o: ../include/msg.h postlog.o: ../include/vstring.h postlog.o: ../include/vbuf.h postlog.o: ../include/vstream.h +postlog.o: ../include/binattr.h postlog.o: ../include/vstring_vstream.h postlog.o: ../include/msg_output.h postlog.o: ../include/msg_vstream.h diff --git a/postfix/postmap/.indent.pro b/postfix/postmap/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postmap/.indent.pro +++ b/postfix/postmap/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postmap/Makefile.in b/postfix/postmap/Makefile.in index db3a6bd5f..0fa850f4d 100644 --- a/postfix/postmap/Makefile.in +++ b/postfix/postmap/Makefile.in @@ -60,6 +60,7 @@ postmap.o: ../include/mymalloc.h postmap.o: ../include/vstring.h postmap.o: ../include/vbuf.h postmap.o: ../include/vstream.h +postmap.o: ../include/binattr.h postmap.o: ../include/msg_vstream.h postmap.o: ../include/readlline.h postmap.o: ../include/stringops.h diff --git a/postfix/postsuper/.indent.pro b/postfix/postsuper/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/postsuper/.indent.pro +++ b/postfix/postsuper/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/postsuper/Makefile.in b/postfix/postsuper/Makefile.in index b5caf22cb..eb8068c83 100644 --- a/postfix/postsuper/Makefile.in +++ b/postfix/postsuper/Makefile.in @@ -60,6 +60,7 @@ postsuper.o: ../include/msg.h postsuper.o: ../include/msg_syslog.h postsuper.o: ../include/vstream.h postsuper.o: ../include/vbuf.h +postsuper.o: ../include/binattr.h postsuper.o: ../include/msg_vstream.h postsuper.o: ../include/scan_dir.h postsuper.o: ../include/vstring.h diff --git a/postfix/qmgr/.indent.pro b/postfix/qmgr/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/qmgr/.indent.pro +++ b/postfix/qmgr/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/qmgr/Makefile.in b/postfix/qmgr/Makefile.in index 99ce9e6ef..b24a64812 100644 --- a/postfix/qmgr/Makefile.in +++ b/postfix/qmgr/Makefile.in @@ -64,6 +64,7 @@ qmgr.o: ../include/msg.h qmgr.o: ../include/events.h qmgr.o: ../include/vstream.h qmgr.o: ../include/vbuf.h +qmgr.o: ../include/binattr.h qmgr.o: ../include/dict.h qmgr.o: ../include/argv.h qmgr.o: ../include/mail_queue.h @@ -85,6 +86,7 @@ qmgr_active.o: ../include/events.h qmgr_active.o: ../include/mymalloc.h qmgr_active.o: ../include/vstream.h qmgr_active.o: ../include/vbuf.h +qmgr_active.o: ../include/binattr.h qmgr_active.o: ../include/mail_params.h qmgr_active.o: ../include/mail_open_ok.h qmgr_active.o: ../include/mail_queue.h @@ -104,6 +106,7 @@ qmgr_bounce.o: ../include/bounce.h qmgr_bounce.o: ../include/deliver_completed.h qmgr_bounce.o: ../include/vstream.h qmgr_bounce.o: ../include/vbuf.h +qmgr_bounce.o: ../include/binattr.h qmgr_bounce.o: qmgr.h qmgr_bounce.o: ../include/scan_dir.h qmgr_bounce.o: ../include/maps.h @@ -114,6 +117,7 @@ qmgr_defer.o: ../include/sys_defs.h qmgr_defer.o: ../include/msg.h qmgr_defer.o: ../include/vstream.h qmgr_defer.o: ../include/vbuf.h +qmgr_defer.o: ../include/binattr.h qmgr_defer.o: ../include/defer.h qmgr_defer.o: ../include/bounce.h qmgr_defer.o: qmgr.h @@ -127,6 +131,7 @@ qmgr_deliver.o: ../include/msg.h qmgr_deliver.o: ../include/vstring.h qmgr_deliver.o: ../include/vbuf.h qmgr_deliver.o: ../include/vstream.h +qmgr_deliver.o: ../include/binattr.h qmgr_deliver.o: ../include/vstring_vstream.h qmgr_deliver.o: ../include/events.h qmgr_deliver.o: ../include/iostuff.h @@ -144,6 +149,7 @@ qmgr_enable.o: ../include/sys_defs.h qmgr_enable.o: ../include/msg.h qmgr_enable.o: ../include/vstream.h qmgr_enable.o: ../include/vbuf.h +qmgr_enable.o: ../include/binattr.h qmgr_enable.o: qmgr.h qmgr_enable.o: ../include/scan_dir.h qmgr_enable.o: ../include/maps.h @@ -156,6 +162,7 @@ qmgr_entry.o: ../include/mymalloc.h qmgr_entry.o: ../include/events.h qmgr_entry.o: ../include/vstream.h qmgr_entry.o: ../include/vbuf.h +qmgr_entry.o: ../include/binattr.h qmgr_entry.o: ../include/mail_params.h qmgr_entry.o: qmgr.h qmgr_entry.o: ../include/scan_dir.h @@ -169,6 +176,7 @@ qmgr_message.o: ../include/mymalloc.h qmgr_message.o: ../include/vstring.h qmgr_message.o: ../include/vbuf.h qmgr_message.o: ../include/vstream.h +qmgr_message.o: ../include/binattr.h qmgr_message.o: ../include/split_at.h qmgr_message.o: ../include/valid_hostname.h qmgr_message.o: ../include/argv.h @@ -198,6 +206,7 @@ qmgr_move.o: ../include/mail_queue.h qmgr_move.o: ../include/vstring.h qmgr_move.o: ../include/vbuf.h qmgr_move.o: ../include/vstream.h +qmgr_move.o: ../include/binattr.h qmgr_move.o: ../include/mail_scan_dir.h qmgr_move.o: qmgr.h qmgr_move.o: ../include/maps.h @@ -214,6 +223,7 @@ qmgr_queue.o: ../include/recipient_list.h qmgr_queue.o: qmgr.h qmgr_queue.o: ../include/vstream.h qmgr_queue.o: ../include/vbuf.h +qmgr_queue.o: ../include/binattr.h qmgr_queue.o: ../include/scan_dir.h qmgr_queue.o: ../include/maps.h qmgr_queue.o: ../include/dict.h @@ -224,6 +234,7 @@ qmgr_rcpt_list.o: ../include/mymalloc.h qmgr_rcpt_list.o: qmgr.h qmgr_rcpt_list.o: ../include/vstream.h qmgr_rcpt_list.o: ../include/vbuf.h +qmgr_rcpt_list.o: ../include/binattr.h qmgr_rcpt_list.o: ../include/scan_dir.h qmgr_rcpt_list.o: ../include/maps.h qmgr_rcpt_list.o: ../include/dict.h @@ -237,6 +248,7 @@ qmgr_scan.o: ../include/mail_scan_dir.h qmgr_scan.o: qmgr.h qmgr_scan.o: ../include/vstream.h qmgr_scan.o: ../include/vbuf.h +qmgr_scan.o: ../include/binattr.h qmgr_scan.o: ../include/maps.h qmgr_scan.o: ../include/dict.h qmgr_scan.o: ../include/argv.h @@ -248,6 +260,7 @@ qmgr_transport.o: ../include/events.h qmgr_transport.o: ../include/mymalloc.h qmgr_transport.o: ../include/vstream.h qmgr_transport.o: ../include/vbuf.h +qmgr_transport.o: ../include/binattr.h qmgr_transport.o: ../include/iostuff.h qmgr_transport.o: ../include/mail_proto.h qmgr_transport.o: ../include/recipient_list.h diff --git a/postfix/sendmail/.indent.pro b/postfix/sendmail/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/sendmail/.indent.pro +++ b/postfix/sendmail/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/sendmail/Makefile.in b/postfix/sendmail/Makefile.in index da946438b..50a3c8e27 100644 --- a/postfix/sendmail/Makefile.in +++ b/postfix/sendmail/Makefile.in @@ -59,6 +59,7 @@ sendmail.o: ../include/msg.h sendmail.o: ../include/mymalloc.h sendmail.o: ../include/vstream.h sendmail.o: ../include/vbuf.h +sendmail.o: ../include/binattr.h sendmail.o: ../include/vstring.h sendmail.o: ../include/msg_vstream.h sendmail.o: ../include/msg_syslog.h diff --git a/postfix/showq/.indent.pro b/postfix/showq/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/showq/.indent.pro +++ b/postfix/showq/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/showq/Makefile.in b/postfix/showq/Makefile.in index ec75f8c9b..7a2c010a4 100644 --- a/postfix/showq/Makefile.in +++ b/postfix/showq/Makefile.in @@ -60,6 +60,7 @@ showq.o: ../include/scan_dir.h showq.o: ../include/vstring.h showq.o: ../include/vbuf.h showq.o: ../include/vstream.h +showq.o: ../include/binattr.h showq.o: ../include/vstring_vstream.h showq.o: ../include/stringops.h showq.o: ../include/mymalloc.h diff --git a/postfix/smtp/.indent.pro b/postfix/smtp/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/smtp/.indent.pro +++ b/postfix/smtp/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/smtp/Makefile.in b/postfix/smtp/Makefile.in index 48239ba6b..d35b6a382 100644 --- a/postfix/smtp/Makefile.in +++ b/postfix/smtp/Makefile.in @@ -74,6 +74,7 @@ smtp.o: ../include/sys_defs.h smtp.o: ../include/dict.h smtp.o: ../include/vstream.h smtp.o: ../include/vbuf.h +smtp.o: ../include/binattr.h smtp.o: ../include/argv.h smtp.o: ../include/msg.h smtp.o: ../include/mymalloc.h @@ -88,6 +89,7 @@ smtp.o: ../include/mail_error.h smtp.o: ../include/deliver_pass.h smtp.o: ../include/mail_proto.h smtp.o: ../include/iostuff.h +smtp.o: ../include/smtp_stream.h smtp.o: ../include/mail_server.h smtp.o: smtp.h smtp.o: smtp_sasl.h @@ -104,6 +106,7 @@ smtp_addr.o: ../include/own_inet_addr.h smtp_addr.o: ../include/dns.h smtp_addr.o: smtp.h smtp_addr.o: ../include/vstream.h +smtp_addr.o: ../include/binattr.h smtp_addr.o: ../include/argv.h smtp_addr.o: ../include/deliver_request.h smtp_addr.o: ../include/recipient_list.h @@ -114,6 +117,7 @@ smtp_chat.o: ../include/msg.h smtp_chat.o: ../include/vstring.h smtp_chat.o: ../include/vbuf.h smtp_chat.o: ../include/vstream.h +smtp_chat.o: ../include/binattr.h smtp_chat.o: ../include/argv.h smtp_chat.o: ../include/stringops.h smtp_chat.o: ../include/line_wrap.h @@ -131,6 +135,7 @@ smtp_connect.o: ../include/sys_defs.h smtp_connect.o: ../include/msg.h smtp_connect.o: ../include/vstream.h smtp_connect.o: ../include/vbuf.h +smtp_connect.o: ../include/binattr.h smtp_connect.o: ../include/vstring.h smtp_connect.o: ../include/split_at.h smtp_connect.o: ../include/mymalloc.h @@ -151,6 +156,7 @@ smtp_proto.o: ../include/msg.h smtp_proto.o: ../include/vstring.h smtp_proto.o: ../include/vbuf.h smtp_proto.o: ../include/vstream.h +smtp_proto.o: ../include/binattr.h smtp_proto.o: ../include/vstring_vstream.h smtp_proto.o: ../include/stringops.h smtp_proto.o: ../include/mymalloc.h @@ -176,6 +182,8 @@ smtp_sasl_glue.o: ../include/sys_defs.h smtp_sasl_glue.o: ../include/msg.h smtp_sasl_glue.o: ../include/mymalloc.h smtp_sasl_glue.o: ../include/stringops.h +smtp_sasl_glue.o: ../include/vstring.h +smtp_sasl_glue.o: ../include/vbuf.h smtp_sasl_glue.o: ../include/split_at.h smtp_sasl_glue.o: ../include/name_mask.h smtp_sasl_glue.o: ../include/mail_params.h @@ -183,10 +191,9 @@ smtp_sasl_glue.o: ../include/string_list.h smtp_sasl_glue.o: ../include/maps.h smtp_sasl_glue.o: ../include/dict.h smtp_sasl_glue.o: ../include/vstream.h -smtp_sasl_glue.o: ../include/vbuf.h +smtp_sasl_glue.o: ../include/binattr.h smtp_sasl_glue.o: ../include/argv.h smtp_sasl_glue.o: smtp.h -smtp_sasl_glue.o: ../include/vstring.h smtp_sasl_glue.o: ../include/deliver_request.h smtp_sasl_glue.o: ../include/recipient_list.h smtp_sasl_glue.o: smtp_sasl.h @@ -198,6 +205,7 @@ smtp_sasl_proto.o: ../include/mail_params.h smtp_sasl_proto.o: smtp.h smtp_sasl_proto.o: ../include/vstream.h smtp_sasl_proto.o: ../include/vbuf.h +smtp_sasl_proto.o: ../include/binattr.h smtp_sasl_proto.o: ../include/vstring.h smtp_sasl_proto.o: ../include/argv.h smtp_sasl_proto.o: ../include/deliver_request.h @@ -208,9 +216,10 @@ smtp_session.o: ../include/sys_defs.h smtp_session.o: ../include/mymalloc.h smtp_session.o: ../include/vstream.h smtp_session.o: ../include/vbuf.h +smtp_session.o: ../include/binattr.h smtp_session.o: ../include/stringops.h -smtp_session.o: smtp.h smtp_session.o: ../include/vstring.h +smtp_session.o: smtp.h smtp_session.o: ../include/argv.h smtp_session.o: ../include/deliver_request.h smtp_session.o: ../include/recipient_list.h @@ -220,6 +229,7 @@ smtp_state.o: ../include/mymalloc.h smtp_state.o: ../include/vstring.h smtp_state.o: ../include/vbuf.h smtp_state.o: ../include/vstream.h +smtp_state.o: ../include/binattr.h smtp_state.o: ../include/mail_conf.h smtp_state.o: smtp.h smtp_state.o: ../include/argv.h @@ -235,6 +245,7 @@ smtp_trouble.o: ../include/stringops.h smtp_trouble.o: ../include/mymalloc.h smtp_trouble.o: ../include/smtp_stream.h smtp_trouble.o: ../include/vstream.h +smtp_trouble.o: ../include/binattr.h smtp_trouble.o: ../include/deliver_request.h smtp_trouble.o: ../include/recipient_list.h smtp_trouble.o: ../include/deliver_completed.h @@ -253,6 +264,7 @@ smtp_unalias.o: ../include/msg.h smtp_unalias.o: ../include/dns.h smtp_unalias.o: smtp.h smtp_unalias.o: ../include/vstream.h +smtp_unalias.o: ../include/binattr.h smtp_unalias.o: ../include/argv.h smtp_unalias.o: ../include/deliver_request.h smtp_unalias.o: ../include/recipient_list.h diff --git a/postfix/smtp/smtp.c b/postfix/smtp/smtp.c index 27a577d94..3100e7155 100644 --- a/postfix/smtp/smtp.c +++ b/postfix/smtp/smtp.c @@ -198,6 +198,7 @@ #include #include #include +#include /* Single server skeleton. */ @@ -291,6 +292,7 @@ static int deliver_message(DELIVER_REQUEST *request) "%s", vstring_str(why)); } else { debug_peer_check(state->session->host, state->session->addr); + smtp_jump_setup(state->session->stream, state->jbuf); if (smtp_helo(state) == 0) smtp_xfer(state); if (state->history != 0 diff --git a/postfix/smtp/smtp.h b/postfix/smtp/smtp.h index d73494871..b1ff99142 100644 --- a/postfix/smtp/smtp.h +++ b/postfix/smtp/smtp.h @@ -8,6 +8,11 @@ /* DESCRIPTION /* .nf + /* + * System library. + */ +#include + /* * SASL library. */ @@ -52,6 +57,7 @@ typedef struct SMTP_STATE { VSTRING *sasl_decoded; /* decoding buffer */ sasl_callback_t *sasl_callbacks; /* stateful callbacks */ #endif + jmp_buf jbuf[1]; /* exception context */ } SMTP_STATE; #define SMTP_FEATURE_ESMTP (1<<0) diff --git a/postfix/smtp/smtp_proto.c b/postfix/smtp/smtp_proto.c index 600280160..7e3f2debe 100644 --- a/postfix/smtp/smtp_proto.c +++ b/postfix/smtp/smtp_proto.c @@ -158,7 +158,7 @@ int smtp_helo(SMTP_STATE *state) * Prepare for disaster. */ smtp_timeout_setup(state->session->stream, var_smtp_helo_tmout); - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(state->jbuf[0])) != 0) return (smtp_stream_except(state, except, "sending HELO")); /* @@ -439,7 +439,7 @@ int smtp_xfer(SMTP_STATE *state) */ smtp_timeout_setup(state->session->stream, *xfer_timeouts[recv_state]); - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(state->jbuf[0])) != 0) RETURN(smtp_stream_except(state, except, xfer_states[recv_state])); resp = smtp_chat_resp(state); @@ -591,7 +591,7 @@ int smtp_xfer(SMTP_STATE *state) if (send_state == SMTP_STATE_DOT && nrcpt > 0) { smtp_timeout_setup(state->session->stream, var_smtp_data1_tmout); - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(state->jbuf[0])) != 0) RETURN(smtp_stream_except(state, except, "sending message body")); diff --git a/postfix/smtp/smtp_trouble.c b/postfix/smtp/smtp_trouble.c index 04f5d4eb4..0085bda69 100644 --- a/postfix/smtp/smtp_trouble.c +++ b/postfix/smtp/smtp_trouble.c @@ -91,7 +91,6 @@ #include #include /* 44BSD stdarg.h uses abort() */ -#include #include /* Utility library. */ diff --git a/postfix/smtpd/.indent.pro b/postfix/smtpd/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/smtpd/.indent.pro +++ b/postfix/smtpd/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/smtpd/Makefile.in b/postfix/smtpd/Makefile.in index 3f2c7fc9f..b20ef9557 100644 --- a/postfix/smtpd/Makefile.in +++ b/postfix/smtpd/Makefile.in @@ -100,6 +100,7 @@ smtpd.o: ../include/mymalloc.h smtpd.o: ../include/vstring.h smtpd.o: ../include/vbuf.h smtpd.o: ../include/vstream.h +smtpd.o: ../include/binattr.h smtpd.o: ../include/vstring_vstream.h smtpd.o: ../include/stringops.h smtpd.o: ../include/events.h @@ -138,6 +139,7 @@ smtpd_chat.o: ../include/argv.h smtpd_chat.o: ../include/vstring.h smtpd_chat.o: ../include/vbuf.h smtpd_chat.o: ../include/vstream.h +smtpd_chat.o: ../include/binattr.h smtpd_chat.o: ../include/stringops.h smtpd_chat.o: ../include/line_wrap.h smtpd_chat.o: ../include/mymalloc.h @@ -168,6 +170,7 @@ smtpd_check.o: ../include/argv.h smtpd_check.o: ../include/mymalloc.h smtpd_check.o: ../include/dict.h smtpd_check.o: ../include/vstream.h +smtpd_check.o: ../include/binattr.h smtpd_check.o: ../include/htable.h smtpd_check.o: ../include/dns.h smtpd_check.o: ../include/namadr_list.h @@ -191,10 +194,11 @@ smtpd_peer.o: ../include/msg.h smtpd_peer.o: ../include/mymalloc.h smtpd_peer.o: ../include/valid_hostname.h smtpd_peer.o: ../include/stringops.h +smtpd_peer.o: ../include/vstring.h +smtpd_peer.o: ../include/vbuf.h smtpd_peer.o: smtpd.h smtpd_peer.o: ../include/vstream.h -smtpd_peer.o: ../include/vbuf.h -smtpd_peer.o: ../include/vstring.h +smtpd_peer.o: ../include/binattr.h smtpd_peer.o: ../include/argv.h smtpd_peer.o: ../include/mail_stream.h smtpd_sasl_glue.o: smtpd_sasl_glue.c @@ -208,6 +212,7 @@ smtpd_sasl_glue.o: ../include/smtp_stream.h smtpd_sasl_glue.o: ../include/vstring.h smtpd_sasl_glue.o: ../include/vbuf.h smtpd_sasl_glue.o: ../include/vstream.h +smtpd_sasl_glue.o: ../include/binattr.h smtpd_sasl_glue.o: smtpd.h smtpd_sasl_glue.o: ../include/argv.h smtpd_sasl_glue.o: ../include/mail_stream.h @@ -221,6 +226,7 @@ smtpd_sasl_proto.o: ../include/mail_params.h smtpd_sasl_proto.o: ../include/mail_proto.h smtpd_sasl_proto.o: ../include/vstream.h smtpd_sasl_proto.o: ../include/vbuf.h +smtpd_sasl_proto.o: ../include/binattr.h smtpd_sasl_proto.o: ../include/iostuff.h smtpd_sasl_proto.o: ../include/mail_error.h smtpd_sasl_proto.o: ../include/name_mask.h @@ -238,6 +244,7 @@ smtpd_state.o: ../include/events.h smtpd_state.o: ../include/mymalloc.h smtpd_state.o: ../include/vstream.h smtpd_state.o: ../include/vbuf.h +smtpd_state.o: ../include/binattr.h smtpd_state.o: ../include/name_mask.h smtpd_state.o: ../include/msg.h smtpd_state.o: ../include/cleanup_user.h diff --git a/postfix/smtpd/smtpd.c b/postfix/smtpd/smtpd.c index 7b3c436e2..5285bcfbd 100644 --- a/postfix/smtpd/smtpd.c +++ b/postfix/smtpd/smtpd.c @@ -1145,9 +1145,10 @@ static void smtpd_proto(SMTPD_STATE *state) * cleans up, but no attempt is made to inform the client of the nature * of the problem. */ + smtp_jump_setup(state->client, state->jbuf); smtp_timeout_setup(state->client, var_smtpd_tmout); - switch (setjmp(smtp_timeout_buf)) { + switch (setjmp(state->jbuf[0])) { default: msg_panic("smtpd_proto: unknown error reading from %s[%s]", diff --git a/postfix/smtpd/smtpd.h b/postfix/smtpd/smtpd.h index 447ad932e..b39bebab7 100644 --- a/postfix/smtpd/smtpd.h +++ b/postfix/smtpd/smtpd.h @@ -8,6 +8,11 @@ /* DESCRIPTION /* .nf + /* + * System library + */ +#include + /* * SASL library. */ @@ -71,6 +76,7 @@ typedef struct SMTPD_STATE { VSTRING *sasl_encoded; VSTRING *sasl_decoded; #endif + jmp_buf jbuf[1]; } SMTPD_STATE; extern void smtpd_state_init(SMTPD_STATE *, VSTREAM *); diff --git a/postfix/smtpstone/.indent.pro b/postfix/smtpstone/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/smtpstone/.indent.pro +++ b/postfix/smtpstone/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/smtpstone/Makefile.in b/postfix/smtpstone/Makefile.in index 702f55cf6..da2794c34 100644 --- a/postfix/smtpstone/Makefile.in +++ b/postfix/smtpstone/Makefile.in @@ -67,6 +67,7 @@ smtp-sink.o: ../include/msg.h smtp-sink.o: ../include/vstring.h smtp-sink.o: ../include/vbuf.h smtp-sink.o: ../include/vstream.h +smtp-sink.o: ../include/binattr.h smtp-sink.o: ../include/vstring_vstream.h smtp-sink.o: ../include/get_hostname.h smtp-sink.o: ../include/listen.h @@ -81,6 +82,7 @@ smtp-source.o: ../include/msg.h smtp-source.o: ../include/msg_vstream.h smtp-source.o: ../include/vstream.h smtp-source.o: ../include/vbuf.h +smtp-source.o: ../include/binattr.h smtp-source.o: ../include/vstring.h smtp-source.o: ../include/vstring_vstream.h smtp-source.o: ../include/get_hostname.h diff --git a/postfix/smtpstone/smtp-sink.c b/postfix/smtpstone/smtp-sink.c index 7cd5e65e5..8b49d7590 100644 --- a/postfix/smtpstone/smtp-sink.c +++ b/postfix/smtpstone/smtp-sink.c @@ -74,6 +74,7 @@ typedef struct SINK_STATE { int data_state; int (*read) (struct SINK_STATE *); int rcpts; + jmp_buf jbuf[1]; } SINK_STATE; #define ST_ANY 0 @@ -284,7 +285,7 @@ static void read_event(int unused_event, char *context) SINK_STATE *state = (SINK_STATE *) context; do { - switch (setjmp(smtp_timeout_buf)) { + switch (setjmp(state->jbuf[0])) { default: msg_panic("unknown error reading input"); @@ -334,6 +335,7 @@ static void connect_event(int unused_event, char *context) state->stream = vstream_fdopen(fd, O_RDWR); state->read = command_read; state->data_state = 0; + smtp_jump_setup(state->stream, state->jbuf); smtp_timeout_setup(state->stream, var_tmout); smtp_printf(state->stream, "220 %s ESMTP", var_myhostname); event_enable_read(fd, read_event, (char *) state); diff --git a/postfix/smtpstone/smtp-source.c b/postfix/smtpstone/smtp-source.c index 1181ffaff..4ca866e6e 100644 --- a/postfix/smtpstone/smtp-source.c +++ b/postfix/smtpstone/smtp-source.c @@ -8,7 +8,8 @@ /* DESCRIPTION /* smtp-source connects to the named host and port (default 25) /* and sends one or more little messages to it, either sequentially -/* or in parallel. +/* or in parallel. The program speaks either SMTP (default) or +/* LMTP. /* /* Options: /* .IP -c @@ -111,6 +112,7 @@ typedef struct SESSION { VSTREAM *stream; /* open connection */ int connect_count; /* # of connect()s to retry */ struct SESSION *next; /* connect() queue linkage */ + jmp_buf jbuf[1]; /* exception handling */ } SESSION; static SESSION *last_session; /* connect() queue tail */ @@ -388,6 +390,7 @@ static void start_connect(SESSION *session) (void) non_blocking(fd, NON_BLOCKING); session->stream = vstream_fdopen(fd, O_RDWR); event_enable_write(fd, connect_done, (char *) session); + smtp_jump_setup(session->stream, session->jbuf); smtp_timeout_setup(session->stream, var_timeout); if (connect(fd, (struct sockaddr *) & sin, sizeof(sin)) < 0 && errno != EINPROGRESS) @@ -426,8 +429,8 @@ static void read_banner(int unused_event, char *context) /* * Prepare for disaster. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) - msg_fatal("%s while reading HELO", exception_text(except)); + if ((except = setjmp(session->jbuf[0])) != 0) + msg_fatal("%s while reading server greeting", exception_text(except)); /* * Read and parse the server's SMTP greeting banner. @@ -454,7 +457,7 @@ static void send_helo(SESSION *session) /* * Send the standard greeting with our hostname */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending HELO", exception_text(except)); command(session->stream, "%s %s", protocol, var_myhostname); @@ -477,7 +480,7 @@ static void helo_done(int unused_event, char *context) /* * Get response to HELO command. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending HELO", exception_text(except)); if ((resp = response(session->stream, buffer))->code / 100 != 2) @@ -495,7 +498,7 @@ static void send_mail(SESSION *session) /* * Send the envelope sender address. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending sender", exception_text(except)); command(session->stream, "MAIL FROM:<%s>", sender); @@ -518,7 +521,7 @@ static void mail_done(int unused, char *context) /* * Get response to MAIL command. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending sender", exception_text(except)); if ((resp = response(session->stream, buffer))->code / 100 != 2) @@ -539,7 +542,7 @@ static void send_rcpt(int unused_event, char *context) /* * Send envelope recipient address. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending recipient", exception_text(except)); if (session->rcpt_count > 1) @@ -568,7 +571,7 @@ static void rcpt_done(int unused, char *context) /* * Get response to RCPT command. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending recipient", exception_text(except)); if ((resp = response(session->stream, buffer))->code / 100 != 2) @@ -593,7 +596,7 @@ static void send_data(int unused_event, char *context) /* * Request data transmission. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending DATA command", exception_text(except)); command(session->stream, "DATA"); @@ -617,7 +620,7 @@ static void data_done(int unused_event, char *context) /* * Get response to DATA command. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending DATA command", exception_text(except)); if ((resp = response(session->stream, buffer))->code != 354) msg_fatal("data %d %s", resp->code, resp->str); @@ -641,7 +644,7 @@ static void data_done(int unused_event, char *context) /* * Send some garbage. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending message", exception_text(except)); if (message_length == 0) { smtp_fputs("La de da de da 1.", 17, session->stream); @@ -684,7 +687,7 @@ static void dot_done(int unused_event, char *context) /* * Get response to "." command. */ - if ((except = setjmp(smtp_timeout_buf)) != 0) + if ((except = setjmp(session->jbuf[0])) != 0) msg_fatal("%s while sending message", exception_text(except)); do { /* XXX this could block */ if ((resp = response(session->stream, buffer))->code / 100 != 2) diff --git a/postfix/spawn/.indent.pro b/postfix/spawn/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/spawn/.indent.pro +++ b/postfix/spawn/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/spawn/spawn.c b/postfix/spawn/spawn.c index 06e094bd5..428ec635c 100644 --- a/postfix/spawn/spawn.c +++ b/postfix/spawn/spawn.c @@ -68,7 +68,7 @@ /* .IP \fIservice\fB_command_time_limit\fR /* The amount of time the command is allowed to run before it is /* killed with force. The \fIservice\fR name is the name of the entry -/* in the \fBmastr.cf\fR file. The default time limit is given by the +/* in the \fBmaster.cf\fR file. The default time limit is given by the /* global \fBcommand_time_limit\fR configuration parameter. /* SEE ALSO /* master(8) process manager diff --git a/postfix/trivial-rewrite/.indent.pro b/postfix/trivial-rewrite/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/trivial-rewrite/.indent.pro +++ b/postfix/trivial-rewrite/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/trivial-rewrite/Makefile.in b/postfix/trivial-rewrite/Makefile.in index a944bf153..7aa7d8b8b 100644 --- a/postfix/trivial-rewrite/Makefile.in +++ b/postfix/trivial-rewrite/Makefile.in @@ -65,6 +65,7 @@ resolve.o: ../include/msg.h resolve.o: ../include/vstring.h resolve.o: ../include/vbuf.h resolve.o: ../include/vstream.h +resolve.o: ../include/binattr.h resolve.o: ../include/vstring_vstream.h resolve.o: ../include/split_at.h resolve.o: ../include/mail_params.h @@ -85,6 +86,7 @@ rewrite.o: ../include/msg.h rewrite.o: ../include/vstring.h rewrite.o: ../include/vbuf.h rewrite.o: ../include/vstream.h +rewrite.o: ../include/binattr.h rewrite.o: ../include/vstring_vstream.h rewrite.o: ../include/split_at.h rewrite.o: ../include/mail_params.h @@ -99,12 +101,13 @@ transport.o: transport.c transport.o: ../include/sys_defs.h transport.o: ../include/msg.h transport.o: ../include/stringops.h -transport.o: ../include/mymalloc.h transport.o: ../include/vstring.h transport.o: ../include/vbuf.h +transport.o: ../include/mymalloc.h transport.o: ../include/split_at.h transport.o: ../include/dict.h transport.o: ../include/vstream.h +transport.o: ../include/binattr.h transport.o: ../include/argv.h transport.o: ../include/mail_params.h transport.o: ../include/maps.h @@ -115,6 +118,7 @@ trivial-rewrite.o: ../include/msg.h trivial-rewrite.o: ../include/vstring.h trivial-rewrite.o: ../include/vbuf.h trivial-rewrite.o: ../include/vstream.h +trivial-rewrite.o: ../include/binattr.h trivial-rewrite.o: ../include/vstring_vstream.h trivial-rewrite.o: ../include/split_at.h trivial-rewrite.o: ../include/stringops.h diff --git a/postfix/util/.indent.pro b/postfix/util/.indent.pro index f9b8f2287..2139804a4 100644 --- a/postfix/util/.indent.pro +++ b/postfix/util/.indent.pro @@ -1,6 +1,8 @@ -TALIAS_TOKEN -TARGV -TBH_TABLE +-TBINATTR +-TBINATTR_INFO -TBINHASH -TBINHASH_INFO -TBOUNCE_STAT @@ -44,6 +46,7 @@ -THTABLE_INFO -TINET_ADDR_LIST -TINT_TABLE +-TJMP_BUF_WRAPPER -TLOCAL_EXP -TLOCAL_STATE -TMAC_EXP diff --git a/postfix/util/Makefile.in b/postfix/util/Makefile.in index 349b29d43..dc8e0546c 100644 --- a/postfix/util/Makefile.in +++ b/postfix/util/Makefile.in @@ -21,7 +21,8 @@ SRCS = argv.c argv_split.c attr.c basename.c binhash.c chroot_uid.c \ write_buf.c write_wait.c dict_unix.c dict_pcre.c stream_listen.c \ stream_connect.c stream_trigger.c dict_regexp.c mac_expand.c \ clean_env.c watchdog.c spawn_command.c duplex_pipe.c sane_rename.c \ - sane_link.c + sane_link.c unescape.c timed_read.c timed_write.c binattr.c \ + vstream_attr.c OBJS = argv.o argv_split.o attr.o basename.o binhash.o chroot_uid.o \ close_on_exec.o concatenate.o dict.o dict_db.o dict_dbm.o \ dict_env.o dict_ht.o dict_ldap.o dict_mysql.o dict_ni.o dict_nis.o \ @@ -44,7 +45,8 @@ OBJS = argv.o argv_split.o attr.o basename.o binhash.o chroot_uid.o \ write_buf.o write_wait.o dict_unix.o dict_pcre.o stream_listen.o \ stream_connect.o stream_trigger.o dict_regexp.o mac_expand.o \ clean_env.o watchdog.o spawn_command.o duplex_pipe.o sane_rename.o \ - sane_link.o + sane_link.o unescape.o timed_read.o timed_write.o binattr.o \ + vstream_attr.o HDRS = argv.h attr.h binhash.h chroot_uid.h connect.h dict.h dict_db.h \ dict_dbm.h dict_env.h dict_ht.h dict_ldap.h dict_mysql.h \ dict_ni.h dict_nis.h dict_nisplus.h dir_forest.h events.h \ @@ -59,7 +61,7 @@ HDRS = argv.h attr.h binhash.h chroot_uid.h connect.h dict.h dict_db.h \ timed_connect.h timed_wait.h trigger.h username.h valid_hostname.h \ vbuf.h vbuf_print.h vstream.h vstring.h vstring_vstream.h \ dict_unix.h dict_pcre.h dict_regexp.h mac_expand.h clean_env.h \ - watchdog.h spawn_command.h sane_fsops.h + watchdog.h spawn_command.h sane_fsops.h binattr.h TESTSRC = fifo_open.c fifo_rdwr_bug.c fifo_rdonly_bug.c select_bug.c \ stream_test.c dup2_pass_on_exec.c WARN = -W -Wformat -Wimplicit -Wmissing-prototypes \ @@ -75,7 +77,7 @@ TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \ inet_addr_host inet_addr_local mac_parse make_dirs msg_syslog \ mystrtok peer_name sigdelay translit valid_hostname vstream_popen \ vstring vstring_vstream doze select_bug stream_test mac_expand \ - watchdog + watchdog unescape LIB_DIR = ../lib INC_DIR = ../include @@ -249,6 +251,11 @@ watchdog: $(LIB) $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS) mv junk $@.o +unescape: $(LIB) + mv $@.o junk + $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS) + mv junk $@.o + depend: $(MAKES) (sed '1,/^# do not edit/!d' Makefile.in; \ set -e; for i in [a-z][a-z0-9]*.c; do \ @@ -260,7 +267,7 @@ depend: $(MAKES) stream_test: stream_test.c $(LIB) $(CC) $(CFLAGS) -o $@ $@.c $(LIB) $(SYSLIBS) -tests: valid_hostname_test mac_expand_test dict_test +tests: valid_hostname_test mac_expand_test dict_test unescape_test valid_hostname_test: valid_hostname valid_hostname.in valid_hostname.ref ./valid_hostname valid_hostname.tmp @@ -272,6 +279,11 @@ mac_expand_test: mac_expand mac_expand.in mac_expand.ref diff mac_expand.ref mac_expand.tmp rm -f mac_expand.tmp +unescape_test: unescape unescape.in unescape.ref + ./unescape unescape.tmp + diff -b unescape.ref unescape.tmp + rm -f unescape.tmp + DB_TYPE = `../postconf/postconf -h default_database_type` dict_test: dict_open testdb dict_test.in dict_test.ref @@ -292,6 +304,8 @@ argv_split.o: argv_split.c argv_split.o: sys_defs.h argv_split.o: mymalloc.h argv_split.o: stringops.h +argv_split.o: vstring.h +argv_split.o: vbuf.h argv_split.o: argv.h attr.o: attr.c attr.o: sys_defs.h @@ -301,6 +315,13 @@ attr.o: attr.h basename.o: basename.c basename.o: sys_defs.h basename.o: stringops.h +basename.o: vstring.h +basename.o: vbuf.h +binattr.o: binattr.c +binattr.o: sys_defs.h +binattr.o: mymalloc.h +binattr.o: htable.h +binattr.o: binattr.h binhash.o: binhash.c binhash.o: sys_defs.h binhash.o: mymalloc.h @@ -322,6 +343,8 @@ concatenate.o: concatenate.c concatenate.o: sys_defs.h concatenate.o: mymalloc.h concatenate.o: stringops.h +concatenate.o: vstring.h +concatenate.o: vbuf.h dict.o: dict.c dict.o: sys_defs.h dict.o: msg.h @@ -329,6 +352,7 @@ dict.o: htable.h dict.o: mymalloc.h dict.o: vstream.h dict.o: vbuf.h +dict.o: binattr.h dict.o: vstring.h dict.o: readlline.h dict.o: mac_parse.h @@ -346,6 +370,7 @@ dict_db.o: iostuff.h dict_db.o: myflock.h dict_db.o: dict.h dict_db.o: vstream.h +dict_db.o: binattr.h dict_db.o: argv.h dict_db.o: dict_db.h dict_dbm.o: dict_dbm.c @@ -358,6 +383,7 @@ dict_env.o: safe.h dict_env.o: dict.h dict_env.o: vstream.h dict_env.o: vbuf.h +dict_env.o: binattr.h dict_env.o: argv.h dict_env.o: dict_env.h dict_ht.o: dict_ht.c @@ -367,6 +393,7 @@ dict_ht.o: htable.h dict_ht.o: dict.h dict_ht.o: vstream.h dict_ht.o: vbuf.h +dict_ht.o: binattr.h dict_ht.o: argv.h dict_ht.o: dict_ht.h dict_ldap.o: dict_ldap.c @@ -383,6 +410,7 @@ dict_nis.o: vstring.h dict_nis.o: vbuf.h dict_nis.o: dict.h dict_nis.o: vstream.h +dict_nis.o: binattr.h dict_nis.o: argv.h dict_nis.o: dict_nis.h dict_nisplus.o: dict_nisplus.c @@ -393,6 +421,7 @@ dict_nisplus.o: htable.h dict_nisplus.o: dict.h dict_nisplus.o: vstream.h dict_nisplus.o: vbuf.h +dict_nisplus.o: binattr.h dict_nisplus.o: argv.h dict_nisplus.o: dict_nisplus.h dict_open.o: dict_open.c @@ -403,6 +432,7 @@ dict_open.o: msg.h dict_open.o: dict.h dict_open.o: vstream.h dict_open.o: vbuf.h +dict_open.o: binattr.h dict_open.o: dict_env.h dict_open.o: dict_unix.h dict_open.o: dict_dbm.h @@ -415,6 +445,7 @@ dict_open.o: dict_mysql.h dict_open.o: dict_pcre.h dict_open.o: dict_regexp.h dict_open.o: stringops.h +dict_open.o: vstring.h dict_open.o: split_at.h dict_open.o: htable.h dict_pcre.o: dict_pcre.c @@ -426,6 +457,7 @@ dict_regexp.o: msg.h dict_regexp.o: safe.h dict_regexp.o: vstream.h dict_regexp.o: vbuf.h +dict_regexp.o: binattr.h dict_regexp.o: vstring.h dict_regexp.o: stringops.h dict_regexp.o: readlline.h @@ -441,6 +473,7 @@ dict_unix.o: vstring.h dict_unix.o: vbuf.h dict_unix.o: dict.h dict_unix.o: vstream.h +dict_unix.o: binattr.h dict_unix.o: argv.h dict_unix.o: dict_unix.h dir_forest.o: dir_forest.c @@ -571,6 +604,8 @@ line_wrap.o: line_wrap.h lowercase.o: lowercase.c lowercase.o: sys_defs.h lowercase.o: stringops.h +lowercase.o: vstring.h +lowercase.o: vbuf.h lstat_as.o: lstat_as.c lstat_as.o: sys_defs.h lstat_as.o: msg.h @@ -595,6 +630,8 @@ make_dirs.o: sys_defs.h make_dirs.o: msg.h make_dirs.o: mymalloc.h make_dirs.o: stringops.h +make_dirs.o: vstring.h +make_dirs.o: vbuf.h make_dirs.o: make_dirs.h match_list.o: match_list.c match_list.o: sys_defs.h @@ -603,6 +640,7 @@ match_list.o: mymalloc.h match_list.o: vstring.h match_list.o: vbuf.h match_list.o: vstream.h +match_list.o: binattr.h match_list.o: vstring_vstream.h match_list.o: stringops.h match_list.o: argv.h @@ -616,9 +654,11 @@ match_ops.o: split_at.h match_ops.o: dict.h match_ops.o: vstream.h match_ops.o: vbuf.h +match_ops.o: binattr.h match_ops.o: argv.h match_ops.o: match_ops.h match_ops.o: stringops.h +match_ops.o: vstring.h msg.o: msg.c msg.o: sys_defs.h msg.o: msg.h @@ -629,6 +669,7 @@ msg_output.o: mymalloc.h msg_output.o: vstring.h msg_output.o: vbuf.h msg_output.o: vstream.h +msg_output.o: binattr.h msg_output.o: msg_vstream.h msg_output.o: stringops.h msg_output.o: percentm.h @@ -645,6 +686,7 @@ msg_vstream.o: msg_vstream.c msg_vstream.o: sys_defs.h msg_vstream.o: vstream.h msg_vstream.o: vbuf.h +msg_vstream.o: binattr.h msg_vstream.o: msg.h msg_vstream.o: msg_output.h msg_vstream.o: msg_vstream.h @@ -663,11 +705,15 @@ mymalloc.o: mymalloc.h mystrtok.o: mystrtok.c mystrtok.o: sys_defs.h mystrtok.o: stringops.h +mystrtok.o: vstring.h +mystrtok.o: vbuf.h name_mask.o: name_mask.c name_mask.o: sys_defs.h name_mask.o: msg.h name_mask.o: mymalloc.h name_mask.o: stringops.h +name_mask.o: vstring.h +name_mask.o: vbuf.h name_mask.o: name_mask.h non_blocking.o: non_blocking.c non_blocking.o: sys_defs.h @@ -686,6 +732,7 @@ open_lock.o: sys_defs.h open_lock.o: msg.h open_lock.o: vstream.h open_lock.o: vbuf.h +open_lock.o: binattr.h open_lock.o: vstring.h open_lock.o: safe_open.h open_lock.o: myflock.h @@ -704,6 +751,8 @@ posix_signals.o: posix_signals.h printable.o: printable.c printable.o: sys_defs.h printable.o: stringops.h +printable.o: vstring.h +printable.o: vbuf.h read_wait.o: read_wait.c read_wait.o: sys_defs.h read_wait.o: msg.h @@ -716,6 +765,7 @@ readlline.o: readlline.c readlline.o: sys_defs.h readlline.o: vstream.h readlline.o: vbuf.h +readlline.o: binattr.h readlline.o: vstring.h readlline.o: readlline.h ring.o: ring.c @@ -728,6 +778,7 @@ safe_open.o: sys_defs.h safe_open.o: msg.h safe_open.o: vstream.h safe_open.o: vbuf.h +safe_open.o: binattr.h safe_open.o: vstring.h safe_open.o: safe_open.h sane_accept.o: sane_accept.c @@ -754,6 +805,7 @@ select_bug.o: sys_defs.h select_bug.o: msg.h select_bug.o: vstream.h select_bug.o: vbuf.h +select_bug.o: binattr.h select_bug.o: msg_vstream.h set_eugid.o: set_eugid.c set_eugid.o: sys_defs.h @@ -771,6 +823,8 @@ sigdelay.o: sigdelay.h skipblanks.o: skipblanks.c skipblanks.o: sys_defs.h skipblanks.o: stringops.h +skipblanks.o: vstring.h +skipblanks.o: vbuf.h spawn_command.o: spawn_command.c spawn_command.o: sys_defs.h spawn_command.o: msg.h @@ -806,6 +860,7 @@ stream_test.o: msg.h stream_test.o: msg_vstream.h stream_test.o: vstream.h stream_test.o: vbuf.h +stream_test.o: binattr.h stream_test.o: listen.h stream_test.o: connect.h stream_trigger.o: stream_trigger.c @@ -821,17 +876,32 @@ timed_connect.o: sys_defs.h timed_connect.o: msg.h timed_connect.o: iostuff.h timed_connect.o: timed_connect.h +timed_read.o: timed_read.c +timed_read.o: sys_defs.h +timed_read.o: iostuff.h timed_wait.o: timed_wait.c timed_wait.o: sys_defs.h timed_wait.o: msg.h timed_wait.o: posix_signals.h timed_wait.o: timed_wait.h +timed_write.o: timed_write.c +timed_write.o: sys_defs.h +timed_write.o: iostuff.h translit.o: translit.c translit.o: sys_defs.h translit.o: stringops.h +translit.o: vstring.h +translit.o: vbuf.h trimblanks.o: trimblanks.c trimblanks.o: sys_defs.h trimblanks.o: stringops.h +trimblanks.o: vstring.h +trimblanks.o: vbuf.h +unescape.o: unescape.c +unescape.o: sys_defs.h +unescape.o: vstring.h +unescape.o: vbuf.h +unescape.o: stringops.h unix_connect.o: unix_connect.c unix_connect.o: sys_defs.h unix_connect.o: msg.h @@ -861,6 +931,8 @@ valid_hostname.o: sys_defs.h valid_hostname.o: msg.h valid_hostname.o: mymalloc.h valid_hostname.o: stringops.h +valid_hostname.o: vstring.h +valid_hostname.o: vbuf.h valid_hostname.o: valid_hostname.h vbuf.o: vbuf.c vbuf.o: sys_defs.h @@ -877,14 +949,23 @@ vstream.o: mymalloc.h vstream.o: msg.h vstream.o: vbuf_print.h vstream.o: vbuf.h +vstream.o: iostuff.h vstream.o: vstring.h +vstream.o: binattr.h vstream.o: vstream.h +vstream_attr.o: vstream_attr.c +vstream_attr.o: sys_defs.h +vstream_attr.o: vstream.h +vstream_attr.o: vbuf.h +vstream_attr.o: binattr.h +vstream_attr.o: htable.h vstream_popen.o: vstream_popen.c vstream_popen.o: sys_defs.h vstream_popen.o: msg.h vstream_popen.o: exec_command.h vstream_popen.o: vstream.h vstream_popen.o: vbuf.h +vstream_popen.o: binattr.h vstream_popen.o: argv.h vstream_popen.o: set_ugid.h vstream_popen.o: clean_env.h @@ -902,6 +983,7 @@ vstring_vstream.o: msg.h vstring_vstream.o: vstring.h vstring_vstream.o: vbuf.h vstring_vstream.o: vstream.h +vstring_vstream.o: binattr.h vstring_vstream.o: vstring_vstream.h watchdog.o: watchdog.c watchdog.o: sys_defs.h diff --git a/postfix/util/binattr.c b/postfix/util/binattr.c new file mode 100644 index 000000000..a50f58ed2 --- /dev/null +++ b/postfix/util/binattr.c @@ -0,0 +1,165 @@ +/*++ +/* NAME +/* binattr 3 +/* SUMMARY +/* binary-valued attribute list manager +/* SYNOPSIS +/* #include +/* +/* typedef struct { +/* .in +4 +/* char *key; +/* char *value; +/* /* private fields... */ +/* .in -4 +/* } BINATTR_ENTRY; +/* +/* BINATTR *binattr_create(size) +/* int size; +/* +/* char *binattr_get(table, name) +/* BINATTR *table; +/* const char *name; +/* +/* BINATTR_ENTRY *binattr_set(table, name, value, free_fn) +/* BINATTR *table; +/* const char *name; +/* void (*free_fn)(char *); +/* +/* void binattr_unset(table, name) +/* BINATTR *table; +/* const char *name; +/* +/* void binattr_free(table) +/* BINATTR *table; +/* DESCRIPTION +/* This module maintains open attribute lists of arbitrary +/* binary values. Each attribute has a string-valued name. +/* The caller specifies the memory management policy for +/* attribute values, which can be arbitrary binary data. +/* Attribute lists grow on demand as entries are added. +/* +/* binattr_create() creates a table of the specified size, +/* or whatever the underlying code deems suitable. +/* +/* binattr_get() looks up the named attribute in the specified +/* attribute list, and returns the value that was stored with +/* binattr_set(). The result is a null pointer when the requested +/* information is not found. +/* +/* binattr_set() adds or replaces the named entry in the specified +/* attribute list. This function expects as attribute value a +/* generic character pointer. Use proper casts when storing data of +/* a different type, or the result will be undefined. +/* +/* binattr_unset() removes the named attribute from the specified +/* attribute list. This operation is undefined for non-existing +/* attributes. +/* +/* binattr_free() destroys the specified attribute list including +/* the information that is stored in it. +/* +/* Arguments: +/* .IP table +/* Open attribute list created with binattr_create. +/* .IP name +/* Attribute name. Attribute names are unique within a list. +/* .IP value +/* The value stored under the named attribute. +/* .IP free_fn +/* Pointer to function that destroys the value stored under the +/* named attribute, or a null pointer. +/* DIAGNOSTICS +/* Panic: interface violations and internal consistency problems. +/* Fatal errors: out of memory. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include + +/* Utility library. */ + +#include +#include +#include "binattr.h" + +/* binattr_create - create binary attribute list */ + +BINATTR *binattr_create(int size) +{ + return (htable_create(size)); +} + +/* binattr_free - destroy binary attribute list */ + +void binattr_free(BINATTR *table) +{ + HTABLE_INFO **info; + HTABLE_INFO **ht; + BINATTR_INFO *h; + + for (ht = info = htable_list(table); *ht != 0; ht++) { + h = (BINATTR_INFO *) (ht[0]->value); + if (h->free_fn) + h->free_fn(h->value); + } + myfree((char *) info); +} + +/* binattr_get - look up binary attribute */ + +char *binattr_get(BINATTR *table, const char *name) +{ + BINATTR_INFO *info; + + return ((info = (BINATTR_INFO *) htable_find(table, name)) == 0 ? 0 : info->value); +} + +/* binattr_set - set or replace binary attribute */ + +BINATTR_INFO *binattr_set(BINATTR *table, const char *name, char *value, BINATTR_FREE_FN free_fn) +{ + BINATTR_INFO *info; + + if ((info = (BINATTR_INFO *) htable_find(table, name)) != 0) { + if (info->value != value) { + if (info->free_fn) + info->free_fn(info->value); + info->value = value; + } + info->free_fn = free_fn; + } else { + info = (BINATTR_INFO *) mymalloc(sizeof(*info)); + info->value = value; + info->free_fn = free_fn; + htable_enter(table, name, (char *) info); + } + return (info); +} + +/* binattr_free_callback - destructor callback */ + +static void binattr_free_callback(char *ptr) +{ + BINATTR_INFO *info = (BINATTR_INFO *) ptr; + + if (info->free_fn) + info->free_fn(info->value); +} + +/* binattr_unset - remove attribute */ + +void binattr_unset(BINATTR *table, const char *name) +{ + htable_delete(table, name, binattr_free_callback); +} diff --git a/postfix/util/binattr.h b/postfix/util/binattr.h new file mode 100644 index 000000000..d69b9bd1b --- /dev/null +++ b/postfix/util/binattr.h @@ -0,0 +1,51 @@ +#ifndef _BINATTR_H_INCLUDED_ +#define _BINATTR_H_INCLUDED_ + +/*++ +/* NAME +/* binattr 3h +/* SUMMARY +/* binary-valued attribute list manager +/* SYNOPSIS +/* #include +/* DESCRIPTION +/* .nf + + /* Structure of one hash table entry. */ + +typedef void (*BINATTR_FREE_FN) (char *); + +typedef struct BINATTR_INFO { + char *key; /* lookup key */ + char *value; /* associated value */ + BINATTR_FREE_FN free_fn; /* destructor */ +} BINATTR_INFO; + + /* Structure of one hash table. */ + +typedef struct HTABLE BINATTR; + +extern BINATTR *binattr_create(int); +extern void binattr_free(BINATTR *); +extern char *binattr_get(BINATTR *, const char *); +extern BINATTR_INFO *binattr_set(BINATTR *, const char *, char *, BINATTR_FREE_FN); +extern void binattr_unset(BINATTR *, const char *); + +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/* CREATION DATE +/* Fri Feb 14 13:43:19 EST 1997 +/* LAST MODIFICATION +/* %E% %U% +/* VERSION/RELEASE +/* %I% +/*--*/ + +#endif diff --git a/postfix/util/dict_dbm.c b/postfix/util/dict_dbm.c index b5b462fe4..ae7cb0da3 100644 --- a/postfix/util/dict_dbm.c +++ b/postfix/util/dict_dbm.c @@ -37,7 +37,11 @@ /* System library. */ #include +#ifdef PATH_NDBM_H +#include PATH_NDBM_H +#else #include +#endif #include #include diff --git a/postfix/util/htable.c b/postfix/util/htable.c index 29ad1236b..923bdc200 100644 --- a/postfix/util/htable.c +++ b/postfix/util/htable.c @@ -44,7 +44,7 @@ /* void (*action)(HTABLE_INFO *, char *ptr); /* char *ptr; /* -/* HTABLE_INFO *htable_list(table) +/* HTABLE_INFO **htable_list(table) /* HTABLE *table; /* DESCRIPTION /* This module maintains one or more hash tables. Each table entry diff --git a/postfix/util/iostuff.h b/postfix/util/iostuff.h index 32d350006..ddc621a32 100644 --- a/postfix/util/iostuff.h +++ b/postfix/util/iostuff.h @@ -24,6 +24,8 @@ extern int peekfd(int); extern int read_wait(int, int); extern int write_wait(int, int); extern int write_buf(int, const char *, int, int); +extern int timed_read(int, void *, unsigned, int); +extern int timed_write(int, void *, unsigned, int); extern void doze(unsigned); extern int duplex_pipe(int *); diff --git a/postfix/util/stringops.h b/postfix/util/stringops.h index 854c02923..1310d4cb0 100644 --- a/postfix/util/stringops.h +++ b/postfix/util/stringops.h @@ -11,8 +11,14 @@ /* DESCRIPTION /* .nf - /* External interface. */ + /* + * Utility library. + */ +#include + /* + * External interface. + */ extern char *printable(char *, int); extern char *lowercase(char *); extern char *skipblanks(const char *); @@ -23,6 +29,7 @@ extern char *translit(char *, const char *, const char *); #ifndef HAVE_BASENAME extern char *basename(const char *); #endif +extern VSTRING *unescape(VSTRING *, const char *); /* LICENSE /* .ad diff --git a/postfix/util/timed_read.c b/postfix/util/timed_read.c new file mode 100644 index 000000000..045d97c94 --- /dev/null +++ b/postfix/util/timed_read.c @@ -0,0 +1,65 @@ +/*++ +/* NAME +/* timed_read 3 +/* SUMMARY +/* read operation with pre-read timeout +/* SYNOPSIS +/* #include +/* +/* int timed_read(fd, buf, buf_len, timeout) +/* int fd; +/* void *buf; +/* unsigned len; +/* int timeout; +/* DESCRIPTION +/* timed_read() performs a read() operation when the specified +/* descriptor becomes readable within a user-specified deadline. +/* +/* Arguments: +/* .IP fd +/* File descriptor in the range 0..FD_SETSIZE. +/* .IP buf +/* Read buffer pointer. +/* .IP buf_len +/* Read buffer size. +/* .IP timeout +/* The deadline in seconds. If this is <= 0, the deadline feature +/* is disabled. +/* DIAGNOSTICS +/* When the operation does not complete within the deadline, the +/* result value is -1, and errno is set to ETIMEDOUT. +/* All other returns are identical to those of a read(2) operation. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include +#include + +/* Utility library. */ + +#include "iostuff.h" + +/* timed_read - read with deadline */ + +int timed_read(int fd, void *buf, unsigned len, int timeout) +{ + + /* + * Wait for a limited amount of time for something to happen. If nothing + * happens, report an ETIMEDOUT error. + */ + if (timeout > 0 && read_wait(fd, timeout) < 0) + return (-1); + else + return (read(fd, buf, len)); +} diff --git a/postfix/util/timed_write.c b/postfix/util/timed_write.c new file mode 100644 index 000000000..2bc428d1e --- /dev/null +++ b/postfix/util/timed_write.c @@ -0,0 +1,65 @@ +/*++ +/* NAME +/* timed_write 3 +/* SUMMARY +/* write operation with pre-write timeout +/* SYNOPSIS +/* #include +/* +/* int timed_write(fd, buf, buf_len, timeout) +/* int fd; +/* const void *buf; +/* unsigned len; +/* int timeout; +/* DESCRIPTION +/* timed_write() performs a write() operation when the specified +/* descriptor becomes writable within a user-specified deadline. +/* +/* Arguments: +/* .IP fd +/* File descriptor in the range 0..FD_SETSIZE. +/* .IP buf +/* Write buffer pointer. +/* .IP buf_len +/* Write buffer size. +/* .IP timeout +/* The deadline in seconds. If this is <= 0, the deadline feature +/* is disabled. +/* DIAGNOSTICS +/* When the operation does not complete within the deadline, the +/* result value is -1, and errno is set to ETIMEDOUT. +/* All other returns are identical to those of a write(2) operation. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include +#include + +/* Utility library. */ + +#include "iostuff.h" + +/* timed_write - write with deadline */ + +int timed_write(int fd, void *buf, unsigned len, int timeout) +{ + + /* + * Wait for a limited amount of time for something to happen. If nothing + * happens, report an ETIMEDOUT error. + */ + if (timeout > 0 && write_wait(fd, timeout) < 0) + return (-1); + else + return (write(fd, buf, len)); +} diff --git a/postfix/util/unescape.c b/postfix/util/unescape.c new file mode 100644 index 000000000..66d2e2e4f --- /dev/null +++ b/postfix/util/unescape.c @@ -0,0 +1,139 @@ +/*++ +/* NAME +/* unescape 3 +/* SUMMARY +/* translate C-like escape sequences +/* SYNOPSIS +/* #include +/* +/* VSTRING *unescape(result, input) +/* VSTRING *result; +/* const char *input; +/* DESCRIPTION +/* unescape() translates C-like escape sequences in the null-terminated +/* string \fIinput\fR and places the result in \fIresult\fR. The result +/* is null-terminated. +/* +/* Escape sequences and their translations: +/* .IP \ea +/* Bell character. +/* .IP \eb +/* Backspace character. +/* .IP \ef +/* formfeed character. +/* .IP \en +/* newline character +/* .IP \er +/* Carriage-return character. +/* .IP \et +/* Horizontal tab character. +/* .IP \ev +/* Vertical tab character. +/* .IP \e\e +/* Backslash character. +/* .IP \enum +/* 8-bit character whose ASCII value is the 1..3 digit +/* octal number \fInum\fR. +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include +#include + +/* Utility library. */ + +#include +#include + +/* unescape - process escape sequences */ + +VSTRING *unescape(VSTRING *result, const char *data) +{ + int ch; + int oval; + int i; + +#define UCHAR(cp) ((unsigned char *) (cp)) +#define ISOCTAL(ch) (ISDIGIT(ch) && (ch) != '8' && (ch) != '9') + + VSTRING_RESET(result); + + while ((ch = *UCHAR(data++)) != 0) { + if (ch == '\\') { + if ((ch = *UCHAR(data++)) == 0) + break; + switch (ch) { + case 'a': /* \a -> audible bell */ + ch = '\a'; + break; + case 'b': /* \b -> backspace */ + ch = '\b'; + break; + case 'f': /* \f -> formfeed */ + ch = '\f'; + break; + case 'n': /* \n -> newline */ + ch = '\n'; + break; + case 'r': /* \r -> carriagereturn */ + ch = '\r'; + break; + case 't': /* \t -> horizontal tab */ + ch = '\t'; + break; + case 'v': /* \v -> vertical tab */ + ch = '\v'; + break; + case '0': /* \nnn -> ASCII value */ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + for (oval = ch - '0', i = 0; + i < 2 && (ch = *UCHAR(data)) != 0 && ISOCTAL(ch); + i++, data++) { + oval = (oval << 3) | (ch - '0'); + } + ch = oval; + break; + default: /* \any -> any */ + break; + } + } + VSTRING_ADDCH(result, ch); + } + VSTRING_TERMINATE(result); + return (result); +} + +#ifdef TEST + +#include + +int main(int unused_argc, char **unused_argv) +{ + VSTRING *in = vstring_alloc(10); + VSTRING *out = vstring_alloc(10); + + while (vstring_fgets_nonl(in, VSTREAM_IN)) { + unescape(out, vstring_str(in)); + vstream_fwrite(VSTREAM_OUT, vstring_str(out), VSTRING_LEN(out)); + } + vstream_fflush(VSTREAM_OUT); + exit(0); +} + +#endif diff --git a/postfix/util/unescape.in b/postfix/util/unescape.in new file mode 100644 index 000000000..824cb213d --- /dev/null +++ b/postfix/util/unescape.in @@ -0,0 +1,3 @@ +\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +\1\2\3\4\5\6\7\8\9 +\1234\2345\3456\4567 diff --git a/postfix/util/unescape.ref b/postfix/util/unescape.ref new file mode 100644 index 000000000..49cc49ff6 --- /dev/null +++ b/postfix/util/unescape.ref @@ -0,0 +1,7 @@ +0000000 007 \b c d e \f g h i j k l m \n o p + 007 010 143 144 145 014 147 150 151 152 153 154 155 012 157 160 +0000020 q \r s \t u 013 w x y z 001 002 003 004 005 006 + 161 015 163 011 165 013 167 170 171 172 001 002 003 004 005 006 +0000040 007 8 9 S 4 234 5 345 6 . 7 + 007 070 071 123 064 234 065 345 066 056 067 +0000053 diff --git a/postfix/util/vbuf.h b/postfix/util/vbuf.h index 57aa6f6f9..5c50f1a5d 100644 --- a/postfix/util/vbuf.h +++ b/postfix/util/vbuf.h @@ -60,11 +60,13 @@ struct VBUF { */ #define VBUF_FLAG_ERR (1<<0) /* some I/O error */ #define VBUF_FLAG_EOF (1<<1) /* end of data */ -#define VBUF_FLAG_BAD (VBUF_FLAG_ERR | VBUF_FLAG_EOF) -#define VBUF_FLAG_FIXED (1<<2) /* fixed-size buffer */ +#define VBUF_FLAG_TIMEOUT (1<<2) /* timeout error */ +#define VBUF_FLAG_BAD (VBUF_FLAG_ERR | VBUF_FLAG_EOF | VBUF_FLAG_TIMEOUT) +#define VBUF_FLAG_FIXED (1<<3) /* fixed-size buffer */ #define vbuf_error(v) ((v)->flags & VBUF_FLAG_ERR) #define vbuf_eof(v) ((v)->flags & VBUF_FLAG_EOF) +#define vbuf_timeout(v) ((v)->flags & VBUF_FLAG_TIMEOUT) #define vbuf_clearerr(v) ((v)->flags &= ~VBUF_FLAG_BAD) /* diff --git a/postfix/util/vstream.c b/postfix/util/vstream.c index 7985ac32b..2274510df 100644 --- a/postfix/util/vstream.c +++ b/postfix/util/vstream.c @@ -75,6 +75,9 @@ /* int vstream_ferror(stream) /* VSTREAM *stream; /* +/* int vstream_ftimeout(stream) +/* VSTREAM *stream; +/* /* int vstream_feof(stream) /* VSTREAM *stream; /* @@ -199,11 +202,11 @@ /* The following lists the names and the types of the corresponding /* value arguments. /* .IP "VSTREAM_CTL_READ_FN (int (*)(int, void *, unsigned))" -/* The argument specifies an alternative for the read(2) function, -/* for example, a read function that enforces a time limit. +/* The argument specifies an alternative for the timed_read(3) function, +/* for example, a read function that performs encryption. /* .IP "VSTREAM_CTL_WRITE_FN (int (*)(int, void *, unsigned))" -/* The argument specifies an alternative for the write(2) function, -/* for example, a write function that enforces a time limit. +/* The argument specifies an alternative for the timed_write(3) function, +/* for example, a write function that performs encryption. /* .IP "VSTREAM_CTL_PATH (char *)" /* Updates the stored pathname of the specified stream. The pathname /* is copied. @@ -221,6 +224,10 @@ /* .IP "VSTREAM_CTL_WAITPID_FN (int (*)(pid_t, WAIT_STATUS_T *, int))" /* A pointer to function that behaves like waitpid(). This information /* is used by the vstream_pclose() routine. +/* .IP "VSTREAM_CTL_TIMEOUT (int) +/* The deadline for a descriptor to become readable in case of a read +/* request, or writable in case of a write request. Specify a value +/* <= 0 to disable deadlines. /* .PP /* vstream_fileno() gives access to the file handle associated with /* a buffered stream. With streams that have separate read/write @@ -230,12 +237,17 @@ /* with vstream_fopen() or with vstream_control(). The macro is /* unsafe because it evaluates some arguments more than once. /* -/* vstream_ferror() (vstream_feof()) returns non-zero when a previous -/* operation on the specified stream caused an error (end-of-file) -/* condition. +/* vstream_feof() returns non-zero when a previous operation on the +/* specified stream caused an end-of-file condition. +/* +/* vstream_ferror() returns non-zero when a previous operation on the +/* specified stream caused a non-EOF error condition, including timeout. /* -/* vstream_clearerr() resets the error and end-of-file indication of -/* specified stream, and returns no useful result. +/* vstream_ftimeout() returns non-zero when a previous operation on the +/* specified stream caused a timeout error condition. +/* +/* vstream_clearerr() resets the timeout, error and end-of-file indication +/* of the specified stream, and returns no useful result. /* /* vstream_vfprintf() provides an alternate interface /* for formatting an argument list according to a format string. @@ -245,6 +257,8 @@ /* DIAGNOSTICS /* Panics: interface violations. Fatal errors: out of memory. /* SEE ALSO +/* timed_read(3) default read routine +/* timed_write(3) default write routine /* vbuf_print(3) formatting engine /* BUGS /* Should use mmap() on reasonable systems. @@ -275,7 +289,9 @@ #include "mymalloc.h" #include "msg.h" #include "vbuf_print.h" +#include "iostuff.h" #include "vstring.h" +#include "binattr.h" #include "vstream.h" /* Application-specific. */ @@ -299,17 +315,17 @@ VSTREAM vstream_fstd[] = { 0, /* flags */ 0, 0, 0, 0, /* buffer */ vstream_buf_get_ready, vstream_buf_put_ready, vstream_buf_space, - }, STDIN_FILENO, (VSTREAM_FN) read, (VSTREAM_FN) write,}, + }, STDIN_FILENO, (VSTREAM_FN) timed_read, (VSTREAM_FN) timed_write,}, {{ 0, /* flags */ 0, 0, 0, 0, /* buffer */ vstream_buf_get_ready, vstream_buf_put_ready, vstream_buf_space, - }, STDOUT_FILENO, (VSTREAM_FN) read, (VSTREAM_FN) write,}, + }, STDOUT_FILENO, (VSTREAM_FN) timed_read, (VSTREAM_FN) timed_write,}, {{ VBUF_FLAG_FIXED | VSTREAM_FLAG_WRITE, vstream_fstd_buf, VSTREAM_BUFSIZE, VSTREAM_BUFSIZE, vstream_fstd_buf, vstream_buf_get_ready, vstream_buf_put_ready, vstream_buf_space, - }, STDERR_FILENO, (VSTREAM_FN) read, (VSTREAM_FN) write,}, + }, STDERR_FILENO, (VSTREAM_FN) timed_read, (VSTREAM_FN) timed_write,}, }; #define VSTREAM_STATIC(v) ((v) >= VSTREAM_IN && (v) <= VSTREAM_ERR) @@ -483,8 +499,10 @@ static int vstream_fflush_some(VSTREAM *stream, int to_flush) * any. */ for (data = (char *) bp->data, len = to_flush; len > 0; len -= n, data += n) { - if ((n = stream->write_fn(stream->fd, data, len)) <= 0) { + if ((n = stream->write_fn(stream->fd, data, len, stream->timeout)) <= 0) { bp->flags |= VSTREAM_FLAG_ERR; + if (errno == ETIMEDOUT) + bp->flags |= VSTREAM_FLAG_TIMEOUT; return (VSTREAM_EOF); } if (msg_verbose > 2 && stream != VSTREAM_ERR && n != to_flush) @@ -607,9 +625,11 @@ static int vstream_buf_get_ready(VBUF *bp) * data as is available right now, whichever is less. Update the cached * file seek position, if any. */ - switch (n = stream->read_fn(stream->fd, bp->data, bp->len)) { + switch (n = stream->read_fn(stream->fd, bp->data, bp->len, stream->timeout)) { case -1: bp->flags |= VSTREAM_FLAG_ERR; + if (errno == ETIMEDOUT) + bp->flags |= VSTREAM_FLAG_TIMEOUT; return (VSTREAM_EOF); case 0: bp->flags |= VSTREAM_FLAG_EOF; @@ -846,13 +866,15 @@ VSTREAM *vstream_fdopen(int fd, int flags) */ stream = (VSTREAM *) mymalloc(sizeof(*stream)); stream->fd = fd; - stream->read_fn = VSTREAM_CAN_READ(flags) ? (VSTREAM_FN) read : 0; - stream->write_fn = VSTREAM_CAN_WRITE(flags) ? (VSTREAM_FN) write : 0; + stream->read_fn = VSTREAM_CAN_READ(flags) ? (VSTREAM_FN) timed_read : 0; + stream->write_fn = VSTREAM_CAN_WRITE(flags) ? (VSTREAM_FN) timed_write : 0; vstream_buf_init(&stream->buf, flags); stream->offset = 0; stream->path = 0; stream->pid = 0; stream->waitpid_fn = 0; + stream->timeout = 0; + stream->attr = 0; return (stream); } @@ -907,6 +929,8 @@ int vstream_fclose(VSTREAM *stream) } if (stream->path) myfree(stream->path); + if (stream->attr) + binattr_free(stream->attr); if (!VSTREAM_STATIC(stream)) myfree((char *) stream); return (err ? VSTREAM_EOF : 0); @@ -996,6 +1020,9 @@ void vstream_control(VSTREAM *stream, int name,...) case VSTREAM_CTL_WAITPID_FN: stream->waitpid_fn = va_arg(ap, VSTREAM_WAITPID_FN); break; + case VSTREAM_CTL_TIMEOUT: + stream->timeout = va_arg(ap, int); + break; default: msg_panic("%s: bad name %d", myname, name); } diff --git a/postfix/util/vstream.h b/postfix/util/vstream.h index d67ee2377..76cb3d25a 100644 --- a/postfix/util/vstream.h +++ b/postfix/util/vstream.h @@ -21,12 +21,13 @@ * Utility library. */ #include +#include /* * Simple buffered stream. The members of this structure are not part of the * official interface and can change without prior notice. */ -typedef int (*VSTREAM_FN) (int, void *, unsigned); +typedef int (*VSTREAM_FN) (int, void *, unsigned, int); typedef int (*VSTREAM_WAITPID_FN) (pid_t, WAIT_STATUS_T *, int); typedef struct VSTREAM { @@ -40,8 +41,10 @@ typedef struct VSTREAM { int write_fd; /* write channel (double-buffered) */ VBUF read_buf; /* read buffer (double-buffered) */ VBUF write_buf; /* write buffer (double-buffered) */ + int timeout; /* read/write timout */ pid_t pid; /* vstream_popen/close() */ VSTREAM_WAITPID_FN waitpid_fn; /* vstream_popen/close() */ + BINATTR *attr; /* optional binary attribute list */ } VSTREAM; extern VSTREAM vstream_fstd[]; /* pre-defined streams */ @@ -52,6 +55,7 @@ extern VSTREAM vstream_fstd[]; /* pre-defined streams */ #define VSTREAM_FLAG_ERR VBUF_FLAG_ERR /* some I/O error */ #define VSTREAM_FLAG_EOF VBUF_FLAG_EOF /* end of file */ +#define VSTREAM_FLAG_TIMEOUT VBUF_FLAG_TIMEOUT /* timeout error */ #define VSTREAM_FLAG_FIXED VBUF_FLAG_FIXED /* fixed-size buffer */ #define VSTREAM_FLAG_BAD VBUF_FLAG_BAD @@ -85,6 +89,7 @@ extern VSTREAM *vstream_fdopen(int, int); #define vstream_fileno(vp) ((vp)->fd) #define vstream_ferror(vp) vbuf_error(&(vp)->buf) #define vstream_feof(vp) vbuf_eof(&(vp)->buf) +#define vstream_ftimeout(vp) vbuf_timeout(&(vp)->buf) #define vstream_clearerr(vp) vbuf_clearerr(&(vp)->buf) #define VSTREAM_PATH(vp) ((vp)->path ? (vp)->path : "unknown_stream") @@ -98,6 +103,7 @@ extern void vstream_control(VSTREAM *, int,...); #define VSTREAM_CTL_READ_FD 5 #define VSTREAM_CTL_WRITE_FD 6 #define VSTREAM_CTL_WAITPID_FN 7 +#define VSTREAM_CTL_TIMEOUT 8 extern VSTREAM *vstream_printf(const char *,...); extern VSTREAM *vstream_fprintf(VSTREAM *, const char *,...); @@ -121,6 +127,16 @@ extern VSTREAM *vstream_vfprintf(VSTREAM *, const char *, va_list); extern int vstream_peek(VSTREAM *); + /* + * Attribute management, a way of tacking on arbitrary information onto a + * VSTREAM without destroying the VSTREAM abstraction itself. + */ +#define VSTREAM_ATTR_FREE_FN BINATTR_FREE_FN + +extern void vstream_attr_set(VSTREAM *, const char *, char *, VSTREAM_ATTR_FREE_FN); +extern char *vstream_attr_get(VSTREAM *, const char *); +extern void vstream_attr_unset(VSTREAM *, const char *); + /* LICENSE /* .ad /* .fi diff --git a/postfix/util/vstream_attr.c b/postfix/util/vstream_attr.c new file mode 100644 index 000000000..00484b72b --- /dev/null +++ b/postfix/util/vstream_attr.c @@ -0,0 +1,92 @@ +/*++ +/* NAME +/* vstream_attr 3 +/* SUMMARY +/* per-stream attribute list management +/* SYNOPSIS +/* #include +/* +/* void vstream_attr_set(stream, name, value, free_fn) +/* VSTREAM *stream; +/* const char *name; +/* char *value; +/* void (*free_fn)(char *); +/* +/* char *vstream_attr_get(stream, name) +/* VSTREAM *stream; +/* const char *name; +/* +/* void vstream_attr_unset(stream, name) +/* VSTREAM *stream; +/* const char *name; +/* DESCRIPTION +/* This module maintains an optional per-stream open attribute +/* list for arbitrary binary values. It is in fact a convienience +/* interface built on top of the binattr(3) module. +/* +/* vstream_attr_set() adds or replaces the named attribute. +/* +/* vstream_attr_get() looks up the named attribute. The result +/* is the value stored with vstream_attr_set() or a null pointer +/* when the requested information is not found. +/* +/* vstream_attr_unset() removes the named attribute. This operation +/* is undefined for attributes that do not exist. +/* +/* Arguments: +/* .IP stream +/* Open VSTREAM. +/* .IP name +/* Attribute name, in the form of a null-terminated list. +/* The name is copied. +/* .IP value +/* Arbitrary binary value. The value is not copied. +/* .IP free_fn +/* Null pointer, or pointer to function that destroys the value +/* that was stored with vstream_attr_set(). +/* LICENSE +/* .ad +/* .fi +/* The Secure Mailer license must be distributed with this software. +/* AUTHOR(S) +/* Wietse Venema +/* IBM T.J. Watson Research +/* P.O. Box 704 +/* Yorktown Heights, NY 10598, USA +/*--*/ + +/* System library. */ + +#include + +/* Utility library. */ + +#include +#include + +/* vstream_attr_set - add or replace per-stream attribute */ + +void vstream_attr_set(VSTREAM *stream, const char *name, char *value, BINATTR_FREE_FN free_fn) +{ + if (stream->attr == 0) + stream->attr = binattr_create(1); + binattr_set(stream->attr, name, value, free_fn); +} + +/* vstream_attr_get - look up per-stream attribute */ + +char *vstream_attr_get(VSTREAM *stream, const char *name) +{ + if (stream->attr == 0) + return (0); + else + return (binattr_get(stream->attr, name)); +} + +/* vstream_attr_unset - unset per-stream attribute */ + +void vstream_attr_unset(VSTREAM *stream, const char *name) +{ + if (stream->attr) + binattr_unset(stream->attr, name); +} diff --git a/postfix/util/vstring.c b/postfix/util/vstring.c index 6bd7717b0..a6f5feb91 100644 --- a/postfix/util/vstring.c +++ b/postfix/util/vstring.c @@ -1,3 +1,4 @@ +/*++ /* NAME /* vstring 3 /* SUMMARY @@ -8,6 +9,11 @@ /* VSTRING *vstring_alloc(len) /* int len; /* +/* VSTRING *vstring_init(vp, buf, len) +/* VSTRING *vp; +/* char *buf; +/* int len; +/* /* vstring_ctl(vp, type, value, ..., VSTRING_CTL_END) /* VSTRING *vp; /* int type; @@ -100,6 +106,10 @@ /* of at least "len" bytes. The minimal length is 1. The result /* is a null-terminated string of length zero. /* +/* vstring_init() initializes a fixed-size buffer. Attempts to +/* allocate space beyond the buffer end cause the process to +/* terminate with a fatal run-time error. +/* /* vstring_ctl() gives control over memory management policy. /* The function takes a VSTRING pointer and a list of zero /* or more (name,value) pairs. The expected valye type of the @@ -217,7 +227,7 @@ #include #include -#include /* 44BSD stdarg.h uses abort() */ +#include /* 44BSD stdarg.h uses abort() */ #include #include @@ -296,6 +306,49 @@ VSTRING *vstring_alloc(int len) return (vp); } +/* vstring_fixed_get_ready - vbuf callback for read buffer empty condition */ + +static int vstring_fixed_get_ready(VBUF *unused_buf) +{ + msg_panic("vstring_fixed_get: write-only buffer"); +} + +/* vstring_fixed_put_ready - vbuf callback for write buffer full condition */ + +static int vstring_fixed_put_ready(VBUF *unused_bp) +{ + msg_fatal("fixed-size string buffer full"); +} + +/* vstring_fixed_space - vbuf callback to reserve space */ + +static int vstring_fixed_space(VBUF *bp, int len) +{ + if (len < 0) + msg_panic("vstring_fixed_space: bad length %d", len); + if (len - bp->cnt > 0) + msg_fatal("fixed-size string buffer full"); + return (0); +} + +/* vstring_init - initialize fixed-length buffer */ + +VSTRING *vstring_init(VSTRING *vp, char *buf, int len) +{ + if (len < 1) + msg_panic("vstring_init: bad length %d", len); + vp->vbuf.flags = 0; + vp->vbuf.data = (unsigned char *) buf; + vp->vbuf.len = len; + VSTRING_RESET(vp); + vp->vbuf.data[0] = 0; + vp->vbuf.get_ready = vstring_fixed_get_ready; + vp->vbuf.put_ready = vstring_fixed_put_ready; + vp->vbuf.space = vstring_fixed_space; + vp->maxlen = 0; + return (vp); +} + /* vstring_free - destroy variable-length string */ VSTRING *vstring_free(VSTRING *vp) diff --git a/postfix/util/vstring.h b/postfix/util/vstring.h index 4d4a972bf..4231559a2 100644 --- a/postfix/util/vstring.h +++ b/postfix/util/vstring.h @@ -30,9 +30,8 @@ typedef struct VSTRING { int maxlen; } VSTRING; -extern void vstring_init(VSTRING *, int); -extern void vstring_wipe(VSTRING *); extern VSTRING *vstring_alloc(int); +extern VSTRING *vstring_init(VSTRING *, char *, int); extern void vstring_ctl(VSTRING *,...); extern VSTRING *vstring_truncate(VSTRING *, int); extern VSTRING *vstring_free(VSTRING *);