Skip to content

Commit 93c5764

Browse files
gejobjjaapmarcus
andauthored
Sieve support (hestiacp#2163)
* Sieve support Dovecot, Exim4 and roundcube modifications to support sieve on Ubuntu 20.04.3 LTS * Added v-add-sys-sieve command Added a shell script to install and uninstall sieve on Ubuntu 20.04.3 LTS * Update hst-install-ubuntu.sh Remove uninstall section from installation script * FIX - added dovecot-managesieved to apt added dovecot-managesieved to apt install and restart services * FIX - permission changes Permission changes in /var/log/dovecot.log * Move v-add-sys-sieve to upgrade folder - Changed -b to -Z for sieve - Added support for Debian * PHP8.0 json installed on default * Remove php-json also from php-fpm build + new line "bug" * Add install dir(s) RC for Sieve * Remove not needed commands + Use smaller qoutes instead in upgrade.conf Include syshealth.sh for v-update-sys-defaults * Fix issue with exim * Replace exim with exim4 due to error in the past * Remove dovecot_virtual_delivery out default exim.conf After sed in installers it will be duplicate and there fore causing issues * Fix bug disable sieve regex for Exim Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent 679d7c4 commit 93c5764

File tree

14 files changed

+818
-81
lines changed

14 files changed

+818
-81
lines changed

bin/v-add-sys-roundcube

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ if [ "$UPDATE" == "no" ]; then
113113
ln -s $RC_CONFIG_DIR/plugins/newmail_notifier/config.inc.php ./plugins/newmail_notifier/config.inc.php
114114
cp -f $HESTIA_INSTALL_DIR/roundcube/plugins/config_zipdownload.inc.php $RC_CONFIG_DIR/plugins/zipdownload/config.inc.php
115115
ln -s $RC_CONFIG_DIR/plugins/zipdownload/config.inc.php ./plugins/zipdownload/config.inc.php
116+
116117
# Set up correct permissions roundcube
117118
chown -R root:www-data $RC_CONFIG_DIR/
118119
chmod 751 -R $RC_CONFIG_DIR

bin/v-update-sys-defaults

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ system=$1
1515
source /etc/hestiacp/hestia.conf
1616
# shellcheck source=/usr/local/hestia/func/main.sh
1717
source $HESTIA/func/main.sh
18+
# shellcheck source=/usr/local/hestia/func/syshealth.sh
19+
source $HESTIA/func/syshealth.sh
1820
# load config file
1921
source_conf "$HESTIA/conf/hestia.conf"
2022

install/deb/dovecot/conf.d/10-master.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ service auth {
2525
mode = 0660
2626
user = dovecot
2727
}
28+
unix_listener auth-master {
29+
group = mail
30+
mode = 0660
31+
user = dovecot
32+
}
2833
user = dovecot
2934
}

install/deb/dovecot/conf.d/20-imap.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ protocol imap {
1414

1515
# Space separated list of plugins to load (default is global mail_plugins).
1616
#mail_plugins = $mail_plugins
17-
mail_plugins = quota imap_quota
17+
mail_plugins = quota imap_quota imap_sieve
1818

1919
# IMAP logout format string:
2020
# %i - total number of bytes read from client

install/deb/dovecot/dovecot.conf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ login_greeting = Mail Delivery Agent
55
!include conf.d/*.conf
66
!include_try conf.d/domains/*.conf
77

8+
service stats {
9+
unix_listener stats-writer {
10+
group = mail
11+
mode = 0660
12+
user = dovecot
13+
}
14+
}
15+
816
namespace {
917
type = private
1018
separator = /
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
##
2+
## ManageSieve specific settings
3+
##
4+
5+
# Uncomment to enable managesieve protocol:
6+
protocols = $protocols sieve
7+
8+
# Service definitions
9+
10+
service managesieve-login {
11+
inet_listener sieve {
12+
port = 4190
13+
}
14+
15+
#inet_listener sieve_deprecated {
16+
# port = 2000
17+
#}
18+
19+
# Number of connections to handle before starting a new process. Typically
20+
# the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0
21+
# is faster. <doc/wiki/LoginProcess.txt>
22+
#service_count = 1
23+
24+
# Number of processes to always keep waiting for more connections.
25+
#process_min_avail = 0
26+
27+
# If you set service_count=0, you probably need to grow this.
28+
#vsz_limit = 64M
29+
}
30+
31+
#service managesieve {
32+
# Max. number of ManageSieve processes (connections)
33+
#process_limit = 1024
34+
#}
35+
36+
# Service configuration
37+
38+
protocol sieve {
39+
# Maximum ManageSieve command line length in bytes. ManageSieve usually does
40+
# not involve overly long command lines, so this setting will not normally
41+
# need adjustment
42+
managesieve_max_line_length = 65536
43+
44+
# Maximum number of ManageSieve connections allowed for a user from each IP
45+
# address.
46+
# NOTE: The username is compared case-sensitively.
47+
#mail_max_userip_connections = 10
48+
49+
# Space separated list of plugins to load (none known to be useful so far).
50+
# Do NOT try to load IMAP plugins here.
51+
#mail_plugins =
52+
53+
# MANAGESIEVE logout format string:
54+
# %i - total number of bytes read from client
55+
# %o - total number of bytes sent to client
56+
# %{put_bytes} - Number of bytes saved using PUTSCRIPT command
57+
# %{put_count} - Number of scripts saved using PUTSCRIPT command
58+
# %{get_bytes} - Number of bytes read using GETCRIPT command
59+
# %{get_count} - Number of scripts read using GETSCRIPT command
60+
# %{get_bytes} - Number of bytes processed using CHECKSCRIPT command
61+
# %{get_count} - Number of scripts checked using CHECKSCRIPT command
62+
# %{deleted_count} - Number of scripts deleted using DELETESCRIPT command
63+
# %{renamed_count} - Number of scripts renamed using RENAMESCRIPT command
64+
#managesieve_logout_format = bytes=%i/%o
65+
66+
# To fool ManageSieve clients that are focused on CMU's timesieved you can
67+
# specify the IMPLEMENTATION capability that Dovecot reports to clients.
68+
# For example: 'Cyrus timsieved v2.2.13'
69+
managesieve_implementation_string = Dovecot Pigeonhole
70+
71+
# Explicitly specify the SIEVE and NOTIFY capability reported by the server
72+
# before login. If left unassigned these will be reported dynamically
73+
# according to what the Sieve interpreter supports by default (after login
74+
# this may differ depending on the user).
75+
#managesieve_sieve_capability =
76+
#managesieve_notify_capability =
77+
78+
# The maximum number of compile errors that are returned to the client upon
79+
# script upload or script verification.
80+
#managesieve_max_compile_errors = 5
81+
82+
# Refer to 90-sieve.conf for script quota configuration and configuration of
83+
# Sieve execution limits.
84+
85+
#log_path = /var/log/dovecot-sieve-errors.log
86+
#info_log_path = /var/log/dovecot-sieve.log
87+
88+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Sieve Extprograms plugin configuration
2+
3+
# Don't forget to add the sieve_extprograms plugin to the sieve_plugins setting.
4+
# Also enable the extensions you need (one or more of vnd.dovecot.pipe,
5+
# vnd.dovecot.filter and vnd.dovecot.execute) by adding these to the
6+
# sieve_extensions or sieve_global_extensions settings. Restricting these
7+
# extensions to a global context using sieve_global_extensions is recommended.
8+
9+
plugin {
10+
11+
# The directory where the program sockets are located for the
12+
# vnd.dovecot.pipe, vnd.dovecot.filter and vnd.dovecot.execute extension
13+
# respectively. The name of each unix socket contained in that directory
14+
# directly maps to a program-name referenced from the Sieve script.
15+
#sieve_pipe_socket_dir = sieve-pipe
16+
#sieve_filter_socket_dir = sieve-filter
17+
#sieve_execute_socket_dir = sieve-execute
18+
19+
# The directory where the scripts are located for direct execution by the
20+
# vnd.dovecot.pipe, vnd.dovecot.filter and vnd.dovecot.execute extension
21+
# respectively. The name of each script contained in that directory
22+
# directly maps to a program-name referenced from the Sieve script.
23+
#sieve_pipe_bin_dir = /usr/lib/dovecot/sieve-pipe
24+
#sieve_filter_bin_dir = /usr/lib/dovecot/sieve-filter
25+
#sieve_execute_bin_dir = /usr/lib/dovecot/sieve-execute
26+
27+
}
28+
29+
# An example program service called 'do-something' to pipe messages to
30+
#service do-something {
31+
# Define the executed script as parameter to the sieve service
32+
#executable = script /usr/lib/dovecot/sieve-pipe/do-something.sh
33+
34+
# Use some unprivileged user for executing the program
35+
#user = dovenull
36+
37+
# The unix socket located in the sieve_pipe_socket_dir (as defined in the
38+
# plugin {} section above)
39+
#unix_listener sieve-pipe/do-something {
40+
# LDA/LMTP must have access
41+
# user = vmail
42+
# mode = 0600
43+
#}
44+
#}
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
##
2+
## Settings for the Sieve interpreter
3+
##
4+
5+
# Do not forget to enable the Sieve plugin in 15-lda.conf and 20-lmtp.conf
6+
# by adding it to the respective mail_plugins= settings.
7+
8+
# The Sieve interpreter can retrieve Sieve scripts from several types of
9+
# locations. The default `file' location type is a local filesystem path
10+
# pointing to a Sieve script file or a directory containing multiple Sieve
11+
# script files. More complex setups can use other location types such as
12+
# `ldap' or `dict' to fetch Sieve scripts from remote databases.
13+
#
14+
# All settings that specify the location of one ore more Sieve scripts accept
15+
# the following syntax:
16+
#
17+
# location = [<type>:]path[;<option>[=<value>][;...]]
18+
#
19+
# If the type prefix is omitted, the script location type is 'file' and the
20+
# location is interpreted as a local filesystem path pointing to a Sieve script
21+
# file or directory. Refer to Pigeonhole wiki or INSTALL file for more
22+
# information.
23+
24+
plugin {
25+
# The location of the user's main Sieve script or script storage. The LDA
26+
# Sieve plugin uses this to find the active script for Sieve filtering at
27+
# delivery. The "include" extension uses this location for retrieving
28+
# :personal" scripts. This is also where the ManageSieve service will store
29+
# the user's scripts, if supported.
30+
#
31+
# Currently only the 'file:' location type supports ManageSieve operation.
32+
# Other location types like 'dict:' and 'ldap:' can currently only
33+
# be used as a read-only script source ().
34+
#
35+
# For the 'file:' type: use the ';active=' parameter to specify where the
36+
# active script symlink is located.
37+
# For other types: use the ';name=' parameter to specify the name of the
38+
# default/active script.
39+
#sieve = file:~/sieve;active=~/.dovecot.sieve
40+
sieve = file:~/mail/%d/%n/sieve;active=~/mail/%d/%n/dovecot.sieve
41+
42+
# The default Sieve script when the user has none. This is the location of a
43+
# global sieve script file, which gets executed ONLY if user's personal Sieve
44+
# script doesn't exist. Be sure to pre-compile this script manually using the
45+
# sievec command line tool if the binary is not stored in a global location.
46+
# --> See sieve_before for executing scripts before the user's personal
47+
# script.
48+
#sieve_default = /var/lib/dovecot/sieve/default.sieve
49+
50+
# The name by which the default Sieve script (as configured by the
51+
# sieve_default setting) is visible to the user through ManageSieve.
52+
#sieve_default_name =
53+
54+
# Location for ":global" include scripts as used by the "include" extension.
55+
#sieve_global =
56+
57+
# The location of a Sieve script that is run for any message that is about to
58+
# be discarded; i.e., it is not delivered anywhere by the normal Sieve
59+
# execution. This only happens when the "implicit keep" is canceled, by e.g.
60+
# the "discard" action, and no actions that deliver the message are executed.
61+
# This "discard script" can prevent discarding the message, by executing
62+
# alternative actions. If the discard script does nothing, the message is
63+
# still discarded as it would be when no discard script is configured.
64+
#sieve_discard =
65+
66+
# Location Sieve of scripts that need to be executed before the user's
67+
# personal script. If a 'file' location path points to a directory, all the
68+
# Sieve scripts contained therein (with the proper `.sieve' extension) are
69+
# executed. The order of execution within that directory is determined by the
70+
# file names, using a normal 8bit per-character comparison.
71+
#
72+
# Multiple script locations can be specified by appending an increasing number
73+
# to the setting name. The Sieve scripts found from these locations are added
74+
# to the script execution sequence in the specified order. Reading the
75+
# numbered sieve_before settings stops at the first missing setting, so no
76+
# numbers may be skipped.
77+
#sieve_before = /var/lib/dovecot/sieve.d/
78+
#sieve_before2 = ldap:/etc/sieve-ldap.conf;name=ldap-domain
79+
#sieve_before3 = (etc...)
80+
81+
# Identical to sieve_before, only the specified scripts are executed after the
82+
# user's script (only when keep is still in effect!). Multiple script
83+
# locations can be specified by appending an increasing number.
84+
#sieve_after =
85+
#sieve_after2 =
86+
#sieve_after2 = (etc...)
87+
88+
# Which Sieve language extensions are available to users. By default, all
89+
# supported extensions are available, except for deprecated extensions or
90+
# those that are still under development. Some system administrators may want
91+
# to disable certain Sieve extensions or enable those that are not available
92+
# by default. This setting can use '+' and '-' to specify differences relative
93+
# to the default. For example `sieve_extensions = +imapflags' will enable the
94+
# deprecated imapflags extension in addition to all extensions were already
95+
# enabled by default.
96+
sieve_extensions = +notify +imapflags
97+
98+
# Which Sieve language extensions are ONLY available in global scripts. This
99+
# can be used to restrict the use of certain Sieve extensions to administrator
100+
# control, for instance when these extensions can cause security concerns.
101+
# This setting has higher precedence than the `sieve_extensions' setting
102+
# (above), meaning that the extensions enabled with this setting are never
103+
# available to the user's personal script no matter what is specified for the
104+
# `sieve_extensions' setting. The syntax of this setting is similar to the
105+
# `sieve_extensions' setting, with the difference that extensions are
106+
# enabled or disabled for exclusive use in global scripts. Currently, no
107+
# extensions are marked as such by default.
108+
sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
109+
110+
# The Pigeonhole Sieve interpreter can have plugins of its own. Using this
111+
# setting, the used plugins can be specified. Check the Dovecot wiki
112+
# (wiki2.dovecot.org) or the pigeonhole website
113+
# (http://pigeonhole.dovecot.org) for available plugins.
114+
# The sieve_extprograms plugin is included in this release.
115+
sieve_plugins = sieve_imapsieve sieve_extprograms
116+
117+
sieve_pipe_bin_dir = /etc/dovecot/sieve
118+
119+
# The maximum size of a Sieve script. The compiler will refuse to compile any
120+
# script larger than this limit. If set to 0, no limit on the script size is
121+
# enforced.
122+
#sieve_max_script_size = 1M
123+
124+
# The maximum number of actions that can be performed during a single script
125+
# execution. If set to 0, no limit on the total number of actions is enforced.
126+
#sieve_max_actions = 32
127+
128+
# The maximum number of redirect actions that can be performed during a single
129+
# script execution. If set to 0, no redirect actions are allowed.
130+
#sieve_max_redirects = 4
131+
132+
# The maximum number of personal Sieve scripts a single user can have. If set
133+
# to 0, no limit on the number of scripts is enforced.
134+
# (Currently only relevant for ManageSieve)
135+
#sieve_quota_max_scripts = 0
136+
137+
# The maximum amount of disk storage a single user's scripts may occupy. If
138+
# set to 0, no limit on the used amount of disk storage is enforced.
139+
# (Currently only relevant for ManageSieve)
140+
#sieve_quota_max_storage = 0
141+
142+
# The primary e-mail address for the user. This is used as a default when no
143+
# other appropriate address is available for sending messages. If this setting
144+
# is not configured, either the postmaster or null "<>" address is used as a
145+
# sender, depending on the action involved. This setting is important when
146+
# there is no message envelope to extract addresses from, such as when the
147+
# script is executed in IMAP.
148+
#sieve_user_email =
149+
150+
# The path to the file where the user log is written. If not configured, a
151+
# default location is used. If the main user's personal Sieve (as configured
152+
# with sieve=) is a file, the logfile is set to <filename>.log by default. If
153+
# it is not a file, the default user log file is ~/.dovecot.sieve.log.
154+
#sieve_user_log =
155+
156+
# Specifies what envelope sender address is used for redirected messages.
157+
# The following values are supported for this setting:
158+
#
159+
# "sender" - The sender address is used (default).
160+
# "recipient" - The final recipient address is used.
161+
# "orig_recipient" - The original recipient is used.
162+
# "user_email" - The user's primary address is used. This is
163+
# configured with the "sieve_user_email" setting. If
164+
# that setting is unconfigured, "user_mail" is equal to
165+
# "recipient".
166+
# "postmaster" - The postmaster_address configured for the LDA.
167+
# "<user@domain>" - Redirected messages are always sent from user@domain.
168+
# The angle brackets are mandatory. The null "<>" address
169+
# is also supported.
170+
#
171+
# This setting is ignored when the envelope sender is "<>". In that case the
172+
# sender of the redirected message is also always "<>".
173+
#sieve_redirect_envelope_from = sender
174+
175+
## TRACE DEBUGGING
176+
# Trace debugging provides detailed insight in the operations performed by
177+
# the Sieve script. These settings apply to both the LDA Sieve plugin and the
178+
# IMAPSIEVE plugin.
179+
#
180+
# WARNING: On a busy server, this functionality can quickly fill up the trace
181+
# directory with a lot of trace files. Enable this only temporarily and as
182+
# selective as possible.
183+
184+
# The directory where trace files are written. Trace debugging is disabled if
185+
# this setting is not configured or if the directory does not exist. If the
186+
# path is relative or it starts with "~/" it is interpreted relative to the
187+
# current user's home directory.
188+
#sieve_trace_dir =
189+
190+
# The verbosity level of the trace messages. Trace debugging is disabled if
191+
# this setting is not configured. Possible values are:
192+
#
193+
# "actions" - Only print executed action commands, like keep,
194+
# fileinto, reject and redirect.
195+
# "commands" - Print any executed command, excluding test commands.
196+
# "tests" - Print all executed commands and performed tests.
197+
# "matching" - Print all executed commands, performed tests and the
198+
# values matched in those tests.
199+
#sieve_trace_level =
200+
201+
# Enables highly verbose debugging messages that are usually only useful for
202+
# developers.
203+
#sieve_trace_debug = no
204+
205+
# Enables showing byte code addresses in the trace output, rather than only
206+
# the source line numbers.
207+
#sieve_trace_addresses = no
208+
}

0 commit comments

Comments
 (0)