From f1c51df0689604401a33569f6cd73ab3bbb0f520 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 18 Nov 2014 11:03:09 +0000 Subject: [PATCH] backport of r49425+r49431: do not return an smtp account with a password encrypted with user-credentials for async service, as it can not work --- .../inc/class.emailadmin_account.inc.php | 21 ++++++++++++++++++- .../inc/class.emailadmin_credentials.inc.php | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/emailadmin/inc/class.emailadmin_account.inc.php b/emailadmin/inc/class.emailadmin_account.inc.php index 9c9b90adb0..132004dcdd 100644 --- a/emailadmin/inc/class.emailadmin_account.inc.php +++ b/emailadmin/inc/class.emailadmin_account.inc.php @@ -34,6 +34,7 @@ * @property-read int $acc_imap_port imap port, default 143 or for ssl 993 * @property-read string $acc_imap_username * @property-read string $acc_imap_password + * @property-read string $acc_imap_pw_enc emailadmin_credentials::(CLEARTEXT|USER|SYSTEM) * @property-read boolean $acc_sieve_enabled sieve enabled * @property-read string $acc_sieve_host sieve host, default imap_host * @property-read int $acc_sieve_ssl 0=none, 1=starttls, 2=tls, 3=ssl, &8=validate certificate @@ -48,6 +49,7 @@ * @property-read int $acc_smtp_port smtp port * @property-read string $acc_smtp_username if smtp auth required * @property-read string $acc_smtp_password + * @property-read string $acc_smtp_pw_enc emailadmin_credentials::(CLEARTEXT|USER|SYSTEM) * @property-read string $acc_smtp_type smtp class to use, default emailadmin_smtp * @property-read string $acc_imap_type imap class to use, default emailadmin_imap * @property-read string $acc_imap_logintype how to construct login-name standard, vmailmgr, admin, uidNumber @@ -1315,6 +1317,7 @@ class emailadmin_account implements ArrayAccess */ static function get_default_acc_id($smtp=false) { + //error_log(__METHOD__.__LINE__.'Smtp?'.array2string($smtp)); try { foreach(emailadmin_account::search(true, 'params') as $acc_id => $params) @@ -1323,7 +1326,23 @@ class emailadmin_account implements ArrayAccess { if (!$params['acc_smtp_host'] || !$params['acc_smtp_port']) continue; // check requirement of session, which is not available in async service! - if (isset($GLOBALS['egw_info']['flags']['async-service']) && $params['acc_smtp_auth_session']) continue; + //error_log(__METHOD__.__LINE__.array2string($params)); + //error_log(__METHOD__.__LINE__.'is async:'.array2string($GLOBALS['egw_info']['flags']['async-service'])); + if (isset($GLOBALS['egw_info']['flags']['async-service'])) + { + if ($params['acc_smtp_auth_session']) continue; + // may fail because of smtp only profile, or no session password, etc + try + { + $account = new emailadmin_account($params); + } + catch (Exception $x) + { + continue; + } + if ($account->acc_smtp_pw_enc == emailadmin_credentials::USER) continue; + //error_log(__METHOD__.__LINE__.array2string($account->params)); + } } else { diff --git a/emailadmin/inc/class.emailadmin_credentials.inc.php b/emailadmin/inc/class.emailadmin_credentials.inc.php index 7a14f72591..965179d263 100644 --- a/emailadmin/inc/class.emailadmin_credentials.inc.php +++ b/emailadmin/inc/class.emailadmin_credentials.inc.php @@ -150,6 +150,7 @@ class emailadmin_credentials $results[$prefix.'password'] = $password; $results[$prefix.'cred_id'] = $row['cred_id']; $results[$prefix.'account_id'] = $row['account_id']; + $results[$prefix.'pw_enc'] = $row['cred_pw_enc']; } } }