[Pkg-owncloud-commits] [owncloud-client] 160/219: SocketAPI: Before reporting something new check for parent permissions.

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:22 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 98d9f7924d158ddc8eab6cba25b37a90604671be
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Sep 25 21:49:38 2014 +0200

    SocketAPI: Before reporting something new check for parent permissions.
    
    In case it is not allowed to create files or dirs because of missing
    permissions in shares, the socket API has to report an error state
    rather than the NEW state.
    
    As discussed in mirall issue #1931
---
 src/mirall/socketapi.cpp | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/mirall/socketapi.cpp b/src/mirall/socketapi.cpp
index aec40e2..fbfeda2 100644
--- a/src/mirall/socketapi.cpp
+++ b/src/mirall/socketapi.cpp
@@ -110,6 +110,18 @@ SyncFileStatus recursiveFolderStatus(Folder *folder, const QString& fileName, c_
     return result;
 }
 
+SyncJournalFileRecord dbFileRecord( Folder *folder, QString fileName )
+{
+    QFileInfo fi(fileName);
+    if( !folder ) {
+        return SyncJournalFileRecord();
+    }
+    if( fi.isAbsolute() ) {
+        fileName.remove(0, folder->path().length());
+    }
+    return( folder->journalDb()->getFileRecord(fileName) );
+}
+
 /**
  * Get status about a single file.
  */
@@ -157,8 +169,30 @@ SyncFileStatus fileStatus(Folder *folder, const QString& systemFileName, c_strli
 
     // Problem: for the sync dir itself we do not have a record in the sync journal
     // so the next check must not be used for the sync root folder.
-    SyncJournalFileRecord rec = folder->journalDb()->getFileRecord(unixFileName);
+    SyncJournalFileRecord rec = dbFileRecord(folder, unixFileName );
     if( !isSyncRootFolder && !rec.isValid() ) {
+        // check the parent folder if it is shared and if it is allowed to create a file/dir within
+        QDir d( fi.path() );
+        QString parentPath = d.path();
+        SyncJournalFileRecord dirRec = dbFileRecord(folder, parentPath);
+        while( !d.isRoot() && !(d.exists() && dirRec.isValid()) ) {
+            d.cdUp(); // returns true if the dir exists.
+
+            parentPath = d.path();
+            // cut the folder path
+            dirRec = dbFileRecord(folder, parentPath);
+        }
+        if( dirRec.isValid() ) {
+            if( dirRec._type == CSYNC_FTW_TYPE_DIR ) {
+                if( !dirRec._remotePerm.contains("K") ) {
+                    return SyncFileStatus::STATUS_ERROR;
+                }
+            } else {
+                if( !dirRec._remotePerm.contains("C") ) {
+                    return SyncFileStatus::STATUS_ERROR;
+                }
+            }
+        }
         return SyncFileStatus(SyncFileStatus::STATUS_NEW);
     }
 
@@ -443,3 +477,4 @@ void SocketApi::command_VERSION(const QString&, QTcpSocket* socket)
 
 
 } // namespace Mirall
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list