From fba3e1ae0c0f4c1d73f55b9f97674c3ed7e695e0 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 25 Sep 2016 08:35:18 +0200 Subject: [PATCH 01/24] GnuPG 2.1: Add option to configure gpgconf binary location --- plugins/enigma/config.inc.php.dist | 4 ++++ plugins/enigma/lib/enigma_driver_gnupg.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/plugins/enigma/config.inc.php.dist b/plugins/enigma/config.inc.php.dist index 581ac8534b3..aa4280f419b 100644 --- a/plugins/enigma/config.inc.php.dist +++ b/plugins/enigma/config.inc.php.dist @@ -24,6 +24,10 @@ $config['enigma_pgp_binary'] = ''; // It's used with GnuPG 2.x. $config['enigma_pgp_agent'] = ''; +// Location of gpgconf binary. By default it will be auto-detected. +// It's used with GnuPG >= 2.1. +$config['enigma_pgp_gpgconf'] = ''; + // Enables signatures verification feature. $config['enigma_signatures'] = true; diff --git a/plugins/enigma/lib/enigma_driver_gnupg.php b/plugins/enigma/lib/enigma_driver_gnupg.php index 3c02f9f4392..267af4fd1de 100644 --- a/plugins/enigma/lib/enigma_driver_gnupg.php +++ b/plugins/enigma/lib/enigma_driver_gnupg.php @@ -43,6 +43,7 @@ function init() $debug = $this->rc->config->get('enigma_debug'); $binary = $this->rc->config->get('enigma_pgp_binary'); $agent = $this->rc->config->get('enigma_pgp_agent'); + $gpgconf = $this->rc->config->get('enigma_pgp_gpgconf'); if (!$homedir) { return new enigma_error(enigma_error::INTERNAL, @@ -88,6 +89,9 @@ function init() if ($agent) { $options['agent'] = $agent; } + if ($gpgconf) { + $options['gpgconf'] = $gpgconf; + } // Create Crypt_GPG object try { From 7829da358d80bc0a07b6b86dfc01f52abe7bce2f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 25 Sep 2016 13:05:21 +0200 Subject: [PATCH 02/24] GnuPG 2.1: Fix importing newly generated (secret) keys using GnuPG 2.1 --- plugins/enigma/enigma.js | 5 +++-- plugins/enigma/lib/enigma_driver.php | 7 ++++--- plugins/enigma/lib/enigma_driver_gnupg.php | 14 ++++++++++---- plugins/enigma/lib/enigma_driver_phpssl.php | 2 +- plugins/enigma/lib/enigma_engine.php | 6 +++--- plugins/enigma/lib/enigma_ui.php | 3 ++- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/plugins/enigma/enigma.js b/plugins/enigma/enigma.js index 081fea21b95..3dc3e9a8957 100644 --- a/plugins/enigma/enigma.js +++ b/plugins/enigma/enigma.js @@ -99,7 +99,7 @@ rcube_webmail.prototype.enigma_key_create_save = function() size = $('#key-size').val(); $('[name="identity[]"]:checked').each(function() { - users.push(this.value); + users.push(this.value); }); // validate the form @@ -124,7 +124,8 @@ rcube_webmail.prototype.enigma_key_create_save = function() openpgp.generateKeyPair(options).then(function(keypair) { // success - var post = {_a: 'import', _keys: keypair.privateKeyArmored, _generated: 1}; + var post = {_a: 'import', _keys: keypair.privateKeyArmored, _generated: 1, + _passwd: password, _keyid: keypair.key.primaryKey.fingerprint}; // send request to server rcmail.http_post('plugin.enigmakeys', post, lock); diff --git a/plugins/enigma/lib/enigma_driver.php b/plugins/enigma/lib/enigma_driver.php index 1ed5fbc3d9c..eaa4364b476 100644 --- a/plugins/enigma/lib/enigma_driver.php +++ b/plugins/enigma/lib/enigma_driver.php @@ -77,12 +77,13 @@ abstract function verify($text, $signature); /** * Key/Cert file import. * - * @param string File name or file content - * @param bollean True if first argument is a filename + * @param string File name or file content + * @param bolean True if first argument is a filename + * @param array Optional key => password map * * @return mixed Import status array or enigma_error */ - abstract function import($content, $isfile = false); + abstract function import($content, $isfile = false, $passwords = array()); /** * Key/Cert export. diff --git a/plugins/enigma/lib/enigma_driver_gnupg.php b/plugins/enigma/lib/enigma_driver_gnupg.php index 267af4fd1de..b6f87946eab 100644 --- a/plugins/enigma/lib/enigma_driver_gnupg.php +++ b/plugins/enigma/lib/enigma_driver_gnupg.php @@ -201,14 +201,20 @@ function verify($text, $signature) /** * Key file import. * - * @param string File name or file content - * @param bollean True if first argument is a filename + * @param string File name or file content + * @param bolean True if first argument is a filename + * @param array Optional key => password map * * @return mixed Import status array or enigma_error */ - public function import($content, $isfile=false) + public function import($content, $isfile = false, $passwords = array()) { try { + // GnuPG 2.1 requires secret key passphrases on import + foreach ($passwords as $keyid => $pass) { + $this->gpg->addPassphrase($keyid, $pass); + } + if ($isfile) return $this->gpg->importKeyFile($content); else @@ -251,7 +257,7 @@ public function export($keyid, $with_private = false) * * @return mixed Array of enigma_key objects or enigma_error */ - public function list_keys($pattern='') + public function list_keys($pattern = '') { try { $keys = $this->gpg->getKeys($pattern); diff --git a/plugins/enigma/lib/enigma_driver_phpssl.php b/plugins/enigma/lib/enigma_driver_phpssl.php index 967811da0f8..8cffc62f08d 100644 --- a/plugins/enigma/lib/enigma_driver_phpssl.php +++ b/plugins/enigma/lib/enigma_driver_phpssl.php @@ -122,7 +122,7 @@ function verify($struct, $message) return $sig; } - public function import($content, $isfile=false) + public function import($content, $isfile = false, $passwords = array()) { } diff --git a/plugins/enigma/lib/enigma_engine.php b/plugins/enigma/lib/enigma_engine.php index f3236778957..f75be365786 100644 --- a/plugins/enigma/lib/enigma_engine.php +++ b/plugins/enigma/lib/enigma_engine.php @@ -1113,10 +1113,10 @@ function generate_key($data) * * @return mixed Import status data array or enigma_error */ - function import_key($content, $isfile=false) + function import_key($content, $isfile = false) { $this->load_pgp_driver(); - $result = $this->pgp_driver->import($content, $isfile); + $result = $this->pgp_driver->import($content, $isfile, $this->get_passwords()); if ($result instanceof enigma_error) { rcube::raise_error(array( @@ -1174,7 +1174,7 @@ function password_handler() $passwd = rcube_utils::get_input_value('_passwd', rcube_utils::INPUT_POST, true); if ($keyid && $passwd !== null && strlen($passwd)) { - $this->save_password($keyid, $passwd); + $this->save_password(strtoupper($keyid), $passwd); } } diff --git a/plugins/enigma/lib/enigma_ui.php b/plugins/enigma/lib/enigma_ui.php index b7fc011611d..650ea2166f7 100644 --- a/plugins/enigma/lib/enigma_ui.php +++ b/plugins/enigma/lib/enigma_ui.php @@ -498,8 +498,9 @@ private function key_import() { // Import process if ($data = rcube_utils::get_input_value('_keys', rcube_utils::INPUT_POST)) { - // Import from generation form (ajax request) $this->enigma->load_engine(); + $this->enigma->engine->password_handler(); + $result = $this->enigma->engine->import_key($data); if (is_array($result)) { From 571a10751f500553d4b65fda1b8e8fd9bd32283f Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Oct 2016 11:29:50 +0200 Subject: [PATCH 03/24] Display error when trying to upload more files than specified in max_file_uploads (#5483) --- CHANGELOG | 1 + program/include/rcmail.php | 14 +++++++++++--- program/js/app.js | 4 ++++ program/localization/en_US/messages.inc | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index fc683ef037c..5dabc9e09c9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Display error when trying to upload more files than specified in max_file_uploads (#5483) - Add missing sql upgrade file for 'ip' column resize in session table (#5465) - Do not show inline images of unsupported mimetype (#5463) - Password: Added LDAP PPolicy driver (#5364) diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 4402da0f6c2..a6d07695f51 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -2061,6 +2061,8 @@ public function upload_progress() * Initializes file uploading interface. * * @param int $max_size Optional maximum file size in bytes + * + * @return string Human-readable file size limit */ public function upload_init($max_size = null) { @@ -2088,12 +2090,18 @@ public function upload_init($max_size = null) $max_filesize = $max_size; } + $max_filesize_txt = $this->show_bytes($max_filesize); $this->output->set_env('max_filesize', $max_filesize); - $max_filesize = $this->show_bytes($max_filesize); $this->output->set_env('filesizeerror', $this->gettext(array( - 'name' => 'filesizeerror', 'vars' => array('size' => $max_filesize)))); + 'name' => 'filesizeerror', 'vars' => array('size' => $max_filesize_txt)))); + + if ($max_filecount = ini_get('max_file_uploads')) { + $this->output->set_env('max_filecount', $max_filecount); + $this->output->set_env('filecounterror', $this->gettext(array( + 'name' => 'filecounterror', 'vars' => array('count' => $max_filecount)))); + } - return $max_filesize; + return $max_filesize_txt; } /** diff --git a/program/js/app.js b/program/js/app.js index 6e000d83ed3..8449735694f 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -4876,6 +4876,10 @@ function rcube_webmail() this.display_message(this.env.filesizeerror, 'error'); return false; } + if (this.env.max_filecount && this.env.filecounterror && numfiles > this.env.max_filecount) { + this.display_message(this.env.filecounterror, 'error'); + return false; + } var frame_name = this.async_upload_form(form, action || 'upload', function(e) { var d, content = ''; diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index ccf931776d2..945bb22c205 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -119,6 +119,7 @@ $messages['messageopenerror'] = 'Could not load message from server.'; $messages['filelinkerror'] = 'Attaching the file failed.'; $messages['fileuploaderror'] = 'File upload failed.'; $messages['filesizeerror'] = 'The uploaded file exceeds the maximum size of $size.'; +$messages['filecounterror'] = 'You can upload maximum $count files at once.'; $messages['msgsizeerror'] = 'Failed to attach a file. Maximum size of a message ($size) exceeded.'; $messages['copysuccess'] = 'Successfully copied $nr contacts.'; $messages['movesuccess'] = 'Successfully moved $nr contacts.'; From edea8732a6534c31c54aa48f7982434f7049e599 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 20 Oct 2016 15:48:42 +0200 Subject: [PATCH 04/24] Fix regression where UI object could be not created on some pages (#5484) --- program/include/rcmail_output_html.php | 4 ++++ skins/larry/includes/footer.html | 3 +++ skins/larry/includes/header.html | 8 -------- skins/larry/includes/links.html | 4 +++- skins/larry/ui.js | 8 +++++--- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index 7bca9561e4a..1c281a69001 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -1096,6 +1096,10 @@ protected function xml_command($matches) } break; + case 'add_label': + $this->add_label($attrib['name']); + break; + // include a file case 'include': $old_base_path = $this->base_path; diff --git a/skins/larry/includes/footer.html b/skins/larry/includes/footer.html index cade440bd6b..f64420d27c5 100644 --- a/skins/larry/includes/footer.html +++ b/skins/larry/includes/footer.html @@ -1,2 +1,5 @@ + diff --git a/skins/larry/includes/header.html b/skins/larry/includes/header.html index 5efe5b60043..1289d5681b5 100644 --- a/skins/larry/includes/header.html +++ b/skins/larry/includes/header.html @@ -1,13 +1,5 @@