New option --message-id-header
Showing
1 changed file
with
44 additions
and
16 deletions
... | @@ -17,19 +17,25 @@ | ... | @@ -17,19 +17,25 @@ |
17 | 17 | ||
18 | #include <mail.local.h> | 18 | #include <mail.local.h> |
19 | 19 | ||
20 | int multiple_delivery; | 20 | int multiple_delivery; /* Don't return errors when delivering to multiple |
21 | int ex_quota_tempfail; | 21 | recipients */ |
22 | int exit_code = EX_OK; | 22 | int ex_quota_tempfail; /* Return temporary failure if mailbox quota is |
23 | uid_t uid; | 23 | exceeded. If this variable is not set, mail.local |
24 | char *quotadbname = NULL; | 24 | will return "service unavailable" */ |
25 | int lock_timeout = 300; | 25 | int exit_code = EX_OK; /* Exit code to be used */ |
26 | uid_t uid; /* Current user name */ | ||
27 | char *quotadbname = NULL; /* Name of mailbox quota database */ | ||
28 | int lock_timeout = 300; /* Locking timeout in seconds */ | ||
26 | 29 | ||
27 | /* Debuggig options */ | 30 | /* Debuggig options */ |
28 | int debug_level; | 31 | int debug_level; /* General debugging level */ |
29 | int debug_flags; | 32 | int debug_flags; /* Mailutils debugging flags */ |
30 | int sieve_debug_flags; | 33 | int sieve_debug_flags; /* Sieve debugging flags */ |
31 | int sieve_enable_log; | 34 | int sieve_enable_log; /* Enables logging of executed Sieve actions */ |
32 | mu_debug_t mudebug; | 35 | char *message_id_header; /* Use the value of this header as message |
36 | identifier when logging Sieve actions */ | ||
37 | mu_debug_t mudebug; /* Mailutils debugging object */ | ||
38 | |||
33 | 39 | ||
34 | #define MAXFD 64 | 40 | #define MAXFD 64 |
35 | #define EX_QUOTA() (ex_quota_tempfail ? EX_TEMPFAIL : EX_UNAVAILABLE) | 41 | #define EX_QUOTA() (ex_quota_tempfail ? EX_TEMPFAIL : EX_UNAVAILABLE) |
... | @@ -59,6 +65,7 @@ static char args_doc[] = N_("recipient [recipient ...]"); | ... | @@ -59,6 +65,7 @@ static char args_doc[] = N_("recipient [recipient ...]"); |
59 | 65 | ||
60 | #define ARG_MULTIPLE_DELIVERY 1 | 66 | #define ARG_MULTIPLE_DELIVERY 1 |
61 | #define ARG_QUOTA_TEMPFAIL 2 | 67 | #define ARG_QUOTA_TEMPFAIL 2 |
68 | #define ARG_MESSAGE_ID_HEADER 3 | ||
62 | 69 | ||
63 | static struct argp_option options[] = | 70 | static struct argp_option options[] = |
64 | { | 71 | { |
... | @@ -75,6 +82,8 @@ static struct argp_option options[] = | ... | @@ -75,6 +82,8 @@ static struct argp_option options[] = |
75 | #endif | 82 | #endif |
76 | { "sieve", 'S', N_("PATTERN"), 0, | 83 | { "sieve", 'S', N_("PATTERN"), 0, |
77 | N_("Set name pattern for user-defined sieve mail filters"), 0 }, | 84 | N_("Set name pattern for user-defined sieve mail filters"), 0 }, |
85 | { "message-id-header", ARG_MESSAGE_ID_HEADER, N_("STRING"), 0, | ||
86 | N_("Identify messages by the value of this header when logging Sieve actions"), 0 }, | ||
78 | #ifdef WITH_GUILE | 87 | #ifdef WITH_GUILE |
79 | { "source", 's', N_("PATTERN"), 0, | 88 | { "source", 's', N_("PATTERN"), 0, |
80 | N_("Set name pattern for user-defined mail filters"), 0 }, | 89 | N_("Set name pattern for user-defined mail filters"), 0 }, |
... | @@ -127,6 +136,10 @@ parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -127,6 +136,10 @@ parse_opt (int key, char *arg, struct argp_state *state) |
127 | ex_quota_tempfail = 1; | 136 | ex_quota_tempfail = 1; |
128 | break; | 137 | break; |
129 | 138 | ||
139 | case ARG_MESSAGE_ID_HEADER: | ||
140 | message_id_header = arg; | ||
141 | break; | ||
142 | |||
130 | case 'r': | 143 | case 'r': |
131 | case 'f': | 144 | case 'f': |
132 | if (from != NULL) | 145 | if (from != NULL) |
... | @@ -227,12 +240,27 @@ _sieve_action_log (void *user_name, | ... | @@ -227,12 +240,27 @@ _sieve_action_log (void *user_name, |
227 | const char *script, size_t msgno, message_t msg, | 240 | const char *script, size_t msgno, message_t msg, |
228 | const char *action, const char *fmt, va_list ap) | 241 | const char *action, const char *fmt, va_list ap) |
229 | { | 242 | { |
230 | size_t uid = 0; | ||
231 | char *text = NULL; | 243 | char *text = NULL; |
232 | 244 | ||
233 | message_get_uid (msg, &uid); | 245 | if (message_id_header) |
234 | 246 | { | |
235 | asprintf (&text, _("%s on msg uid %d"), action, uid); | 247 | header_t hdr = NULL; |
248 | char *val = NULL; | ||
249 | message_get_header (msg, &hdr); | ||
250 | if (header_aget_value (hdr, message_id_header, &val) == 0 | ||
251 | || header_aget_value (hdr, MU_HEADER_MESSAGE_ID, &val) == 0) | ||
252 | { | ||
253 | asprintf (&text, _("%s on msg %s"), action, val); | ||
254 | free (val); | ||
255 | } | ||
256 | } | ||
257 | if (text == NULL) | ||
258 | { | ||
259 | size_t uid = 0; | ||
260 | message_get_uid (msg, &uid); | ||
261 | asprintf (&text, _("%s on msg uid %d"), action, uid); | ||
262 | } | ||
263 | |||
236 | if (fmt && strlen (fmt)) | 264 | if (fmt && strlen (fmt)) |
237 | { | 265 | { |
238 | char *diag = NULL; | 266 | char *diag = NULL; |
... | @@ -797,7 +825,7 @@ notify_biff (mailbox_t mbox, char *name, size_t size) | ... | @@ -797,7 +825,7 @@ notify_biff (mailbox_t mbox, char *name, size_t size) |
797 | inaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 825 | inaddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
798 | inaddr.sin_port = sp->s_port; | 826 | inaddr.sin_port = sp->s_port; |
799 | 827 | ||
800 | fd = socket (AF_INET, SOCK_DGRAM, 0); | 828 | fd = socket (PF_INET, SOCK_DGRAM, 0); |
801 | if (fd < 0) | 829 | if (fd < 0) |
802 | fd = -2; /* Mark failed initialization */ | 830 | fd = -2; /* Mark failed initialization */ |
803 | } | 831 | } | ... | ... |
-
Please register or sign in to post a comment