Skip to content
Snippets Groups Projects
Commit 639b71a3 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

* Minor changes to the extension implementation

* Started the lda plugin source
parent 06b238a1
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ sievec_SOURCES = \ ...@@ -39,6 +39,7 @@ sievec_SOURCES = \
sieve-validator.c \ sieve-validator.c \
sieve-generator.c \ sieve-generator.c \
sieve-interpreter.c \ sieve-interpreter.c \
sieve-result.c \
sieve-error.c \ sieve-error.c \
sieve-commands.c \ sieve-commands.c \
sieve-code.c \ sieve-code.c \
...@@ -51,10 +52,12 @@ sievec_SOURCES = \ ...@@ -51,10 +52,12 @@ sievec_SOURCES = \
noinst_HEADERS = \ noinst_HEADERS = \
sieve-lexer.h \ sieve-lexer.h \
sieve-ast.h \ sieve-ast.h \
sieve-binary.h \
sieve-parser.h \ sieve-parser.h \
sieve-validator.h \ sieve-validator.h \
sieve-generator.h \ sieve-generator.h \
sieve-interpreter.h \ sieve-interpreter.h \
sieve-result.h
sieve-error.h \ sieve-error.h \
sieve-commands.h \ sieve-commands.h \
sieve-code.h sieve-code.h
......
...@@ -79,3 +79,32 @@ static bool ext_fileinto_opcode_dump(struct sieve_interpreter *interpreter) ...@@ -79,3 +79,32 @@ static bool ext_fileinto_opcode_dump(struct sieve_interpreter *interpreter)
return TRUE; return TRUE;
} }
/*
* Execution
*/
static bool ext_fileinto_opcode_execute(struct sieve_interpreter *interpreter)
{
}
/*
static int sieve_fileinto(void *ac,
void *ic ATTR_UNUSED,
void *sc,
void *mc,
const char **errmsg ATTR_UNUSED)
{
sieve_fileinto_context_t *fc = (sieve_fileinto_context_t *) ac;
script_data_t *sd = (script_data_t *) sc;
sieve_msgdata_t *md = (sieve_msgdata_t *) mc;
enum mail_flags flags;
const char *const *keywords;
get_flags(fc->imapflags, &flags, &keywords);
if (deliver_save(sd->namespaces, sd->storage_r, fc->mailbox,
md->mail, flags, keywords) < 0)
return SIEVE_FAIL;
return SIEVE_OK;
}*/
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "lib.h" #include "lib.h"
#include "buffer.h" #include "buffer.h"
#include "mail-storage.h"
#include "sieve-binary.h" #include "sieve-binary.h"
...@@ -10,6 +11,14 @@ struct sieve_coded_stringlist; ...@@ -10,6 +11,14 @@ struct sieve_coded_stringlist;
struct sieve_interpreter; struct sieve_interpreter;
struct sieve_mail_context {
struct mail_namespace *namespaces;
struct mail_storage **storage_r;
struct mail *mail;
const char *destaddr;
const char *mailbox;
};
struct sieve_interpreter *sieve_interpreter_create(struct sieve_binary *binary); struct sieve_interpreter *sieve_interpreter_create(struct sieve_binary *binary);
void sieve_interpreter_free(struct sieve_interpreter *interpreter); void sieve_interpreter_free(struct sieve_interpreter *interpreter);
......
SUBDIRS = lda-sieve
SUBDIRS = libsieve
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib-sieve \
-I$(dovecot_incdir) \
-I$(dovecot_incdir)/src/lib \
-I$(dovecot_incdir)/src/lib-dict \
-I$(dovecot_incdir)/src/lib-mail \
-I$(dovecot_incdir)/src/lib-storage \
-I$(dovecot_incdir)/src/deliver
lda_moduledir = $(moduledir)/lda
lib90_cmusieve_plugin_la_LDFLAGS = -module -avoid-version
lda_module_LTLIBRARIES = \
lib90_cmusieve_plugin.la
lib90_cmusieve_plugin_la_LIBADD = \
libsieve/libsieve.la
lib90_cmusieve_plugin_la_SOURCES = \
cmusieve-plugin.c \
imparse.c \
map.c \
sieve-cmu.c
noinst_HEADERS = \
cmusieve-plugin.h \
imparse.h \
libconfig.h \
map.h \
xmalloc.h
/* Copyright (C) 2006 Timo Sirainen */
#include "lib.h"
#include "home-expand.h"
#include "deliver.h"
#include "sieve-compiler.h"
#include "lda-sieve-plugin.h"
#include <stdlib.h>
#include <sys/stat.h>
#define SIEVE_SCRIPT_PATH "~/.dovecot.sieve"
static deliver_mail_func_t *next_deliver_mail;
struct et_list *_et_list = NULL;
static const char *get_sieve_path(void)
{
const char *script_path, *home;
struct stat st;
home = getenv("HOME");
/* userdb may specify Sieve path */
script_path = getenv("SIEVE");
if (script_path != NULL) {
if (*script_path == '\0') {
/* disabled */
return NULL;
}
if (*script_path != '/' && *script_path != '\0') {
/* relative path. change to absolute. */
script_path = t_strconcat(getenv("HOME"), "/",
script_path, NULL);
}
} else {
if (home == NULL) {
i_error("Per-user script path is unknown. See "
"http://wiki.dovecot.org/LDA/Sieve#location");
return NULL;
}
script_path = home_expand(SIEVE_SCRIPT_PATH);
}
if (stat(script_path, &st) < 0) {
if (errno != ENOENT)
i_error("stat(%s) failed: %m", script_path);
/* use global script instead, if one exists */
script_path = getenv("SIEVE_GLOBAL_PATH");
if (script_path == NULL) {
/* for backwards compatibility */
script_path = getenv("GLOBAL_SCRIPT_PATH");
}
}
return script_path;
}
static int
lda_sieve_deliver_mail(struct mail_namespace *namespaces,
struct mail_storage **storage_r,
struct mail *mail,
const char *destaddr, const char *mailbox)
{
const char *script_path;
script_path = get_sieve_path();
if (script_path == NULL)
return 0;
if (getenv("DEBUG") != NULL)
i_info("sieve: Using sieve path: %s", script_path);
return sieve_run(namespaces, storage_r, mail, script_path,
destaddr, getenv("USER"), mailbox);
}
void lda_sieve_plugin_init(void)
{
next_deliver_mail = deliver_mail;
deliver_mail = lda_sieve_deliver_mail;
}
void lda_sieve_plugin_deinit(void)
{
deliver_mail = next_deliver_mail;
}
#ifndef __LDA_SIEVE_PLUGIN_H
#define __LDA_SIEVE_PLUGIN_H
int lda_sieve_run(struct mail_namespace *namespaces,
struct mail_storage **storage_r, struct mail *mail,
const char *script_path, const char *destaddr,
const char *username, const char *mailbox);
void lda_sieve_plugin_init(void);
void lda_sieve_plugin_deinit(void);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.