Undefined GetImpersonatedUser() if BackendCombined for Kopano + Dovecot
-
Dear Developers,
Thank you for your efforts for Z-Push and Kopano very much.
Today, I have to report the error, BackendKopano causes error under BackendCombined.[Symptom]
In /etc/z-push/z-push.conf.php,
(1)Works fine if BACKEND_PROVIDER is BackendKopano
(2)Works fine if BACKEND_PROVIDER is BackendImap
(3)Cause the error if BACKEND_PROVIDER is BackendCombined for BackendKopano + BackendImap[Environment]
After ‘yum -y update’ in the following environment
CentOS 7
Apache 2.4.6-89.el7.centos.1
PHP 7.3.8-1.el7.remi
Kopano core-8.7.82.61
Z-Push 2.5.0+0-117.1
Dovecot 1:2.2.36-3.el7[Details]
(1)
define(‘BACKEND_PROVIDER’, ‘BackendKopano’); in /etc/z-push/z-push.conf.php
Kopano’s Notes can be syncronised fine.(2)
define(‘BACKEND_PROVIDER’, ‘BackendImap’); in /etc/z-push/z-push.conf.php
Dovecot mails can be syncronised fine.(3)
/etc/z-push/z-push.conf.php
define(‘BACKEND_PROVIDER’, ‘BackendCombined’);
If above setting, Z-Push causes the error
‘/usr/share/z-push/backend/kopano/exporter.php:73 - Uncaught Error: Call to undefined method BackendCombined::GetImpersonatedUser() in /usr/share/z-push/backe
nd/kopano/exporter.php:73’.Z-Push log
Aug 1 17:41:12 localhost z-push/core[20056]: [INFO] [hoho] Options request Aug 1 17:41:12 localhost z-push/core[20056]: [INFO] [hoho] cmd='' memory='1.66 MiB/2.00 MiB' time='0.02s' devType='' devId='' getUser='hoho' from='192.168.150.21' idle='0s' version='2.5.0+0' method='OPTIONS' httpcode='200' Aug 1 17:41:13 localhost z-push/core[20030]: [INFO] [hoho] ProvisioningRequiredException: Retry after sending a PROVISION command - code: 0 - file: /usr/share/z-push/index.php:82 Aug 1 17:41:13 localhost z-push/core[20030]: [INFO] [hoho] User-agent: 'Android-Mail/2019.06.09.254811277.release' Aug 1 17:41:13 localhost z-push/core[20030]: [FATAL] [hoho] Exception: (ProvisioningRequiredException) - Retry after sending a PROVISION command Aug 1 17:41:13 localhost z-push/core[20030]: [INFO] [hoho] cmd='FolderSync' memory='1.67 MiB/2.00 MiB' time='0.00s' devType='Android' devId='androidc1290472354' getUser='hoho' from='192.168.150.21' idle='0s' version='2.5.0+0' method='POST' httpcode='449' Aug 1 17:41:13 localhost z-push/core[20025]: [INFO] [hoho] cmd='Provision' memory='1.91 MiB/4.00 MiB' time='0.01s' devType='Android' devId='androidc1290472354' getUser='hoho' from='192.168.150.21' idle='0s' version='2.5.0+0' method='POST' httpcode='200' Aug 1 17:41:13 localhost z-push/core[20025]: [INFO] [hoho] cmd='Provision' memory='1.82 MiB/2.00 MiB' time='0.01s' devType='Android' devId='androidc1290472354' getUser='hoho' from='192.168.150.21' idle='0s' version='2.5.0+0' method='POST' httpcode='200' Aug 1 17:41:13 localhost z-push/core[20025]: [INFO] [hoho] cmd='Settings' memory='2.09 MiB/4.00 MiB' time='0.01s' devType='Android' devId='androidc1290472354' getUser='hoho' from='192.168.150.21' idle='0s' version='2.5.0+0' method='POST' httpcode='200' Aug 1 17:41:13 localhost z-push/core[20030]: [FATAL] [hoho] Fatal error: /usr/share/z-push/backend/kopano/exporter.php:73 - Uncaught Error: Call to undefined method BackendCombined::GetImpersonatedUser() in /usr/share/z-push/backend/kopano/exporter.php:73 Aug 1 17:41:13 localhost z-push/core[20030]: Stack trace: Aug 1 17:41:13 localhost z-push/core[20030]: #0 /usr/share/z-push/backend/kopano/kopano.php(454): ExportChangesICS->__construct(Resource id #13, Resource id #15) Aug 1 17:41:13 localhost z-push/core[20030]: #1 /usr/share/z-push/backend/combined/exporter.php(71): BackendKopano->GetExporter() Aug 1 17:41:13 localhost z-push/core[20030]: #2 /usr/share/z-push/lib/request/foldersync.php(173): ExportChangesCombined->Config('') Aug 1 17:41:13 localhost z-push/core[20030]: #3 /usr/share/z-push/lib/request/requestprocessor.php(116): FolderSync->Handle(9) Aug 1 17:41:13 localhost z-push/core[20030]: #4 /usr/share/z-push/index.php(107): RequestProcessor::HandleRequest() Aug 1 17:41:13 localhost z-push/core[20030]: #5 {main} Aug 1 17:41:13 localhost z-push/core[20030]: thrown (1) Aug 1 17:41:13 localhost z-push/core[20056]: [FATAL] [hoho] Fatal error: /usr/share/z-push/backend/kopano/exporter.php:73 - Uncaught Error: Call to undefined method BackendCombined::GetImpersonatedUser() in /usr/share/z-push/backend/kopano/exporter.php:73 Aug 1 17:41:13 localhost z-push/core[20056]: Stack trace: Aug 1 17:41:13 localhost z-push/core[20056]: #0 /usr/share/z-push/backend/kopano/kopano.php(454): ExportChangesICS->__construct(Resource id #13, Resource id #15) Aug 1 17:41:13 localhost z-push/core[20056]: #1 /usr/share/z-push/backend/combined/exporter.php(71): BackendKopano->GetExporter() Aug 1 17:41:13 localhost z-push/core[20056]: #2 /usr/share/z-push/lib/request/foldersync.php(173): ExportChangesCombined->Config('') Aug 1 17:41:13 localhost z-push/core[20056]: #3 /usr/share/z-push/lib/request/requestprocessor.php(116): FolderSync->Handle(9) Aug 1 17:41:13 localhost z-push/core[20056]: #4 /usr/share/z-push/index.php(107): RequestProcessor::HandleRequest() Aug 1 17:41:13 localhost z-push/core[20056]: #5 {main} Aug 1 17:41:13 localhost z-push/core[20056]: thrown (1)
/etc/z-push/combined.conf.php
<?php /*********************************************** * File : backend/combined/config.php * Project : Z-Push * Descr : configuration file for the * combined backend. * * Created : 29.11.2010 * * Copyright 2007 - 2016 Zarafa Deutschland GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Consult LICENSE file for details ************************************************/ class BackendCombinedConfig { // ************************* // BackendCombined settings // ************************* /** * Returns the configuration of the combined backend * * @access public * @return array * */ public static function GetBackendCombinedConfig() { //use a function for it because php does not allow //assigning variables to the class members (expecting T_STRING) return array( //the order in which the backends are loaded. //login only succeeds if all backend return true on login //sending mail: the mail is sent with first backend that is able to send the mail 'backends' => array( 'i' => array( 'name' => 'BackendIMAP', ), 'z' => array( 'name' => 'BackendKopano', ), 'm' => array( 'name' => 'BackendMaildir', ), 'v' => array( 'name' => 'BackendVCardDir', ), 'l' => array( 'name' => 'BackendLDAP', ), 'd' => array( 'name' => 'BackendCardDAV', ), 'c' => array( 'name' => 'BackendCalDAV', ), ), 'delimiter' => '/', //force one type of folder to one backend //it must match one of the above defined backends 'folderbackend' => array( SYNC_FOLDER_TYPE_INBOX => 'i', SYNC_FOLDER_TYPE_DRAFTS => 'i', SYNC_FOLDER_TYPE_WASTEBASKET => 'i', SYNC_FOLDER_TYPE_SENTMAIL => 'i', SYNC_FOLDER_TYPE_OUTBOX => 'i', SYNC_FOLDER_TYPE_TASK => 'z', SYNC_FOLDER_TYPE_APPOINTMENT => 'z', SYNC_FOLDER_TYPE_CONTACT => 'z', SYNC_FOLDER_TYPE_NOTE => 'z', SYNC_FOLDER_TYPE_JOURNAL => 'z', SYNC_FOLDER_TYPE_OTHER => 'z', SYNC_FOLDER_TYPE_USER_MAIL => 'i', SYNC_FOLDER_TYPE_USER_APPOINTMENT => 'z', SYNC_FOLDER_TYPE_USER_CONTACT => 'z', SYNC_FOLDER_TYPE_USER_TASK => 'z', SYNC_FOLDER_TYPE_USER_JOURNAL => 'z', SYNC_FOLDER_TYPE_USER_NOTE => 'z', SYNC_FOLDER_TYPE_UNKNOWN => 'z', ), //creating a new folder in the root folder should create a folder in one backend 'rootcreatefolderbackend' => 'z', ); } }
/etc/z-push/kopano.conf.php
<?php /*********************************************** * File : config.php * Project : Z-Push * Descr : Kopano backend configuration file * * Created : 27.11.2012 * * Copyright 2007 - 2016 Zarafa Deutschland GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Consult LICENSE file for details ************************************************/ // ************************ // BackendKopano settings // ************************ // Defines the server to which we want to connect. // // Depending on your setup, it might be advisable to change the lines below to one defined with your // default socket location. // Normally "default:" points to the default setting ("file:///var/run/kopano/server.sock") // Examples: define("MAPI_SERVER", "default:"); // define("MAPI_SERVER", "http://localhost:236/kopano"); // define("MAPI_SERVER", "https://localhost:237/kopano"); // define("MAPI_SERVER", "file:///var/run/kopano/server.sock"); // If you are using ZCP >= 7.2.0, set it to the zarafa location, e.g. // define("MAPI_SERVER", "http://localhost:236/zarafa"); // define("MAPI_SERVER", "https://localhost:237/zarafa"); // define("MAPI_SERVER", "file:///var/run/zarafad/server.sock"); // For ZCP versions prior to 7.2.0 the socket location is different (http(s) sockets are the same): // define("MAPI_SERVER", "file:///var/run/zarafa"); define('MAPI_SERVER', 'default:'); // Read-Only shared folders // When trying to write a change on a read-only folder this data is dropped and replaced on the device of the user. // Enabling the option below, sends an email to the user notifying that this happened (default enabled). // If this is disabled, the data will be dropped silently and will be lost. // The template of the email sent can be customized here. The placeholders can also be used in the subject. define('READ_ONLY_NOTIFY_LOST_DATA', true); // String to mark the data changed by the user (that he is trying to save) define('READ_ONLY_NOTIFY_YOURDATA', 'Your data'); // Email template to be sent to the user define('READ_ONLY_NOTIFY_SUBJECT', "Z-Push: Writing operation not permitted - data reset"); define('READ_ONLY_NOTIFY_BODY', <<<END Dear **USERFULLNAME**, on **DATE** at **TIME** you've tried to save a data in the folder '**FOLDERNAME**' on your device '**MOBILETYPE**' ID: '**MOBILEDEVICEID**'. This operation was not successful, as you lack write access to this folder. Your data has been dropped and replaced with the original data on your device to ensure data integrity. Below is a copy of the data you tried to save. If you want your changes to be stored permanently you should forward this email to a person with write access to this folder asking to perform these changes again. **DIFFERENCES** If you have questions about this email, please contact your e-mail administrator. Sincerely, Your Z-Push system END ); // Format of the **DATE** and **TIME** placeholders - more information on formats, see http://php.net/manual/en/function.strftime.php define('READ_ONLY_NOTIFY_DATE_FORMAT', "%d.%m.%Y"); define('READ_ONLY_NOTIFY_TIME_FORMAT', "%H:%M:%S"); // Comma separated list of folder ids as string for which the notification emails of the changes in read-only folders shouldn't be sent. // E.g. define('READ_ONLY_NONOTIFY', '1, 2, 3, 4'); // When configuring $additionalFolders it is possible to use DeviceManager::FLD_FLAGS_NOREADONLYNOTIFY in the flags bitmask // in order to prevent the notifications as well. define('READ_ONLY_NONOTIFY', '');
-
Hi ukus,
impersonated user is a feature which is currently implemented for the Kopano backend only therefore using combined backend with kopano backend for some of the objects won’t work. I’ve created a JIRA issue to solve this: https://jira.z-hub.io/browse/ZP-1516. You can follow the progress there.
Why is using Kopano for email as well not an option for you?
Manfred
-
As alternative you could just add these lines to the combined backend:
public function GetImpersonatedUser() { return false; }
But certainly the impersonated feature will not work with this.
-
Dear Sebastian,
Thank you for your advice.
In /usr/share/z-push/backend/kopano/exporter.php, I replacedif (ZPush::GetBackend()->GetImpersonatedUser() == 'system') {
with
if (Request::GetImpersonatedUser() == 'system') {
In /usr/share/z-push/backend/kopano/mapiprovider.php, I replaced
if (ZPush::GetBackend()->GetImpersonatedUser()) {
with
if (Request::GetImpersonatedUser()) {
The ‘Undefined’ error has disappeared. However, Notes are not synchronised with BackendCombined + BackendKopano + BackendImap.
But it is different issue.Dear Manfred,
Thank you for providing very much. As we are using the legacy Dovecot email server, it is not easy to move from Dovecot to Kopano mails politically. On the other hand, we wants to add Tasks, Calendars, Notes in our office.
By the way, even though I amended this ‘Undefined’ error, Notes are not synchronised, how should I report? Should I report in this forum? Or should I report in https://jira.z-hub.io? I looked for the suggestion to report the issue, but was not able to find. I wonder if you give me the advice to report.
Kind regards,
UKUS
-
Removing
ZPush::GetBackend()
will indeed “solve” the issue, as no calls to the combined backend will be made anymore. Nevertheless, be careful! This could work, but the impersonated feature was never intended to be used with the combined backend. When logging in via impersonated a few more things happen (e.g. the default store in Kopano is overwritten).
While this seems obvious, there might be other issues you may run into (in the future).Reporting via the forum is fine.
Cheers,
Sebastian -
Hi Sebastian,
Thank you for giving me the technical information, that kind of information is helpful to understand the software architecture.
I have created the new topic for the ‘Not synchronised’ issue, I wonder if you help us to solve the issue.
https://forum.kopano.io/topic/2602/kopano-s-data-are-not-synchronised-when-using-backendcombined-for-kopano-dovecotKind regards,
UKUS