summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2013-06-20 13:52:35 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2013-06-20 13:52:35 (GMT)
commitaa67eb6fd91fe78373ef961b0207fe29fa9398a1 (patch)
treeb87b6c387ea982671ed4ccad8bb386eecc91db9b
parent84789326b63f7c976b7fd079cd301e8c6b0e4478 (diff)
downloadiRony-aa67eb6fd91fe78373ef961b0207fe29fa9398a1.tar.gz
Fix WebDAV service for Mac OS X Finder: add support for locking (otherwise mounted read-only); handle the numerous attempts to read and write hidden/temp files
-rw-r--r--lib/Kolab/DAV/Collection.php16
-rw-r--r--public_html/index.php8
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/Kolab/DAV/Collection.php b/lib/Kolab/DAV/Collection.php
index e391162..1a08d1d 100644
--- a/lib/Kolab/DAV/Collection.php
+++ b/lib/Kolab/DAV/Collection.php
@@ -95,6 +95,11 @@ class Collection extends \Kolab\DAV\Node implements \Sabre\DAV\ICollection
*/
public function getChild($name)
{
+ // no support for hidden system files
+ if ($name[0] == '.') {
+ throw new \Sabre\DAV\Exception\NotFound('File not found: ' . $name);
+ }
+
// @TODO: optimise this?
foreach ($this->getChildren() as $child) {
if ($child->getName() == $name) {
@@ -150,6 +155,11 @@ class Collection extends \Kolab\DAV\Node implements \Sabre\DAV\ICollection
*/
public function createFile($name, $data = null)
{
+ // no support for hidden system files
+ if ($name[0] == '.') {
+ throw new \Sabre\DAV\Exception\Forbidden('Hidden files are not accepted');
+ }
+
$filename = $this->path . '/' . $name;
$filedata = $this->fileData($name, $data);
@@ -173,6 +183,11 @@ class Collection extends \Kolab\DAV\Node implements \Sabre\DAV\ICollection
*/
public function createDirectory($name)
{
+ // no support for hidden system files
+ if ($name[0] == '.') {
+ throw new \Sabre\DAV\Exception\Forbidden('Hidden files are not accepted');
+ }
+
$folder = $this->path . '/' . $name;
try {
@@ -185,4 +200,5 @@ class Collection extends \Kolab\DAV\Node implements \Sabre\DAV\ICollection
// reset cache
$this->children = null;
}
+
}
diff --git a/public_html/index.php b/public_html/index.php
index d201ed8..f9c86b4 100644
--- a/public_html/index.php
+++ b/public_html/index.php
@@ -129,6 +129,14 @@ $caldav_plugin = new \Kolab\CalDAV\Plugin();
$caldav_plugin->setIMipHandler(new \Kolab\CalDAV\IMip());
$server->addPlugin($caldav_plugin);
+// the lock manager is reponsible for making sure users don't overwrite each others changes.
+// TODO: replace this with a class that manages locks in the Kolab backend
+$locks_backend = new \Sabre\DAV\Locks\Backend\File(KOLAB_DAV_ROOT . '/temp/locks');
+$server->addPlugin(new \Sabre\DAV\Locks\Plugin($locks_backend));
+
+// intercept some of the garbage files operation systems tend to generate when mounting a WebDAV share
+$server->addPlugin(new \Sabre\DAV\TemporaryFileFilterPlugin(KOLAB_DAV_ROOT . '/temp'));
+
// HTML UI for browser-based access (recommended only for development)
$server->addPlugin(new \Sabre\DAV\Browser\Plugin());