Commit db5a7026 authored by Manfred Kutas's avatar Manfred Kutas

Merge pull request #686 in ZP/z-push from release/2.4 to master

* commit 'd504674d':
  ZP-1392 Fix SyncUserInformation for default backend. Released under the Affero GNU General Public License (AGPL) version 3.
  ZP-1383 Fix carddav last character of note trimmed. Released under the Affero GNU General Public License (AGPL) version 3.
  ZP-1382 Caldav outofoffice tentative workingelsewhere status. Released under the Affero GNU General Public License (AGPL) version 3.
  ZP-1379 Undefined offset warnings when impersonating.
  ZP-1291 Exit with 0 if gab2contacts called with help.
  ZP-1291 Exit with 0 if gab-sync called with help.
  ZP-1291 Exit with 0 if z-push-top called with help.
  ZP-1291 Exit with 0 if z-push-admin called with help.
  ZP-1376 Return false in IsRequestMemoryLimitReached if memory_limit set to -1.
  ZP-1377 Fix undefined index warnings in imap backend.
  ZP-1374 Add imap backend location to the include_path when using imap backend.
  ZP-1373 Modify custom header so it matches the apache modphp version.
  ZP-1373 Disable custom remote IP header by default.
  ZP-1375 Change state and log dirs and log rotation ownership to root:z-push on RHEL based operating systems.
parents 0dfcf196 d504674d
......@@ -467,13 +467,8 @@ service nginx reload || true
%zpush_dir/
%doc src/LICENSE
%if 0%{?suse_version}
%attr(770,wwwrun,z-push) %dir %_localstatedir/lib/z-push
%attr(770,wwwrun,z-push) %dir %_localstatedir/log/z-push
%else
%attr(750,apache,z-push) %dir %_localstatedir/lib/z-push
%attr(750,apache,z-push) %dir %_localstatedir/log/z-push
%endif
%attr(770,root,z-push) %dir %_localstatedir/lib/z-push
%attr(770,root,z-push) %dir %_localstatedir/log/z-push
%_bindir/z-push-admin
%_bindir/z-push-top
......
/var/log/z-push/*.log {
size 1k
create apache apache
create root z-push
compress
rotate 4
}
......@@ -662,13 +662,35 @@ class BackendCalDAV extends BackendDiff {
break;
case "TRANSP":
if(!isset($message->busystatus)){
switch ($property->Value()) {
case "TRANSPARENT":
$message->busystatus = "0";
break;
case "OPAQUE":
$message->busystatus = "2";
break;
}
}
break;
case "X-MICROSOFT-CDO-INTENDEDSTATUS":
switch ($property->Value()) {
case "TRANSPARENT":
case "FREE":
$message->busystatus = "0";
break;
case "OPAQUE":
case "TENTATIVE":
$message->busystatus = "1";
break;
case "BUSY":
$message->busystatus = "2";
break;
case "OOF":
$message->busystatus = "3";
break;
case "WORKINGELSEWHERE":
$message->busystatus = "4";
break;
}
break;
......@@ -1022,13 +1044,25 @@ class BackendCalDAV extends BackendDiff {
}
if (isset($data->busystatus)) {
switch ($data->busystatus) {
case "0":
case "1":
case "0": //Free
$vevent->AddProperty("TRANSP", "TRANSPARENT");
$vevent->AddProperty("X-MICROSOFT-CDO-INTENDEDSTATUS", "FREE");
break;
case "2":
case "3":
case "1": //Tentative
$vevent->AddProperty("TRANSP", "OPAQUE");
$vevent->AddProperty("X-MICROSOFT-CDO-INTENDEDSTATUS", "TENTATIVE");
break;
case "2": //Busy
$vevent->AddProperty("TRANSP", "OPAQUE");
$vevent->AddProperty("X-MICROSOFT-CDO-INTENDEDSTATUS", "BUSY");
break;
case "3": //Out of office
$vevent->AddProperty("TRANSP", "TRANSPARENT");
$vevent->AddProperty("X-MICROSOFT-CDO-INTENDEDSTATUS", "OOF");
break;
case "4": //Working elsewhere (not yet in Android)
$vevent->AddProperty("TRANSP", "TRANSPARENT");
$vevent->AddProperty("X-MICROSOFT-CDO-INTENDEDSTATUS", "WORKINGELSEWHERE");
break;
}
}
......@@ -1110,7 +1144,6 @@ class BackendCalDAV extends BackendDiff {
// X-MICROSOFT-CDO-APPT-SEQUENCE:0
// X-MICROSOFT-CDO-OWNERAPPTID:2113393086
// X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
// X-MICROSOFT-CDO-IMPORTANCE:1
// X-MICROSOFT-CDO-INSTTYPE:0
......
......@@ -1285,7 +1285,7 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
$val = str_replace("\n", "\\n", $val);
// Remove trailing ;
$val = substr($val, 0, -1);
$val = rtrim($val, ";");
// Clean full name from emailaddress
if (substr($k, 0, 5) == 'email') {
$val = preg_replace(array('/.*</', '/>.*/'), array('', ''), $val);
......
......@@ -35,7 +35,7 @@ require_once("backend/imap/user_identity.php");
// Add the path for Andrew's Web Libraries to include_path
// because it is required for the emails with ics attachments
// @see https://jira.z-hub.io/browse/ZP-1149
set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/awl/inc');
set_include_path(get_include_path() . PATH_SEPARATOR . '/usr/share/awl/inc' . PATH_SEPARATOR . dirname(__FILE__) . '/');
class BackendIMAP extends BackendDiff implements ISearchProvider {
private $wasteID;
......@@ -205,8 +205,12 @@ class BackendIMAP extends BackendDiff implements ISearchProvider {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->SendMail(): To defined: %s", $toaddr));
}
$message->headers["to"] = Utils::CheckAndFixEncodingInHeadersOfSentMail($Mail_RFC822->parseAddressList($message->headers["to"]));
$message->headers["cc"] = Utils::CheckAndFixEncodingInHeadersOfSentMail($Mail_RFC822->parseAddressList($message->headers["cc"]));
if (isset($message->headers["to"])) {
$message->headers["to"] = Utils::CheckAndFixEncodingInHeadersOfSentMail($Mail_RFC822->parseAddressList($message->headers["to"]));
}
if (isset($message->headers["cc"])) {
$message->headers["cc"] = Utils::CheckAndFixEncodingInHeadersOfSentMail($Mail_RFC822->parseAddressList($message->headers["cc"]));
}
unset($Mail_RFC822);
......
......@@ -2805,6 +2805,9 @@ class MAPIProvider {
if(!isset($this->storeProps[PR_IPM_OUTBOX_ENTRYID])) {
$this->storeProps[PR_IPM_OUTBOX_ENTRYID] = false;
}
if(!isset($this->storeProps[PR_IPM_PUBLIC_FOLDERS_ENTRYID])) {
$this->storeProps[PR_IPM_PUBLIC_FOLDERS_ENTRYID] = false;
}
}
return $this->storeProps;
}
......
......@@ -40,7 +40,7 @@
// is available, the provided value will be used, else REMOTE_ADDR is maintained.
// set to false to disable this behaviour.
// common values: 'HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP' (casing is ignored)
define('USE_CUSTOM_REMOTE_IP_HEADER', 'HTTP_X_REAL_IP');
define('USE_CUSTOM_REMOTE_IP_HEADER', false);
// When using client certificates, we can check if the login sent matches the owner of the certificate.
// This setting specifies the owner parameter in the certificate to look at.
......
......@@ -185,10 +185,10 @@ abstract class Backend implements IBackend {
$emailaddresses->smtpaddress[] = ZPush::GetBackend()->GetUserDetails(Request::GetUser())['emailaddress'];
$emailaddresses->primarysmtpaddress = ZPush::GetBackend()->GetUserDetails(Request::GetUser())['emailaddress'];
$account->emailaddresses = $emailaddresses;
$userinformation->accounts[] = $account;
$settings->accounts[] = $account;
}
else {
$userinformation->emailaddresses = array(ZPush::GetBackend()->GetUserDetails(Request::GetUser())['emailaddress']);
$settings->emailaddresses = array(ZPush::GetBackend()->GetUserDetails(Request::GetUser())['emailaddress']);
}
$settings->emailaddresses = array(ZPush::GetBackend()->GetUserDetails(Request::GetUser())['emailaddress']);
......
......@@ -198,9 +198,17 @@ class Request {
}
// get & convert configured memory limit
(int)preg_replace_callback('/(\-?\d+)(.?)/', function ($m) {
self::$memoryLimit = $m[1] * pow(1024, strpos('BKMG', $m[2])) * self::MAXMEMORYUSAGE;
}, strtoupper(ini_get('memory_limit')));
$memoryLimit = ini_get('memory_limit');
if ($memoryLimit == -1) {
self::$memoryLimit = false;
}
else {
(int)preg_replace_callback('/(\-?\d+)(.?)/',
function ($m) {
self::$memoryLimit = $m[1] * pow(1024, strpos('BKMG', $m[2])) * self::MAXMEMORYUSAGE;
},
strtoupper($memoryLimit));
}
}
/**
......@@ -254,11 +262,20 @@ class Request {
}
}
if (defined('USE_CUSTOM_REMOTE_IP_HEADER') && USE_CUSTOM_REMOTE_IP_HEADER !== false && isset(self::$headers[strtolower(USE_CUSTOM_REMOTE_IP_HEADER)])) {
$remoteIP = self::filterIP(self::$headers[strtolower(USE_CUSTOM_REMOTE_IP_HEADER)]);
if ($remoteIP) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Using custom header '%s' to determine remote IP: %s - connect is coming from IP: %s", USE_CUSTOM_REMOTE_IP_HEADER, $remoteIP, self::$remoteAddr));
self::$remoteAddr = $remoteIP;
if (defined('USE_CUSTOM_REMOTE_IP_HEADER') && USE_CUSTOM_REMOTE_IP_HEADER !== false) {
// make custom header compatible with Apache modphp (see ZP-1332)
$header = $apacheHeader = strtolower(USE_CUSTOM_REMOTE_IP_HEADER);
if (substr($apacheHeader, 0, 5) === 'http_') {
$apacheHeader = substr($apacheHeader, 5);
}
$apacheHeader = str_replace("_", "-", $apacheHeader);
if (isset(self::$headers[$header]) || isset(self::$headers[$apacheHeader])) {
$remoteIP = isset(self::$headers[$header]) ? self::$headers[$header] : self::$headers[$apacheHeader];
$remoteIP = self::filterIP($remoteIP);
if ($remoteIP) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("Using custom header '%s' to determine remote IP: %s - connect is coming from IP: %s", USE_CUSTOM_REMOTE_IP_HEADER, $remoteIP, self::$remoteAddr));
self::$remoteAddr = $remoteIP;
}
}
}
......@@ -700,6 +717,9 @@ class Request {
* @return boolean
*/
static public function IsRequestMemoryLimitReached() {
if (self::$memoryLimit === false) {
return false;
}
return memory_get_peak_usage(true) >= self::$memoryLimit;
}
......
......@@ -52,6 +52,9 @@ require_once 'vendor/autoload.php';
fwrite(STDERR, ZPushAdminCLI::GetErrorMessage() . "\n");
echo ZPushAdminCLI::UsageInstructions();
if (ZPushAdminCLI::$help) {
exit(0);
}
exit(1);
}
......@@ -101,6 +104,8 @@ class ZPushAdminCLI {
static private $folderid = false;
static private $flags = 0;
static public $help = false;
/**
* Returns usage instructions
*
......@@ -172,7 +177,7 @@ class ZPushAdminCLI {
if (self::$errormessage)
return;
$options = getopt("u:d:a:t:sn:o:f:g::", array('user:', 'device:', 'action:', 'type:', 'days-old:', 'days-ago:', 'shared', 'foldername:', 'store', 'folderid:', 'flags::'));
$options = getopt("u:d:a:t:sn:o:f:g::h", array('user:', 'device:', 'action:', 'type:', 'days-old:', 'days-ago:', 'shared', 'foldername:', 'store', 'folderid:', 'flags::', 'help'));
// get 'user'
if (isset($options['u']) && !empty($options['u']))
......@@ -269,6 +274,11 @@ class ZPushAdminCLI {
}
}
if ((isset($options['h']) || isset($options['help'])) && $action === false) {
self::$help = true;
$action = 'help';
}
// get a command for the requested action
switch ($action) {
// list data
......@@ -381,8 +391,12 @@ class ZPushAdminCLI {
self::$command = self::COMMAND_REMOVESHARED;
break;
case "help":
break;
default:
self::UsageInstructions();
self::$help = false;
}
}
......
......@@ -51,7 +51,7 @@ require_once 'vendor/autoload.php';
// check if help was requested from CLI
if (in_array('-h', $argv) || in_array('--help', $argv)) {
echo $zpt->UsageInstructions();
exit(1);
exit(0);
}
if ($zpt->IsAvailable()) {
......
......@@ -42,6 +42,9 @@ include_once(SYNC_CONFIG);
fwrite(STDERR, GabSyncCLI::GetErrorMessage() . PHP_EOL.PHP_EOL);
echo GabSyncCLI::UsageInstructions();
if (GabSyncCLI::$help) {
exit(0);
}
exit(1);
}
else if (!GabSyncCLI::SetupSyncWorker()) {
......@@ -74,6 +77,8 @@ class GabSyncCLI {
static private $targetGab = false;
static private $errormessage;
static public $help = false;
/**
* Returns usage instructions.
*
......@@ -142,7 +147,7 @@ class GabSyncCLI {
if (self::$errormessage)
return;
$options = getopt("u:a:t:");
$options = getopt("u:a:t:h", array('help'));
// get 'unique-id'
if (isset($options['u']) && !empty($options['u']))
......@@ -163,6 +168,11 @@ class GabSyncCLI {
elseif (isset($options['action']) && !empty($options['action']))
$action = strtolower(trim($options['action']));
if ((isset($options['h']) || isset($options['help'])) && $action === false) {
self::$help = true;
$action = 'help';
}
// get a command for the requested action
switch ($action) {
// simulate
......@@ -195,8 +205,12 @@ class GabSyncCLI {
self::$command = self::COMMAND_DELETEALL;
break;
case "help":
break;
default:
self::UsageInstructions();
self::$help = false;
}
}
......
......@@ -48,6 +48,9 @@ define('PATH_TO_ZPUSH', '../../src/');
fwrite(STDERR, GAB2ContactsCLI::GetErrorMessage() . PHP_EOL.PHP_EOL);
echo GAB2ContactsCLI::UsageInstructions();
if (GAB2ContactsCLI::$help) {
exit(0);
}
exit(1);
}
else if (!GAB2ContactsCLI::SetupContactWorker()) {
......@@ -76,6 +79,8 @@ class GAB2ContactsCLI {
static private $sourceGAB;
static private $errormessage;
static public $help = false;
/**
* Returns usage instructions.
*
......@@ -144,7 +149,7 @@ class GAB2ContactsCLI {
if (self::$errormessage)
return;
$options = getopt("a:");
$options = getopt("a:h", array('help'));
// get 'action'
$action = false;
......@@ -153,6 +158,11 @@ class GAB2ContactsCLI {
elseif (isset($options['action']) && !empty($options['action']))
$action = strtolower(trim($options['action']));
if ((isset($options['h']) || isset($options['help'])) && $action === false) {
self::$help = true;
$action = 'help';
}
// get a command for the requested action
switch ($action) {
// sync!
......@@ -165,8 +175,12 @@ class GAB2ContactsCLI {
self::$command = self::COMMAND_DELETE;
break;
case "help":
break;
default:
self::UsageInstructions();
self::$help = false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment