From c036b0bf8b12fc6981b4fbac0602c87704e53857 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 23 Jan 2020 11:39:29 +0100 Subject: [PATCH] Fix the management of the size of the attachments. --- library/roles/roundcube/defaults/main.yml | 3 +++ library/roles/roundcube/templates/config.inc.php.j2 | 13 ++++++++++++- library/roles/roundcube/vars/main.yml | 6 ++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/library/roles/roundcube/defaults/main.yml b/library/roles/roundcube/defaults/main.yml index b2ca7dd..43b3722 100644 --- a/library/roles/roundcube/defaults/main.yml +++ b/library/roles/roundcube/defaults/main.yml @@ -140,3 +140,6 @@ roundcube_additional_plugins: [] # In Megabytes. This affects both the nginx/apache and php configurations roundcube_max_attachments_size: 5 +# This one is represented in bytes instead. +roundcube_max_db_allowed_packet: '{{ roundcube_max_attachments_size * 1024 * 1024 * 5 }}' + diff --git a/library/roles/roundcube/templates/config.inc.php.j2 b/library/roles/roundcube/templates/config.inc.php.j2 index 1571aa4..52944e9 100644 --- a/library/roles/roundcube/templates/config.inc.php.j2 +++ b/library/roles/roundcube/templates/config.inc.php.j2 @@ -27,6 +27,12 @@ $config = array(); // or (Windows): 'sqlite:///C:/full/path/to/sqlite.db' $config['db_dsnw'] = '{{ roundcube_db }}://{{ roundcube_db_user }}:{{ roundcube_db_pwd }}@{{ roundcube_db_host }}/{{ roundcube_db_name}}'; +// It is possible to specify database variable values e.g. some limits here. +// Use them if your server is not MySQL or for better performance. +// For example Roundcube uses max_allowed_packet value (in bytes) +// which limits query size for database cache operations. +$config['db_max_allowed_packet'] = '{{ roundcube_max_db_allowed_packet }}'; + // The IMAP host chosen to perform the log-in. // Leave blank to show a textbox at login, give a list of hosts // to display a pulldown menu or set one host as string. @@ -80,7 +86,7 @@ $config['des_key'] = '{{ roundcube_crypt_key }}'; $config['cipher_method'] = 'AES-256-CBC'; // List of active plugins (in plugins/ directory) -$config['plugins'] = array({% for plug in roundcube_default_plugins %}'{{ plug }}', {% endfor %}{% for opt_plug in roundcube_optional_plugins %}'{{ opt_plug }}', {% endfor %}{% for add_plug in roundcube_additional_plugins %}'{{ add_plug }}', {% endfor %}{% if roundcube_install_enigma %}{{ roundcube_enigma_plugin }}{% endif %}); +$config['plugins'] = array({% for plug in roundcube_default_plugins %}'{{ plug }}', {% endfor %}{% for opt_plug in roundcube_optional_plugins %}'{{ opt_plug }}', {% endfor %}{% for add_plug in roundcube_additional_plugins %}'{{ add_plug }}', {% endfor %}{% if roundcube_install_enigma %}'{{ roundcube_enigma_plugin }}'{% endif %}); {% if roundcube_install_enigma %} // Enigma Plugin options @@ -201,6 +207,11 @@ $config['apc_max_allowed_packet'] = '2M'; $config['redis_max_allowed_packet'] = '2M'; {% endif %} +// Message size limit. Note that SMTP server(s) may use a different value. +// This limit is verified when user attaches files to a composed message. +// Size in bytes (possible unit suffix: K, M, G) +$config['max_message_size'] = '{{ roundcube_max_attachments_size }}M'; + // THIS OPTION WILL ALLOW THE INSTALLER TO RUN AND CAN EXPOSE SENSITIVE CONFIG DATA. // ONLY ENABLE IT IF YOU'RE REALLY SURE WHAT YOU'RE DOING! $config['enable_installer'] = false; diff --git a/library/roles/roundcube/vars/main.yml b/library/roles/roundcube/vars/main.yml index 722e700..264cafd 100644 --- a/library/roles/roundcube/vars/main.yml +++ b/library/roles/roundcube/vars/main.yml @@ -4,7 +4,7 @@ nginx_client_max_body_size: '{{ roundcube_max_attachments_size * 2 }}M' phpfpm_default_user: '{{ roundcube_user }}' phpfpm_default_pool_name: roundcube -phpfpm_default_memory_limit: '{{ roundcube_max_attachments_size * 4 }}M' +phpfpm_default_memory_limit: '{{ roundcube_max_attachments_size * 10 }}M' redis_install: False http_port: 80 https_port: 443 @@ -28,8 +28,6 @@ php_additional_packages: - postgresql-client - 'php{{ php_version }}-memcache' -phpfpm_default_memory_limit: "64M" - php_global_settings: - { option: 'zlib.output_compression', value: 'Off' } - { option: 'post_max_size', value: '{{ roundcube_max_attachments_size }}M' } @@ -55,5 +53,5 @@ php_global_settings: php_cli_global_settings: '{{ php_global_settings }}' phpfpm_pools: - - { pool_name: '{{ phpfpm_default_pool_name }}', app_context: '{{ phpfpm_default_context }}', user: '{{ phpfpm_default_user }}', group: '{{ phpfpm_default_group }}', listen: '{{ phpfpm_default_listen }}', allowed_clients: '{{ phpfpm_default_allowed_clients }}', pm: '{{ phpfpm_default_pm }}', pm_max_children: '{{ phpfpm_default_pm_max_children }}', pm_start_servers: '{{ phpfpm_default_pm_start_servers }}', pm_min_spare: '{{ phpfpm_default_pm_min_spare_servers }}', pm_max_spare: '{{ phpfpm_default_pm_max_spare_servers }}', pm_max_requests: '{{ phpfpm_default_pm_max_requests }}', pm_status_enabled: '{{ phpfpm_default_pm_status_enabled }}', pm_status_path: '{{ phpfpm_default_pm_status_path }}', ping_enabled: '{{ phpfpm_default_ping_enabled }}', ping_path: '{{ phpfpm_default_ping_path }}', ping_response: '{{ phpfpm_default_ping_response }}', display_errors: '{{ phpfpm_default_display_errors }}', log_errors: '{{ phpfpm_default_log_errors }}', memory_limit: '{{ phpfpm_default_memory_limit }}', slowlog_timeout: '{{ phpfpm_default_slowlog_timeout }}', rlimit_files: '{{ phpfpm_default_rlimit_files }}', php_extensions: '{{ phpfpm_default_extensions }}', define_custom_variables: '{{ phpfpm_default_define_custom_variables }}', doc_root: '{{ roundcube_web_root }}/public_html', req_term_timeout: '240s', virthost: '{{ roundcube_servername }}', nginx_servername: '{{ roundcube_servername }}' } + - { pool_name: '{{ phpfpm_default_pool_name }}', app_context: '{{ phpfpm_default_context }}', user: '{{ phpfpm_default_user }}', group: '{{ phpfpm_default_group }}', listen: '{{ phpfpm_default_listen }}', allowed_clients: '{{ phpfpm_default_allowed_clients }}', pm: '{{ phpfpm_default_pm }}', pm_max_children: '{{ phpfpm_default_pm_max_children }}', pm_start_servers: '{{ phpfpm_default_pm_start_servers }}', pm_min_spare: '{{ phpfpm_default_pm_min_spare_servers }}', pm_max_spare: '{{ phpfpm_default_pm_max_spare_servers }}', pm_max_requests: '{{ phpfpm_default_pm_max_requests }}', pm_status_enabled: '{{ phpfpm_default_pm_status_enabled }}', pm_status_path: '{{ phpfpm_default_pm_status_path }}', ping_enabled: '{{ phpfpm_default_ping_enabled }}', ping_path: '{{ phpfpm_default_ping_path }}', ping_response: '{{ phpfpm_default_ping_response }}', display_errors: '{{ phpfpm_default_display_errors }}', log_errors: '{{ phpfpm_default_log_errors }}', memory_limit: '{{ phpfpm_default_memory_limit }}', slowlog_timeout: '{{ phpfpm_default_slowlog_timeout }}', rlimit_files: '{{ phpfpm_default_rlimit_files }}', php_extensions: '{{ phpfpm_default_extensions }}', upload_max_filesize: '{{ roundcube_max_attachments_size }}M', define_custom_variables: '{{ phpfpm_default_define_custom_variables }}', doc_root: '{{ roundcube_web_root }}/public_html', req_term_timeout: '240s', virthost: '{{ roundcube_servername }}', nginx_servername: '{{ roundcube_servername }}' }