Sieve: carry global variables from sieve_before to user sieve scripts
Hi!
Is there a way to initialize global variables with default values in sieve_before scripts that can be used in the sieve_default script or in user scripts?
I've tried the following code but this doesn't work..
before.d/10-set-defaults.sieve: -------------------- 8< -------------------- require ["variables", "include"]; require "vnd.dovecot.debug"; set "global.S_TESTVAR leo"; debug_log "LEO SIEVE: in before.d/10-set-defaults, S_TESTVAR: ${global.S_TESTVAR}"; -------------------- 8< --------------------
default.sieve: -------------------- 8< -------------------- require ["variables", "include"]; require "vnd.dovecot.debug";
global "S_TESTVAR"; debug_log "LEO SIEVE: in default.sieve: S_TESTVAR: ${global.S_TESTVAR}, ${S_TESTVAR}"; -------------------- 8< --------------------
Is there any other way to set up defaults in a global sieve script?
Cheers, --leo
e-mail ::: Leo.Bergolth (at) wu.ac.at fax ::: +43-1-31336-906050 location ::: IT-Services | Vienna University of Economics | Austria
On 20.10.2014 11:48, Alexander 'Leo' Bergolth wrote:
Is there a way to initialize global variables with default values in sieve_before scripts that can be used in the sieve_default script or in user scripts?
OK. I guess that's currently not possible. I had a quick look in the code, the global variable namespace seems to be copied from the parent script during execution of the include statement. (In ext_include_generate_include() which calls ext_include_create_ast_context().)
So maybe it is possible to take another approach: Instead of executing sieve_before scripts and sieve_default side by side, maybe it is feasible to set the "before-script" as sieve_default and include the default personal user script from there if it exists? That way global variable inheritance should work, shouldn't it?
Did anyone try this approach? Any caveats? Any security implications?
Cheers, --leo
I've tried the following code but this doesn't work..
before.d/10-set-defaults.sieve: -------------------- 8< -------------------- require ["variables", "include"]; require "vnd.dovecot.debug"; set "global.S_TESTVAR leo"; debug_log "LEO SIEVE: in before.d/10-set-defaults, S_TESTVAR: ${global.S_TESTVAR}"; -------------------- 8< --------------------
default.sieve: -------------------- 8< -------------------- require ["variables", "include"]; require "vnd.dovecot.debug";
global "S_TESTVAR"; debug_log "LEO SIEVE: in default.sieve: S_TESTVAR: ${global.S_TESTVAR}, ${S_TESTVAR}"; -------------------- 8< --------------------
Is there any other way to set up defaults in a global sieve script?
-- e-mail ::: Leo.Bergolth (at) wu.ac.at fax ::: +43-1-31336-906050 location ::: IT-Services | Vienna University of Economics | Austria
On 10/25/2014 3:50 PM, Alexander 'Leo' Bergolth wrote:
On 20.10.2014 11:48, Alexander 'Leo' Bergolth wrote:
Is there a way to initialize global variables with default values in sieve_before scripts that can be used in the sieve_default script or in user scripts?
OK. I guess that's currently not possible.
You're right. The global variable namespace is strictly limited to the tree of scripts created by the the "include" extension. No variables are shared between scripts executed in the multiscript sequence (http://tools.ietf.org/html/draft-degener-sieve-multiscript-00#section-4).
So maybe it is possible to take another approach: Instead of executing sieve_before scripts and sieve_default side by side, maybe it is feasible to set the "before-script" as sieve_default and include the default personal user script from there if it exists? That way global variable inheritance should work, shouldn't it?
A bit ugly, but I guess it would work.
Did anyone try this approach? Any caveats? Any security implications?
One big issue with this is that the user can choose not to include the script.
Regards,
Stephan.
participants (2)
-
Alexander 'Leo' Bergolth
-
Stephan Bosch