[Pkg-owncloud-commits] [owncloud-client] 362/484: SyncEngine: Handle 403 Forbidden properly.

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:38:05 UTC 2015


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 62d26814b2e333deb9a5b61b9fc9ea7d33594add
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Mon Oct 12 17:06:49 2015 +0200

    SyncEngine: Handle 403 Forbidden properly.
    
    A 403 is a reply code sent from the file firewall to indicate that
    this directory is forbidden to use for the user.
    
    The patch handles it by setting the state to IGNORED.
    
    This addresses #3490
---
 csync/src/csync.h              |  3 ++-
 csync/src/csync_macros.h       |  1 +
 csync/src/csync_update.c       | 14 ++++++++++++++
 src/libsync/discoveryphase.cpp |  4 +++-
 src/libsync/syncengine.cpp     |  8 ++++++++
 5 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/csync/src/csync.h b/csync/src/csync.h
index 49abffd..e2ab1ae 100644
--- a/csync/src/csync.h
+++ b/csync/src/csync.h
@@ -102,7 +102,8 @@ enum csync_status_codes_e {
     CYSNC_STATUS_FILE_LOCKED_OR_OPEN,
     CSYNC_STATUS_INDIVIDUAL_EXCLUDE_HIDDEN,
     CSYNC_STATUS_INVALID_CHARACTERS,
-    CSYNC_STATUS_INDIVIDUAL_STAT_FAILED
+    CSYNC_STATUS_INDIVIDUAL_STAT_FAILED,
+    CSYNC_STATUS_FORBIDDEN
 };
 
 typedef enum csync_status_codes_e CSYNC_STATUS;
diff --git a/csync/src/csync_macros.h b/csync/src/csync_macros.h
index 925a523..f128b43 100644
--- a/csync/src/csync_macros.h
+++ b/csync/src/csync_macros.h
@@ -46,6 +46,7 @@
 #define ERRNO_SERVICE_UNAVAILABLE    CSYNC_CUSTOM_ERRNO_BASE+14
 #define ERRNO_USER_ABORT             CSYNC_CUSTOM_ERRNO_BASE+16
 #define ERRNO_STORAGE_UNAVAILABLE    CSYNC_CUSTOM_ERRNO_BASE+17
+#define ERRNO_FORBIDDEN              CSYNC_CUSTOM_ERRNO_BASE+18
 
 #endif /* _CSYNC_MACROS_H */
 /* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */
diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c
index 0bda664..0642b44 100644
--- a/csync/src/csync_update.c
+++ b/csync/src/csync_update.c
@@ -640,6 +640,20 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
               CSYNC_LOG(CSYNC_LOG_PRIORITY_ERROR, "asprintf failed!");
           }
       }
+      //
+      else if(errno == ERRNO_FORBIDDEN) {
+          CSYNC_LOG(CSYNC_LOG_PRIORITY_WARN, "Directory access Forbidden (File Firewall?)");
+          if (ctx->current_fs) {
+              ctx->current_fs->instruction = CSYNC_INSTRUCTION_IGNORE;
+              ctx->current_fs->error_status = CSYNC_STATUS_FORBIDDEN;
+              /* If a directory has ignored files, put the flag on the parent directory as well */
+              if( previous_fs ) {
+                  previous_fs->has_ignored_files = true;
+              }
+              goto done;
+          }
+          /* if current_fs is not defined here, better throw an error */
+      }
       // The server usually replies with the custom "503 Storage not available"
       // if some path is temporarily unavailable. But in some cases a standard 503
       // is returned too. Thus we can't distinguish the two and will treat any
diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp
index 034239f..9c73e07 100644
--- a/src/libsync/discoveryphase.cpp
+++ b/src/libsync/discoveryphase.cpp
@@ -160,8 +160,10 @@ int get_errno_from_http_errcode( int err, const QString & reason ) {
     case 423:           /* Locked */
         new_errno = EACCES;
         break;
-    case 400:           /* Bad Request */
     case 403:           /* Forbidden */
+        new_errno = ERRNO_FORBIDDEN;
+        break;
+    case 400:           /* Bad Request */
     case 409:           /* Conflict */
     case 411:           /* Length Required */
     case 412:           /* Precondition Failed */
diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp
index 94fe027..520b82e 100644
--- a/src/libsync/syncengine.cpp
+++ b/src/libsync/syncengine.cpp
@@ -161,6 +161,9 @@ QString SyncEngine::csyncErrorToString(CSYNC_STATUS err)
     case CSYNC_STATUS_STORAGE_UNAVAILABLE:
         errStr = tr("The mounted folder is temporarily not available on the server");
         break;
+    case CSYNC_STATUS_FORBIDDEN:
+        errStr = tr("Access is forbidden");
+        break;
     case CSYNC_STATUS_OPENDIR_ERROR:
         errStr = tr("An error occurred while opening a folder");
         break;
@@ -412,6 +415,11 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
         item->_status = SyncFileItem::SoftError;
         _temporarilyUnavailablePaths.insert(item->_file);
         break;
+    case CSYNC_STATUS_FORBIDDEN:
+        item->_errorString = QLatin1String("Access forbidden.");
+        item->_status = SyncFileItem::SoftError;
+        _temporarilyUnavailablePaths.insert(item->_file);
+        break;
     case CSYNC_STATUS_PERMISSION_DENIED:
         item->_errorString = QLatin1String("Directory not accessible on client, permission denied.");
         item->_status = SyncFileItem::SoftError;

-- 
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