dovecot-2.2-pigeonhole: lib-sieve: Switched to new Dovecot SMTP ...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Mon Apr 28 20:09:01 UTC 2014
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/c6c320f4918b
changeset: 1848:c6c320f4918b
user: Stephan Bosch <stephan at rename-it.nl>
date: Mon Apr 28 22:08:47 2014 +0200
description:
lib-sieve: Switched to new Dovecot SMTP API.
diffstat:
src/lib-sieve/cmd-redirect.c | 20 +++++++++++++----
src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c | 24 ++++++++++++++-------
src/lib-sieve/plugins/enotify/sieve-ext-enotify.h | 3 ++
src/lib-sieve/plugins/notify/cmd-notify.c | 24 ++++++++++++++-------
src/lib-sieve/plugins/vacation/cmd-vacation.c | 17 ++++++++++-----
src/lib-sieve/sieve-actions.c | 21 ++++++++++++------
src/lib-sieve/sieve-smtp.c | 19 ++++++++---------
src/lib-sieve/sieve-smtp.h | 9 ++++---
src/lib-sieve/sieve-types.h | 9 +++++--
src/plugins/lda-sieve/lda-sieve-plugin.c | 9 ++++---
src/sieve-tools/sieve-test.c | 7 +++--
src/testsuite/testsuite-smtp.c | 7 +++--
src/testsuite/testsuite-smtp.h | 4 +-
13 files changed, 110 insertions(+), 63 deletions(-)
diffs (truncated from 379 to 300 lines):
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/cmd-redirect.c
--- a/src/lib-sieve/cmd-redirect.c Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/cmd-redirect.c Mon Apr 28 22:08:47 2014 +0200
@@ -320,7 +320,9 @@
const char *recipient = sieve_message_get_final_recipient(msgctx);
struct istream *input;
struct ostream *output;
+ const char *error;
void *smtp_handle;
+ int ret;
/* Just to be sure */
if ( !sieve_smtp_available(senv) ) {
@@ -356,11 +358,19 @@
i_stream_unref(&input);
/* Close SMTP transport */
- if ( !sieve_smtp_close(senv, smtp_handle) ) {
- sieve_result_global_error(aenv,
- "failed to redirect message to <%s> "
- "(refer to server log for more information)",
- str_sanitize(ctx->to_address, 80));
+ if ( (ret=sieve_smtp_close(senv, smtp_handle, &error)) <= 0 ) {
+ if ( ret < 0 ) {
+ sieve_result_global_log_error(aenv,
+ "failed to redirect message to <%s>: %s "
+ "(temporary failure)",
+ str_sanitize(ctx->to_address, 256), str_sanitize(error, 512));
+ } else {
+ sieve_result_global_error(aenv,
+ "failed to redirect message to <%s>: %s "
+ "(permanent failure)",
+ str_sanitize(ctx->to_address, 256), str_sanitize(error, 512));
+
+ }
return SIEVE_EXEC_FAILURE;
}
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c
--- a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c Mon Apr 28 22:08:47 2014 +0200
@@ -392,7 +392,8 @@
struct ostream *output;
string_t *msg;
unsigned int count, i, hcount, h;
- const char *outmsgid;
+ const char *outmsgid, *error;
+ int ret;
/* Get recipients */
recipients = array_get(&mtctx->uri->recipients, &count);
@@ -540,15 +541,22 @@
o_stream_send(output, str_data(msg), str_len(msg));
- if ( sieve_smtp_close(senv, smtp_handle) ) {
+ if ( (ret=sieve_smtp_close(senv, smtp_handle, &error)) <= 0 ) {
+ if (ret < 0) {
+ sieve_enotify_global_log_error(nenv,
+ "failed to send mail notification to <%s>: %s (temporary failure)",
+ str_sanitize(recipients[i].normalized, 256),
+ str_sanitize(error, 512));
+ } else {
+ sieve_enotify_global_error(nenv,
+ "failed to send mail notification to <%s>: %s (permanent failure)",
+ str_sanitize(recipients[i].normalized, 256),
+ str_sanitize(error, 512));
+ }
+ } else {
sieve_enotify_global_info(nenv,
"sent mail notification to <%s>",
- str_sanitize(recipients[i].normalized, 80));
- } else {
- sieve_enotify_global_error(nenv,
- "failed to send mail notification to <%s> "
- "(refer to system log for more information)",
- str_sanitize(recipients[i].normalized, 80));
+ str_sanitize(recipients[i].normalized, 256));
}
}
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/plugins/enotify/sieve-ext-enotify.h
--- a/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h Mon Apr 28 22:08:47 2014 +0200
@@ -167,5 +167,8 @@
#define sieve_enotify_global_info(ENV, ...) \
sieve_global_info((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )
+#define sieve_enotify_global_log_error(ENV, ...) \
+ sieve_global_info_error((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )
+
#endif /* __SIEVE_EXT_ENOTIFY_H */
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/plugins/notify/cmd-notify.c
--- a/src/lib-sieve/plugins/notify/cmd-notify.c Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/plugins/notify/cmd-notify.c Mon Apr 28 22:08:47 2014 +0200
@@ -693,8 +693,9 @@
unsigned int count, i;
struct ostream *output;
string_t *msg;
- const char *outmsgid;
+ const char *outmsgid, *error;
size_t hdr_size;
+ int ret;
/* Get recipients */
recipients = array_get(&act->recipients, &count);
@@ -774,15 +775,22 @@
o_stream_send(output, str_data(msg), str_len(msg));
- if ( sieve_smtp_close(senv, smtp_handle) ) {
+ if ( (ret=sieve_smtp_close(senv, smtp_handle, &error)) <= 0 ) {
+ if (ret < 0) {
+ sieve_result_global_log_error(aenv,
+ "failed to send mail notification to <%s>: %s (temporary failure)",
+ str_sanitize(recipients[i].normalized, 256),
+ str_sanitize(error, 512));
+ } else {
+ sieve_result_global_error(aenv,
+ "failed to send mail notification to <%s>: %s (permanent failure)",
+ str_sanitize(recipients[i].normalized, 256),
+ str_sanitize(error, 512));
+ }
+ } else {
sieve_result_global_log(aenv,
"sent mail notification to <%s>",
- str_sanitize(recipients[i].normalized, 80));
- } else {
- sieve_result_global_error(aenv,
- "failed to send mail notification to <%s> "
- "(refer to system log for more information)",
- str_sanitize(recipients[i].normalized, 80));
+ str_sanitize(recipients[i].normalized, 256));
}
}
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/plugins/vacation/cmd-vacation.c
--- a/src/lib-sieve/plugins/vacation/cmd-vacation.c Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/plugins/vacation/cmd-vacation.c Mon Apr 28 22:08:47 2014 +0200
@@ -905,7 +905,7 @@
struct ostream *output;
string_t *msg;
const char *const *headers;
- const char *outmsgid, *subject;
+ const char *outmsgid, *subject, *error;
int ret;
/* Check smpt functions just to be sure */
@@ -992,11 +992,16 @@
o_stream_send(output, str_data(msg), str_len(msg));
/* Close smtp session */
- if ( !sieve_smtp_close(senv, smtp_handle) ) {
- sieve_result_global_error(aenv,
- "failed to send vacation response to <%s> "
- "(refer to server log for more information)",
- str_sanitize(reply_to, 128));
+ if ( (ret=sieve_smtp_close(senv, smtp_handle, &error)) <= 0 ) {
+ if ( ret < 0 ) {
+ sieve_result_global_log_error(aenv,
+ "failed to send vacation response to <%s>: %s (temporary error)",
+ str_sanitize(reply_to, 256), str_sanitize(error, 512));
+ } else {
+ sieve_result_global_error(aenv,
+ "failed to send vacation response to <%s>: %s (permanent error)",
+ str_sanitize(reply_to, 256), str_sanitize(error, 512));
+ }
return FALSE;
}
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/sieve-actions.c
--- a/src/lib-sieve/sieve-actions.c Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/sieve-actions.c Mon Apr 28 22:08:47 2014 +0200
@@ -784,8 +784,7 @@
struct istream *input;
struct ostream *output;
void *smtp_handle;
- const char *new_msgid, *boundary;
- const char *header;
+ const char *new_msgid, *boundary, *header, *error;
string_t *hdr;
int ret;
@@ -875,11 +874,19 @@
str_printfa(hdr, "\r\n\r\n--%s--\r\n", boundary);
o_stream_send(output, str_data(hdr), str_len(hdr));
- if ( !sieve_smtp_close(senv, smtp_handle) ) {
- sieve_result_global_error(aenv,
- "failed to send rejection message to <%s> "
- "(refer to server log for more information)",
- str_sanitize(sender, 80));
+ if ( (ret=sieve_smtp_close(senv, smtp_handle, &error)) <= 0 ) {
+ if ( ret < 0 ) {
+ sieve_result_global_log_error(aenv,
+ "failed to send rejection message to <%s>: %s "
+ "(temporary failure)",
+ str_sanitize(sender, 256), str_sanitize(error, 512));
+ } else {
+ sieve_result_global_error(aenv,
+ "failed to send rejection message to <%s>: %s "
+ "(permanent failure)",
+ str_sanitize(sender, 256), str_sanitize(error, 512));
+
+ }
return FALSE;
}
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/sieve-smtp.c
--- a/src/lib-sieve/sieve-smtp.c Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/sieve-smtp.c Mon Apr 28 22:08:47 2014 +0200
@@ -5,29 +5,28 @@
#include "sieve-common.h"
#include "sieve-smtp.h"
-
bool sieve_smtp_available
(const struct sieve_script_env *senv)
{
- return ( senv->smtp_open != NULL && senv->smtp_close != NULL );
+ return ( senv->smtp_open != NULL && senv->smtp_close != NULL );
}
void *sieve_smtp_open
(const struct sieve_script_env *senv, const char *destination,
const char *return_path, struct ostream **output_r)
{
- if ( senv->smtp_open == NULL || senv->smtp_close == NULL )
- return NULL;
+ if ( !sieve_smtp_available(senv) )
+ return NULL;
- return senv->smtp_open(senv, destination, return_path, output_r);
+ return senv->smtp_open(senv, destination, return_path, output_r);
}
-bool sieve_smtp_close
-(const struct sieve_script_env *senv, void *handle)
+int sieve_smtp_close
+(const struct sieve_script_env *senv, void *handle,
+ const char **error_r)
{
- if ( senv->smtp_open == NULL || senv->smtp_close == NULL )
- return NULL;
+ i_assert( sieve_smtp_available(senv) );
- return senv->smtp_close(senv, handle);
+ return senv->smtp_close(senv, handle, error_r);
}
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/sieve-smtp.h
--- a/src/lib-sieve/sieve-smtp.h Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/sieve-smtp.h Mon Apr 28 22:08:47 2014 +0200
@@ -9,11 +9,12 @@
bool sieve_smtp_available
(const struct sieve_script_env *senv);
+// FIXME: support multiple recipients
void *sieve_smtp_open
(const struct sieve_script_env *senv, const char *destination,
- const char *return_path, struct ostream **output_r);
-
-bool sieve_smtp_close
- (const struct sieve_script_env *senv, void *handle);
+ const char *return_path, struct ostream **output_r);
+int sieve_smtp_close
+ (const struct sieve_script_env *senv, void *handle,
+ const char **error_r);
#endif /* __SIEVE_SMTP_H */
diff -r f5d11f8c614c -r c6c320f4918b src/lib-sieve/sieve-types.h
--- a/src/lib-sieve/sieve-types.h Fri Apr 25 23:53:40 2014 +0200
+++ b/src/lib-sieve/sieve-types.h Mon Apr 28 22:08:47 2014 +0200
@@ -195,7 +195,10 @@
void *(*smtp_open)
(const struct sieve_script_env *senv, const char *destination,
const char *return_path, struct ostream **output_r);
- bool (*smtp_close)(const struct sieve_script_env *senv, void *handle);
+ /* Returns 1 on success, 0 on permanent failure, -1 on temporary failure. */
+ int (*smtp_close)
+ (const struct sieve_script_env *senv, void *handle,
+ const char **error_r);
/* Interface for marking and checking duplicates */
int (*duplicate_check)
@@ -205,8 +208,8 @@
time_t time);
/* Interface for rejecting mail */
- int (*reject_mail)(const struct sieve_script_env *senv, const char *recipient,
- const char *reason);
+ int (*reject_mail)(const struct sieve_script_env *senv,
+ const char *recipient, const char *reason);
/* Execution status record */
struct sieve_exec_status *exec_status;
diff -r f5d11f8c614c -r c6c320f4918b src/plugins/lda-sieve/lda-sieve-plugin.c
--- a/src/plugins/lda-sieve/lda-sieve-plugin.c Fri Apr 25 23:53:40 2014 +0200
+++ b/src/plugins/lda-sieve/lda-sieve-plugin.c Mon Apr 28 22:08:47 2014 +0200
More information about the dovecot-cvs
mailing list