-
Notifications
You must be signed in to change notification settings - Fork 817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid detecting permissions to be invalid on linux NTFS file system #7745
Open
mgallien
wants to merge
2
commits into
master
Choose a base branch
from
bugfix/preventWrongPermissionsDetectionOnLinuxNtfs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* | ||
* libcsync -- a library to sync a directory with another | ||
* | ||
* Copyright (c) 2008-2013 by Andreas Schneider <[email protected]> | ||
|
@@ -28,15 +28,15 @@ | |
|
||
#include <memory> | ||
|
||
#include "c_private.h" | ||
#include "c_lib.h" | ||
#include "csync.h" | ||
|
||
#include "vio/csync_vio_local.h" | ||
#include "common/vfs.h" | ||
|
||
#include <QtCore/QLoggingCategory> | ||
#include <QtCore/QFile> | ||
#include <QLoggingCategory> | ||
#include <QFile> | ||
|
||
Q_LOGGING_CATEGORY(lcCSyncVIOLocal, "nextcloud.sync.csync.vio_local", QtInfoMsg) | ||
|
||
|
@@ -49,7 +49,7 @@ | |
QByteArray path; | ||
}; | ||
|
||
static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf); | ||
static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf, bool checkPermissionsValidity); | ||
Check warning on line 52 in src/csync/vio/csync_vio_local_unix.cpp GitHub Actions / buildsrc/csync/vio/csync_vio_local_unix.cpp:52:12 [bugprone-reserved-identifier]
|
||
|
||
csync_vio_handle_t *csync_vio_local_opendir(const QString &name) { | ||
auto handle = std::make_unique<csync_vio_handle_t>(); | ||
|
@@ -71,7 +71,7 @@ | |
return rc; | ||
} | ||
|
||
std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *handle, OCC::Vfs *vfs) { | ||
std::unique_ptr<csync_file_stat_t> csync_vio_local_readdir(csync_vio_handle_t *handle, OCC::Vfs *vfs, bool checkPermissionsValidity) { | ||
|
||
struct _tdirent *dirent = nullptr; | ||
std::unique_ptr<csync_file_stat_t> file_stat; | ||
|
@@ -114,7 +114,7 @@ | |
if (file_stat->path.isNull()) | ||
return file_stat; | ||
|
||
if (_csync_vio_local_stat_mb(fullPath.constData(), file_stat.get()) < 0) { | ||
if (_csync_vio_local_stat_mb(fullPath.constData(), file_stat.get(), checkPermissionsValidity) < 0) { | ||
// Will get excluded by _csync_detect_update. | ||
file_stat->type = ItemTypeSkip; | ||
} | ||
|
@@ -131,12 +131,12 @@ | |
} | ||
|
||
|
||
int csync_vio_local_stat(const QString &uri, csync_file_stat_t *buf) | ||
int csync_vio_local_stat(const QString &uri, csync_file_stat_t *buf, bool checkPermissionsValidity) | ||
{ | ||
return _csync_vio_local_stat_mb(QFile::encodeName(uri).constData(), buf); | ||
return _csync_vio_local_stat_mb(QFile::encodeName(uri).constData(), buf, checkPermissionsValidity); | ||
} | ||
|
||
static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf) | ||
static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf, bool checkPermissionsValidity) | ||
Check warning on line 139 in src/csync/vio/csync_vio_local_unix.cpp GitHub Actions / buildsrc/csync/vio/csync_vio_local_unix.cpp:139:12 [bugprone-reserved-identifier]
|
||
{ | ||
csync_stat_t sb; | ||
|
||
|
@@ -169,7 +169,9 @@ | |
buf->inode = sb.st_ino; | ||
buf->modtime = sb.st_mtime; | ||
buf->size = sb.st_size; | ||
buf->isPermissionsInvalid = (sb.st_mode & S_IWOTH) == S_IWOTH; | ||
if (checkPermissionsValidity) { | ||
buf->isPermissionsInvalid = (sb.st_mode & S_IWOTH) == S_IWOTH; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* | ||
* Copyright (C) by Olivier Goffart <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
|
@@ -943,7 +943,7 @@ | |
|
||
if (!base.isDirectory()) { | ||
csync_file_stat_t buf; | ||
if (csync_vio_local_stat(_discoveryData->_localDir + originalPathAdjusted, &buf)) { | ||
if (csync_vio_local_stat(_discoveryData->_localDir + originalPathAdjusted, &buf, true)) { | ||
qCInfo(lcDisco) << "Local file does not exist anymore." << originalPathAdjusted; | ||
return; | ||
} | ||
|
@@ -2137,7 +2137,7 @@ | |
void ProcessDirectoryJob::startAsyncLocalQuery() | ||
{ | ||
QString localPath = _discoveryData->_localDir + _currentFolder._local; | ||
auto localJob = new DiscoverySingleLocalDirectoryJob(_discoveryData->_account, localPath, _discoveryData->_syncOptions._vfs.data()); | ||
auto localJob = new DiscoverySingleLocalDirectoryJob(_discoveryData->_account, localPath, _discoveryData->_syncOptions._vfs.data(), _discoveryData->_fileSystemReliablePermissions); | ||
|
||
_discoveryData->_currentlyActiveJobs++; | ||
_pendingAsyncJobs++; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* | ||
* Copyright (C) by Olivier Goffart <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
|
@@ -14,7 +14,7 @@ | |
|
||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QElapsedTimer> | ||
#include <QStringList> | ||
#include <csync.h> | ||
|
@@ -119,7 +119,11 @@ | |
{ | ||
Q_OBJECT | ||
public: | ||
explicit DiscoverySingleLocalDirectoryJob(const AccountPtr &account, const QString &localPath, OCC::Vfs *vfs, QObject *parent = nullptr); | ||
explicit DiscoverySingleLocalDirectoryJob(const AccountPtr &account, | ||
const QString &localPath, | ||
OCC::Vfs *vfs, | ||
bool fileSystemReliablePermissions, | ||
QObject *parent = nullptr); | ||
|
||
void run() override; | ||
signals: | ||
|
@@ -134,6 +138,7 @@ | |
QString _localPath; | ||
AccountPtr _account; | ||
OCC::Vfs* _vfs; | ||
bool _fileSystemReliablePermissions = false; | ||
public: | ||
}; | ||
|
||
|
@@ -343,6 +348,8 @@ | |
|
||
bool _noCaseConflictRecordsInDb = false; | ||
|
||
bool _fileSystemReliablePermissions = false; | ||
|
||
QSet<QString> _topLevelE2eeFolderPaths; | ||
|
||
signals: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* | ||
* libcsync -- a library to sync a directory with another | ||
* | ||
* Copyright (c) 2015-2013 by Klaas Freitag <[email protected]> | ||
|
@@ -24,7 +24,7 @@ | |
#include <cerrno> | ||
#include <cstdio> | ||
|
||
#include "csync.h" | ||
#include "vio/csync_vio_local.h" | ||
|
||
#include <QDir> | ||
|
@@ -147,7 +147,7 @@ | |
* whole tree. | ||
* | ||
*/ | ||
static void traverse_dir(void **state, const QString &dir, int *cnt) | ||
static void traverse_dir(void **state, const QString &dir, int *cnt, bool checkPermissionsValidity) | ||
{ | ||
csync_vio_handle_t *dh = nullptr; | ||
std::unique_ptr<csync_file_stat_t> dirent; | ||
|
@@ -161,7 +161,7 @@ | |
assert_non_null(dh); | ||
|
||
OCC::Vfs *vfs = nullptr; | ||
while( (dirent = csync_vio_local_readdir(dh, vfs)) ) { | ||
while( (dirent = csync_vio_local_readdir(dh, vfs, checkPermissionsValidity)) ) { | ||
assert_non_null(dirent.get()); | ||
if (!dirent->original_path.isEmpty()) { | ||
sv->ignored_dir = dirent->original_path; | ||
|
@@ -190,7 +190,7 @@ | |
} | ||
output(subdir_out.constData()); | ||
if( is_dir ) { | ||
traverse_dir(state, QString::fromUtf8(subdir), cnt); | ||
traverse_dir(state, QString::fromUtf8(subdir), cnt, checkPermissionsValidity); | ||
} | ||
} | ||
|
||
|
@@ -210,11 +210,12 @@ | |
{ | ||
auto sv = (statevar*) *state; | ||
|
||
bool checkPermissionsValidity = true; | ||
const char *t1 = "alibaba/und/die/vierzig/räuber/"; | ||
create_dirs( t1 ); | ||
int files_cnt = 0; | ||
|
||
traverse_dir(state, CSYNC_TEST_DIR, &files_cnt); | ||
traverse_dir(state, CSYNC_TEST_DIR, &files_cnt, checkPermissionsValidity); | ||
|
||
assert_string_equal(sv->result.constData(), | ||
QString::fromUtf8("<DIR> %1/alibaba" | ||
|
@@ -233,14 +234,15 @@ | |
auto sv = (statevar*) *state; | ||
int files_cnt = 0; | ||
|
||
bool checkPermissionsValidity = true; | ||
const char *t1 = "warum/nur/40/Räuber/"; | ||
create_dirs( t1 ); | ||
|
||
create_file( t1, "Räuber Max.txt", "Der Max ist ein schlimmer finger"); | ||
create_file( t1, "пя́тница.txt", "Am Freitag tanzt der Ürk"); | ||
|
||
|
||
traverse_dir(state, CSYNC_TEST_DIR, &files_cnt); | ||
traverse_dir(state, CSYNC_TEST_DIR, &files_cnt, checkPermissionsValidity); | ||
|
||
assert_string_equal(sv->result.constData(), | ||
QString::fromUtf8("<DIR> %1/warum" | ||
|
@@ -259,6 +261,8 @@ | |
{ | ||
auto sv = (statevar*) *state; | ||
|
||
bool checkPermissionsValidity = true; | ||
|
||
/* Strange things here: Compilers only support strings with length of 4k max. | ||
* The expected result string is longer, so it needs to be split up in r1, r2 and r3 | ||
*/ | ||
|
@@ -318,7 +322,7 @@ | |
/* assemble the result string ... */ | ||
const auto result = (r1 + r2 + r3).toUtf8(); | ||
int files_cnt = 0; | ||
traverse_dir(state, CSYNC_TEST_DIR, &files_cnt); | ||
traverse_dir(state, CSYNC_TEST_DIR, &files_cnt, checkPermissionsValidity); | ||
assert_int_equal(files_cnt, 0); | ||
/* and compare. */ | ||
assert_string_equal(sv->result.constData(), result.constData()); | ||
|
@@ -333,6 +337,7 @@ | |
// 3: ? ASCII: 191 - BF | ||
// 4: ASCII: 32 - 20 | ||
|
||
bool checkPermissionsValidity = true; | ||
QString p = QStringLiteral("%1/%2").arg(CSYNC_TEST_DIR, QStringLiteral("goodone/")); | ||
int rc = oc_mkdir(p); | ||
assert_int_equal(rc, 0); | ||
|
@@ -344,7 +349,7 @@ | |
assert_int_equal(rc, 0); | ||
|
||
int files_cnt = 0; | ||
traverse_dir(state, CSYNC_TEST_DIR, &files_cnt); | ||
traverse_dir(state, CSYNC_TEST_DIR, &files_cnt, checkPermissionsValidity); | ||
const auto expected_result = QStringLiteral("<DIR> %1/goodone" | ||
"<DIR> %1/goodone/ugly\xEF\xBB\xBF\x32.txt") | ||
.arg(CSYNC_TEST_DIR); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting