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

Made homedir aquisition a callback.

parent 924f83b7
No related branches found
No related tags found
No related merge requests found
......@@ -91,8 +91,6 @@ Next (in order of descending priority/precedence):
through IMAP (no specification for something like this is available; we will
have to provide our own)
* Variables extension: implement compile time evaluation of constant values
* Make the engine and its extensions much more configurable. Possibly this can
be merged with Dovecot's new master config implementation.
* Add development documentation, i.e. comment on library functions and document
the binary and byte-code format.
* Give the byte code format some more thought, it is currently quite rough and
......
......@@ -31,13 +31,20 @@ struct sieve_instance *sieve_instance;
* Settings management
*/
static const char *sieve_tool_get_setting
const char *sieve_tool_get_setting
(void *context ATTR_UNUSED, const char *identifier)
{
return getenv(t_str_ucase(identifier));
}
static const struct sieve_callbacks sieve_tool_callbacks = {
const char *sieve_tool_get_homedir
(void *context ATTR_UNUSED)
{
return getenv("HOME");
}
const struct sieve_callbacks sieve_tool_callbacks = {
sieve_tool_get_homedir,
sieve_tool_get_setting
};
......
......@@ -14,6 +14,11 @@
struct sieve_instance *sieve_instance;
const char *sieve_tool_get_setting(void *context, const char *identifier);
const char *sieve_tool_get_homedir(void *context);
const struct sieve_callbacks sieve_tool_callbacks;
/*
* Initialization
*/
......
......@@ -79,9 +79,7 @@ const char *ext_include_get_script_directory
case EXT_INCLUDE_LOCATION_PERSONAL:
sieve_dir = sieve_get_setting(svinst, "sieve_dir");
home = sieve_get_setting(svinst, "home");
if ( home == NULL ) home = getenv("HOME");
home = sieve_get_homedir(svinst);
if ( sieve_dir == NULL ) {
if ( home == NULL ) {
......
......@@ -6,6 +6,10 @@
#include "sieve-common.h"
/*
* Settings
*/
static inline const char *sieve_get_setting
(struct sieve_instance *svinst, const char *identifier)
{
......@@ -25,4 +29,19 @@ bool sieve_get_int_setting
(struct sieve_instance *svinst, const char *identifier,
long long int *value_r);
/*
* Home directory
*/
static inline const char *sieve_get_homedir
(struct sieve_instance *svinst)
{
const struct sieve_callbacks *callbacks = svinst->callbacks;
if ( callbacks == NULL || callbacks->get_homedir == NULL )
return NULL;
return callbacks->get_homedir(svinst->context);
}
#endif /* __SIEVE_SETTINGS_H */
......@@ -30,6 +30,7 @@ struct sieve_exec_status;
*/
struct sieve_callbacks {
const char *(*get_homedir)(void *context);
const char *(*get_setting)(void *context, const char *identifier);
};
......
......@@ -38,6 +38,21 @@ static deliver_mail_func_t *next_deliver_mail;
* Settings handling
*/
static const char *lda_sieve_get_homedir
(void *context)
{
struct mail_user *mail_user = (struct mail_user *) context;
const char *home = NULL;
if ( mail_user == NULL )
return NULL;
if ( mail_user_get_home(mail_user, &home) <= 0 )
return NULL;
return home;
}
static const char *lda_sieve_get_setting
(void *context, const char *identifier)
{
......@@ -50,6 +65,7 @@ static const char *lda_sieve_get_setting
}
static const struct sieve_callbacks lda_sieve_callbacks = {
lda_sieve_get_homedir,
lda_sieve_get_setting
};
......
......@@ -51,6 +51,7 @@ const struct sieve_script_env *testsuite_scriptenv;
*/
static const struct sieve_callbacks testsuite_sieve_callbacks = {
sieve_tool_get_homedir,
testsuite_setting_get
};
......
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.