Skip to content

Commit

Permalink
Merge branch 'master' into imp_6_2
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Nov 20, 2013
2 parents 7145819 + 57aca33 commit 9a729ed
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 26 deletions.
13 changes: 13 additions & 0 deletions framework/ActiveSync/lib/Horde/ActiveSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,19 @@ public function handleRequest($cmd, $devId)
}
}

// Lastly, check if the device has been set to blocked.
if ($this->_device->blocked) {
$msg = sprintf(
'The device %s was blocked.',
$this->_device->id);
self::$_logger->err($msg);
if ($version > self::VERSION_TWELVEONE) {
$this->_globalError = Horde_ActiveSync_Status::DEVICE_BLOCKED_FOR_USER;
} else {
throw new Horde_ActiveSync_Exception($msg);
}
}

// Don't bother with everything else if all we want are Options
if ($cmd == 'Options') {
$this->_doOptionsRequest();
Expand Down
5 changes: 5 additions & 0 deletions framework/ActiveSync/lib/Horde/ActiveSync/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* folders for, therefore all sources must
* be multiplexed together. Masks are
* the MULTIPLEX_* constants.
* @property boolean blocked True if device has been marked as blocked.
*
*/
class Horde_ActiveSync_Device
Expand All @@ -53,6 +54,8 @@ class Horde_ActiveSync_Device
const VERSION = 'version';
const MULTIPLEX = 'multiplex';
const ANNOUNCED_VERSION = 'announcedVersion';
const BLOCKED = 'blocked';


// Bitwise constants for flagging device must use multiplexed collections.
// @since 2.9.0
Expand Down Expand Up @@ -102,6 +105,7 @@ public function &__get($property)
switch ($property) {
case self::MULTIPLEX:
case self::ANNOUNCED_VERSION:
case self::BLOCKED:
return $this->_properties['properties'][$property];
default:
if (isset($this->_properties[$property])) {
Expand All @@ -121,6 +125,7 @@ public function __set($property, $value)
switch ($property) {
case self::MULTIPLEX:
case self::ANNOUNCED_VERSION:
case self::BLOCKED:
$properties = $this->properties;
if (empty($properties)) {
$properties = array();
Expand Down
23 changes: 14 additions & 9 deletions framework/ActiveSync/lib/Horde/ActiveSync/Folder/Imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,21 @@ public function serialize()
* @throws Horde_ActiveSync_Exception_StaleState
*/
public function unserialize($data)
{ $data = json_decode($data, true);
if (!is_array($data) || empty($data['v']) || $data['v'] != self::VERSION) {
throw new Horde_ActiveSync_Exception_StaleState('Cache version change');
{ $d_data = json_decode($data, true);
if (!is_array($d_data) || empty($d_data['v']) || $d_data['v'] != self::VERSION) {
// Try using the old serialization strategy, since this would save
// an expensive resync of email collections.
$d_data = @unserialize($data);
if (!is_array($d_data) || empty($d_data['v']) || $d_data['v'] != 1) {
throw new Horde_ActiveSync_Exception_StaleState('Cache version change');
}
}
$this->_status = $data['s'];
$this->_messages = $data['m'];
$this->_serverid = $data['f'];
$this->_class = $data['c'];
$this->_lastSinceDate = $data['lsd'];
$this->_softDelete = $data['sd'];
$this->_status = $d_data['s'];
$this->_messages = $d_data['m'];
$this->_serverid = $d_data['f'];
$this->_class = $d_data['c'];
$this->_lastSinceDate = $d_data['lsd'];
$this->_softDelete = $d_data['sd'];
}

/**
Expand Down
8 changes: 8 additions & 0 deletions framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ protected function _handle()
// iOS need this in order to catch missing state.
$this->_logger->err($e->getMessage());
$statusCode = self::STATUS_FOLDERSYNC_REQUIRED;
} catch (Horde_ActiveSync_Exception_StaleState $e) {
$this->_logger->notice($e->getMessage());
return false;
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
return false;
Expand Down Expand Up @@ -857,6 +860,11 @@ protected function _parseSyncCommands(&$collection)
$this->_statusCode = self::STATUS_KEYMISM;
$this->_handleError($collection);
return false;
} catch (Horde_ActiveSync_Exception_StaleState $e) {
$this->_logger->notice($e->getMessage());
$this->_statusCode = self::STATUS_SERVERERROR;
$this->_handleGlobalSyncError();
return false;
} catch (Horde_ActiveSync_Exception $e) {
$this->_logger->err($e->getMessage());
$this->_statusCode = self::STATUS_SERVERERROR;
Expand Down
13 changes: 12 additions & 1 deletion framework/ActiveSync/lib/Horde/ActiveSync/State/Mongo.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,27 @@ public function deviceExists($devId, $user = null)
*
* @param string $user The username to list devices for. If empty, will
* return all devices.
* @param array $filter An array of optional filters where the keys are
* field names and the values are values to match
* exactly.
*
* @return array An array of device hashes
* @throws Horde_ActiveSync_Exception
*/
public function listDevices($user = null)
public function listDevices($user = null, $filter = array())
{
$query = array();
if (!empty($user)) {
$query['users.device_user'] = $user;
}
$explicit_fields = array('device_id', 'device_type', 'device_agent', 'device_user');
foreach ($filter as $key => $value) {
if (in_array($key, $explicit_fields)) {
$query[$key] = $value;
} else {
$query['device_properties.' . $key] = new MongoRegex("/^$value*/");
}
}
try {
$cursor = $this->_db->HAS_device->find($query);
} catch (Exception $e) {
Expand Down
13 changes: 12 additions & 1 deletion framework/ActiveSync/lib/Horde/ActiveSync/State/Sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -691,20 +691,31 @@ public function deviceExists($devId, $user = null)
*
* @param string $user The username to list devices for. If empty, will
* return all devices.
* @param array $filter An array of optional filters where the keys are
* field names and the values are values to match.
*
* @return array An array of device hashes
* @throws Horde_ActiveSync_Exception
*/
public function listDevices($user = null)
public function listDevices($user = null, $filter = array())
{
$query = 'SELECT d.device_id AS device_id, device_type, device_agent,'
. ' device_policykey, device_rwstatus, device_user, device_properties FROM '
. $this->_syncDeviceTable . ' d INNER JOIN ' . $this->_syncUsersTable
. ' u ON d.device_id = u.device_id';
$values = array();
$glue = false;
if (!empty($user)) {
$query .= ' WHERE u.device_user = ?';
$values[] = $user;
$glue = true;
}
$explicit_fields = array('device_id', 'device_type', 'device_agent', 'device_user');
foreach ($filter as $key => $value) {
if (in_array($key, $explicit_fields)) {
$query .= ($glue ? ' AND ' : ' WHERE ') . 'd.' . $key . ' LIKE ?';
$values[] = $value . '%';
}
}

try {
Expand Down
12 changes: 8 additions & 4 deletions framework/ActiveSync/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<email>mrubinsk@horde.org</email>
<active>yes</active>
</lead>
<date>2013-11-18</date>
<date>2013-11-19</date>
<version>
<release>2.9.1</release>
<api>2.9.0</api>
Expand All @@ -21,7 +21,9 @@
</stability>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
*
* [mjr] Add ability to flag a specific device as blocked.
* [mjr] Add ability to filter the list of devices on more than username.
* [mjr] Attempt to recover old serialized data before forcing a repairing of Email collections.
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -1814,10 +1816,12 @@
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2013-11-18</date>
<date>2013-11-19</date>
<license uri="http://www.horde.org/licenses/gpl">GPL-2.0</license>
<notes>
*
* [mjr] Add ability to flag a specific device as blocked.
* [mjr] Add ability to filter the list of devices on more than username.
* [mjr] Attempt to recover old serialized data before forcing a repairing of Email collections.
</notes>
</release>
</changelog>
Expand Down
2 changes: 1 addition & 1 deletion framework/Auth/lib/Horde/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static public function getSalt($encryption = 'md5-hex', $seed = '',
case 'sha256':
case 'ssha256':
return $seed
? substr(base64_decode(preg_replace('|^{SSHA256}|i', '', $seed)), 20)
? substr(base64_decode(preg_replace('|^{SSHA256}|i', '', $seed)), 32)
: substr(pack('H*', hash('sha256', substr(pack('h*', hash('md5', mt_rand())), 0, 8) . $plaintext)), 0, 4);

case 'smd5':
Expand Down
4 changes: 2 additions & 2 deletions framework/Auth/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix parsing salted SHA256 entries (Adam James &lt;adam.james@transitiv.co.uk&gt;).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -904,7 +904,7 @@
<date>2013-10-15</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Fix parsing salted SHA256 entries (Adam James &lt;adam.james@transitiv.co.uk&gt;).
</notes>
</release>
</changelog>
Expand Down
Binary file modified framework/Auth/test/Horde/Auth/TestCase.php
Binary file not shown.
4 changes: 2 additions & 2 deletions framework/Auth/test/Horde/Auth/Unit/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function testGetSalt($encryption, $password, $salt)
/**
* @dataProvider getCredentials
*/
public function testGetCryptedPassword($encryption, $password, $salt)
public function testGetCryptedPassword($encryption, $password, $salt, $show_encryption = false)
{
$this->assertEquals($password, Horde_Auth::getCryptedPassword('foobar', $password, $encryption, false));
$this->assertEquals($password, Horde_Auth::getCryptedPassword('foobar', $password, $encryption, $show_encryption));
}
}
2 changes: 1 addition & 1 deletion framework/Auth/test/Horde/Auth/Unit/Sql/Pdo/SqliteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function setUpBeforeClass()
self::$db = $factory_db->create();
parent::setUpBeforeClass();
} catch (Horde_Test_Exception $e) {
self::$_reason = 'Sqlite not available.';
self::$reason = 'Sqlite not available.';
}
}

Expand Down
2 changes: 1 addition & 1 deletion framework/Smtp/lib/Horde/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ protected function _getResponse($code, $error = null)

$e = new Horde_Smtp_Exception($details);
$e->details = $details;
$e->setSmtpCode($code);
$e->setSmtpCode($replycode);
$e->setEnhancedSmtpCode($enhanced);

switch ($error) {
Expand Down
12 changes: 9 additions & 3 deletions kronolith/templates/edit/edit.inc
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ $hide_img = Horde::img('minus.png', _("Hide"), 'style="display:none"');
// We are editing/viewing resource calendars
foreach ($GLOBALS['display_resource_calendars'] as $cal) {
$rd = Kronolith::getDriver('Resource');
$rc = $rd->getResource($rd->getResourceIdByCalendar($cal));
printf('<option value="%s">%s (%s)</option>',
'resource_' . htmlspecialchars($cal), $rc->get('name'), _("resource")) . "\n";
try {
$rc = $rd->getResource($rd->getResourceIdByCalendar($cal));
printf('<option value="%s">%s (%s)</option>',
'resource_' . htmlspecialchars($cal),
htmlspecialchars($rc->get('name')),
_("resource"))
. "\n";
} catch (Horde_Exception_NotFound $e) {
}
}
}
?>
Expand Down
4 changes: 3 additions & 1 deletion passwd/lib/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ protected function _comparePasswords($encrypted, $plaintext)
{
if (preg_match('/^{([^}]+)}(.*)/', $encrypted, $match)) {
$encryption = Horde_String::lower($match[1]);
$encrypted = $match[2];
if (!$this->_params['show_encryption']) {
$encrypted = $match[2];
}
} else {
$encryption = $this->_params['encryption'];
}
Expand Down

0 comments on commit 9a729ed

Please sign in to comment.