Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
4bbd9e2e
...
4bbd9e2e27cc4f1aeabed4d9be8e7f3cd5345233
authored
2002-01-23 04:27:21 +0000
by
Sam Roberts
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Implemented redirect action, and added option for sieve to specify
the mailer.
1 parent
6b93f609
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
114 additions
and
23 deletions
sieve/sieve.c
sieve/sieve.h
sieve/sv.h
sieve/svcb.c
sieve/svctx.c
sieve/sieve.c
View file @
4bbd9e2
...
...
@@ -40,6 +40,7 @@ const char HELP[] =
" t - sieve trace
\n
"
" h - sieve header parseing
\n
"
" q - sieve message queries
\n
"
" -m a mailer URL (default is
\"
sendmail:
\"
)
\n
"
;
static
void
...
...
@@ -94,6 +95,7 @@ main (int argc, char *argv[])
wicket_t
wicket
=
0
;
ticket_t
ticket
=
0
;
mu_debug_t
debug
=
0
;
mailer_t
mailer
=
0
;
mailbox_t
mbox
=
0
;
size_t
count
=
0
;
...
...
@@ -107,6 +109,7 @@ main (int argc, char *argv[])
char
*
opt_mbox
=
0
;
char
*
opt_tickets
=
0
;
int
opt_debug_level
=
0
;
char
*
opt_mailer
=
"sendmail:"
;
char
*
opt_script
=
0
;
int
opt
;
...
...
@@ -238,6 +241,19 @@ main (int argc, char *argv[])
}
}
/* Create a mailer. */
if
((
rc
=
mailer_create
(
&
mailer
,
opt_mailer
)))
{
fprintf
(
stderr
,
"mailer create <%s> failed: %s
\n
"
,
opt_mailer
,
strerror
(
rc
));
goto
cleanup
;
}
if
(
debug
&&
(
rc
=
mailer_set_debug
(
mailer
,
debug
)))
{
fprintf
(
stderr
,
"mailer_set_debug failed: %s
\n
"
,
strerror
(
rc
));
goto
cleanup
;
}
/* Create, give a ticket to, and open the mailbox. */
if
((
rc
=
mailbox_create_default
(
&
mbox
,
opt_mbox
))
!=
0
)
{
...
...
@@ -319,7 +335,7 @@ main (int argc, char *argv[])
goto
cleanup
;
}
rc
=
sv_script_execute
(
script
,
msg
,
ticket
,
debug
,
opt_no_actions
);
rc
=
sv_script_execute
(
script
,
msg
,
ticket
,
debug
,
mailer
,
opt_no_actions
);
if
(
rc
)
{
...
...
@@ -369,4 +385,8 @@ mutil_register_all_mbox_formats (void)
list_append
(
bookie
,
mbox_record
);
list_append
(
bookie
,
pop_record
);
list_append
(
bookie
,
imap_record
);
list_append
(
bookie
,
mh_record
);
list_append
(
bookie
,
sendmail_record
);
list_append
(
bookie
,
smtp_record
);
}
...
...
sieve/sieve.h
View file @
4bbd9e2
...
...
@@ -32,8 +32,9 @@ Extended methods:
#include <errno.h>
#include <mailutils/message.h>
#include <mailutils/debug.h>
#include <mailutils/mailer.h>
#include <mailutils/message.h>
/* Sieve specific intepretations of error numbers. */
#define SV_EPARSE ENOEXEC
...
...
@@ -43,9 +44,15 @@ extern const char* sv_strerror(int e);
typedef
struct
sv_interp_ctx_t
*
sv_interp_t
;
typedef
struct
sv_script_ctx_t
*
sv_script_t
;
typedef
void
(
*
sv_parse_error_t
)(
const
char
*
script
,
int
lineno
,
const
char
*
errmsg
);
typedef
void
(
*
sv_execute_error_t
)(
const
char
*
script
,
message_t
msg
,
int
rc
,
const
char
*
errmsg
);
typedef
void
(
*
sv_action_log_t
)(
const
char
*
script
,
message_t
msg
,
const
char
*
action
,
const
char
*
fmt
,
va_list
ap
);
typedef
void
(
*
sv_parse_error_t
)
(
const
char
*
script
,
int
lineno
,
const
char
*
errmsg
);
typedef
void
(
*
sv_execute_error_t
)
(
const
char
*
script
,
message_t
msg
,
int
rc
,
const
char
*
errmsg
);
typedef
void
(
*
sv_action_log_t
)
(
const
char
*
script
,
message_t
msg
,
const
char
*
action
,
const
char
*
fmt
,
va_list
ap
);
extern
int
sv_interp_alloc
(
sv_interp_t
*
i
,
sv_parse_error_t
pe
,
...
...
@@ -54,7 +61,9 @@ extern int sv_interp_alloc(sv_interp_t *i,
extern
void
sv_interp_free
(
sv_interp_t
*
i
);
extern
int
sv_script_parse
(
sv_script_t
*
s
,
sv_interp_t
i
,
const
char
*
script
);
extern
int
sv_script_parse
(
sv_script_t
*
s
,
sv_interp_t
i
,
const
char
*
script
);
extern
void
sv_script_free
(
sv_script_t
*
s
);
#define SV_FLAG_NO_ACTIONS 0x01
...
...
@@ -64,5 +73,7 @@ extern void sv_script_free(sv_script_t *s);
#define SV_DEBUG_HDR_FILL 0x200
#define SV_DEBUG_MSG_QUERY 0x400
extern
int
sv_script_execute
(
sv_script_t
s
,
message_t
m
,
ticket_t
t
,
mu_debug_t
d
,
int
svflags
);
extern
int
sv_script_execute
(
sv_script_t
script
,
message_t
message
,
ticket_t
ticket
,
mu_debug_t
debug
,
mailer_t
mailer
,
int
svflags
);
...
...
sieve/sv.h
View file @
4bbd9e2
...
...
@@ -75,8 +75,12 @@ typedef struct sv_msg_ctx_t
/* Ticket for use by mailbox URLs for implicit authentication. */
ticket_t
ticket
;
/* Debug used for debug output. */
mu_debug_t
debug
;
/* Mailer for redirecting messages. */
mailer_t
mailer
;
/* Flags controlling execution of script. */
int
svflags
;
...
...
@@ -115,7 +119,5 @@ extern int sv_mu_mark_deleted (message_t msg, int deleted);
extern
int
sv_mu_copy_debug_level
(
const
mailbox_t
from
,
mailbox_t
to
);
extern
int
sv_mu_save_to
(
const
char
*
toname
,
message_t
msg
,
ticket_t
ticket
,
mu_debug_t
debug
);
#endif
...
...
sieve/svcb.c
View file @
4bbd9e2
...
...
@@ -4,6 +4,8 @@
#include <stdlib.h>
#include <string.h>
#include <mailutils/envelope.h>
#include "sv.h"
/** mailutils errno to sieve error code translation. */
...
...
@@ -229,13 +231,67 @@ int
sv_redirect
(
void
*
ac
,
void
*
ic
,
void
*
sc
,
void
*
mc
,
const
char
**
errmsg
)
{
sv_msg_ctx_t
*
m
=
(
sv_msg_ctx_t
*
)
mc
;
sieve_redirect_context_t
*
a
=
(
sieve_redirect_context_t
*
)
ac
;
char
*
fromaddr
=
0
;
address_t
to
=
0
;
address_t
from
=
0
;
*
errmsg
=
"redirect not supported"
;
m
->
rc
=
ENOTSUP
;
action_log
(
mc
,
"REDIRECT"
,
"to %s"
,
a
->
addr
);
action_log
(
mc
,
"REDIRECT"
,
""
);
if
(
!
m
->
mailer
)
{
*
errmsg
=
"redirect not supported"
;
m
->
rc
=
ENOTSUP
;
return
SIEVE_FAIL
;
}
return
SIEVE_FAIL
;
*
errmsg
=
"redirect, parsing address"
;
if
((
m
->
rc
=
address_create
(
&
to
,
a
->
addr
)))
goto
end
;
*
errmsg
=
"redirect, getting envelope sender"
;
{
envelope_t
envelope
=
0
;
size_t
sz
=
0
;
if
((
m
->
rc
=
message_get_envelope
(
m
->
msg
,
&
envelope
)))
goto
end
;
if
((
m
->
rc
=
envelope_sender
(
envelope
,
NULL
,
0
,
&
sz
)))
goto
end
;
if
(
!
(
fromaddr
=
malloc
(
sz
+
1
)))
{
m
->
rc
=
ENOMEM
;
goto
end
;
}
if
((
m
->
rc
=
envelope_sender
(
envelope
,
fromaddr
,
sz
+
1
,
NULL
)))
goto
end
;
}
if
((
m
->
rc
=
address_create
(
&
from
,
fromaddr
)))
goto
end
;
*
errmsg
=
"redirect, opening mailer"
;
if
((
m
->
rc
=
mailer_open
(
m
->
mailer
,
0
)))
goto
end
;
*
errmsg
=
"redirect, sending message"
;
if
((
m
->
rc
=
mailer_send_message
(
m
->
mailer
,
m
->
msg
,
from
,
to
)))
goto
end
;
end:
if
(
fromaddr
)
free
(
fromaddr
);
mailer_close
(
m
->
mailer
);
address_destroy
(
&
to
);
address_destroy
(
&
from
);
return
sieve_err
(
m
->
rc
);
}
int
...
...
sieve/svctx.c
View file @
4bbd9e2
...
...
@@ -140,30 +140,32 @@ sv_script_free (sv_script_t * sp)
*
sp
=
0
;
}
int
sv_script_execute
(
sv_script_t
s
,
message_t
m
,
ticket_t
t
,
mu_debug_t
d
,
int
svflags
)
int
sv_script_execute
(
sv_script_t
script
,
message_t
msg
,
ticket_t
ticket
,
mu_debug_t
debug
,
mailer_t
mailer
,
int
svflags
)
{
sv_msg_ctx_t
mc
=
{
0
,
};
int
rc
;
int
isdeleted
;
attribute_t
attr
=
0
;
rc
=
message_get_attribute
(
m
,
&
attr
);
rc
=
message_get_attribute
(
m
sg
,
&
attr
);
if
(
rc
)
return
rc
;
isdeleted
=
attribute_is_deleted
(
attr
);
mc
.
sc
=
s
;
mc
.
msg
=
m
;
mc
.
ticket
=
t
;
mc
.
debug
=
d
;
mc
.
sc
=
script
;
mc
.
msg
=
msg
;
mc
.
ticket
=
ticket
;
mc
.
debug
=
debug
;
mc
.
mailer
=
mailer
;
mc
.
svflags
=
svflags
;
message_get_uid
(
m
,
&
mc
.
uid
);
message_get_uid
(
m
sg
,
&
mc
.
uid
);
rc
=
sieve_execute_script
(
s
->
script
,
&
mc
);
rc
=
sieve_execute_script
(
s
cript
->
script
,
&
mc
);
sv_field_cache_release
(
&
mc
.
cache
);
...
...
@@ -172,7 +174,7 @@ int sv_script_execute (sv_script_t s, message_t m, ticket_t t, mu_debug_t d,
/* Reset the deleted flag if the script failed. */
if
(
rc
)
sv_mu_mark_deleted
(
m
,
isdeleted
);
sv_mu_mark_deleted
(
m
sg
,
isdeleted
);
return
rc
;
}
...
...
Please
register
or
sign in
to post a comment