Skip to content

Commit

Permalink
Added: Dovecot listener files
Browse files Browse the repository at this point in the history
10_dovecot_compress.pl
20_dovecot_connections.pl
30_dovecot_namespace.pl
40_dovecot_pfs.pl
50_dovecot_plaintext.pl
  • Loading branch information
reneschuster committed Feb 2, 2016
1 parent 8d90e6d commit 4c98498
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 0 deletions.
54 changes: 54 additions & 0 deletions contrib/Listeners/Dovecot/10_dovecot_compress.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# i-MSCP Listener::Dovecot::Compress listener file
# Copyright (C) 2015-2016 Rene Schuster <mail@reneschuster.de>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#
## i-MSCP listener file for activating the dovecot compress plugin, to reduce
## the bandwidth usage of IMAP and to also compress the stored mails
## For more information please check:
## http://wiki2.dovecot.org/Plugins/Compress
## http://wiki2.dovecot.org/Plugins/Zlib
#

package Listener::Dovecot::Compress;

use strict;
use warnings;
use iMSCP::EventManager;

iMSCP::EventManager->getInstance()->register('beforePoBuildConf', sub {
my ($cfgTpl, $tplName) = @_;

my $cfgSnippet = <<EOF;
# BEGIN Listener::Dovecot::Compress
zlib_save = gz
zlib_save_level = 6
# END Listener::Dovecot::Compress
EOF

if (index($tplName, 'dovecot.conf') != -1) {
# Enable zlib plugin globally for reading/writing
$$cfgTpl =~ s/^(mail_plugins\s+=.*)/$1 zlib/m;
$$cfgTpl =~ s/^(protocol\simap\s+\{.*?mail_plugins.*?$)/$1 imap_zlib/sm;
# Enable these only if you want compression while saving
$$cfgTpl =~ s/^(plugin\s+\{.*?)(\})/$1$cfgSnippet$2/sm;
}

0;
});

1;
__END__
44 changes: 44 additions & 0 deletions contrib/Listeners/Dovecot/20_dovecot_connections.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# i-MSCP Listener::Dovecot::Connections listener file
# Copyright (C) 2015-2016 Rene Schuster <mail@reneschuster.de>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#
## i-MSCP listener file to increase the mail_max_userip_connections
#

package Listener::Dovecot::Connections;

use strict;
use warnings;
use iMSCP::EventManager;


iMSCP::EventManager->getInstance()->register('beforePoBuildConf', sub {
my ($cfgTpl, $tplName) = @_;

my $cfgSnippet = <<EOF;
# BEGIN Listener::Dovecot::Connections
mail_max_userip_connections = 50
# END Listener::Dovecot::Connections
EOF

$$cfgTpl .= "\n$cfgSnippet" if index($tplName, 'dovecot.conf') != -1;

0;
});

1;
__END__
56 changes: 56 additions & 0 deletions contrib/Listeners/Dovecot/30_dovecot_namespace.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# i-MSCP Listener::Dovecot::Namespace listener file
# Copyright (C) 2015-2016 Rene Schuster <mail@reneschuster.de>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#
## i-MSCP listener file that creates the INBOX. as a compatibility name,
## so old clients can continue using it while new clients will use the
## empty prefix namespace.
#

package Listener::Dovecot::Namespace;

use strict;
use warnings;
use iMSCP::EventManager;

iMSCP::EventManager->getInstance()->register('beforePoBuildConf', sub {
my ($cfgTpl, $tplName) = @_;

my $cfgSnippet = <<EOF;
# BEGIN Listener::Dovecot::Namespace
namespace compat {
separator = .
prefix = INBOX.
inbox = no
hidden = yes
list = no
alias_for =
}
# END Listener::Dovecot::Namespace
EOF

if(index($tplName, 'dovecot.conf') != -1) {
$$cfgTpl =~ s/(separator\s+=\s+)\./$1\//;
$$cfgTpl =~ s/(prefix\s+=\s+)INBOX\./$1/;
$$cfgTpl =~ s/^(namespace\s+inbox\s+\{.*?^\}\n)/$1\n$cfgSnippet/sm;
}

0;
});

1;
__END__
43 changes: 43 additions & 0 deletions contrib/Listeners/Dovecot/40_dovecot_pfs.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# i-MSCP Listener::Dovecot::PFS listener file
# Copyright (C) 2016 Rene Schuster <mail@reneschuster.de>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#
## i-MSCP listener file to activate the Perfect Forward Secrecy logging
#

package Listener::Dovecot::PFS;

use strict;
use warnings;
use iMSCP::EventManager;

iMSCP::EventManager->getInstance()->register('beforePoBuildConf', sub {
my ($cfgTpl, $tplName) = @_;

my $cfgSnippet = <<EOF;
# BEGIN Listener::Dovecot::PFS
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e %c %k session=<%{session}>
# END Listener::Dovecot::PFS
EOF

$$cfgTpl .= "\n$cfgSnippet" if index($tplName, 'dovecot.conf') != -1;

0;
});

1;
__END__
42 changes: 42 additions & 0 deletions contrib/Listeners/Dovecot/50_dovecot_plaintext.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# i-MSCP Listener::Dovecot::Plaintext listener file
# Copyright (C) 2015-2016 Rene Schuster <mail@reneschuster.de>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

#
## i-MSCP listener file to disable plaintext logins and force tls.
## Also remove the authentication mechanisms cram-md5 and digest-md5
## which won't be supported anymore in i-MSCP 1.3
#

package Listener::Dovecot::Plaintext;

use strict;
use warnings;
use iMSCP::EventManager;

iMSCP::EventManager->getInstance()->register('beforePoBuildConf', sub {
my ($cfgTpl, $tplName) = @_;

if (index($tplName, 'dovecot.conf') != -1) {
$$cfgTpl =~ s/\s+cram-md5\s+digest-md5//;
$$cfgTpl =~ s/^(disable_plaintext_auth\s+=\s+).*/$1yes/m;
}

0;
});

1;
__END__
27 changes: 27 additions & 0 deletions contrib/Listeners/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,33 @@ Listener file that allows to override Apache2 ServerAlias directive value.

Listener file that allows to change the domain redirect type in customer's vhost files from 302 to 301.

## Dovecot listeners

### 10_dovecot_compress.pl

Listener file for activating the dovecot compress plugin, to reduce the bandwidth usage of IMAP and to also compress
the stored mails. For more information please check:
http://wiki2.dovecot.org/Plugins/Compress
http://wiki2.dovecot.org/Plugins/Zlib

### 20_dovecot_connections.pl

Listener file to increase the mail_max_userip_connections

### 30_dovecot_namespace.pl

Listener file that creates the INBOX. as a compatibility name, so old clients can continue using it while new clients
will use the empty prefix namespace.

### 40_dovecot_pfs.pl

Listener file to activate the Perfect Forward Secrecy logging

### 50_dovecot_plaintext.pl

Listener file to disable plaintext logins and force tls.
Also remove the authentication mechanisms cram-md5 and digest-md5 which won't be supported anymore in i-MSCP 1.3

## Named listeners

### 10_bind9_localnets.pl
Expand Down

0 comments on commit 4c98498

Please sign in to comment.