diff options
author | Hannah von Reth <hannah.vonreth@owncloud.com> | 2021-09-21 13:34:02 +0300 |
---|---|---|
committer | Hannah von Reth <vonreth@kde.org> | 2021-09-22 13:50:48 +0300 |
commit | 0919a2611edc20ce9dd7cb1eda3edc83522ffd3d (patch) | |
tree | e58717a25884ff682d3004269cc521c3312e9962 /src/common | |
parent | 2a95f3b442e6f75eda39347c3c08ea84fb436335 (diff) |
Use NtfsPermissionLookupRAII when checking for readable/writeabel
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/filesystembase.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp index 066e20373..640589ca3 100644 --- a/src/common/filesystembase.cpp +++ b/src/common/filesystembase.cpp @@ -100,6 +100,7 @@ void FileSystem::setFileReadOnly(const QString &filename, bool readonly) if (!readonly) { permissions |= defaultWritePermissions; } + // Warning: This function does not manipulate ACLs, which may limit its effectiveness. file.setPermissions(permissions); } @@ -197,6 +198,10 @@ bool FileSystem::uncheckedRenameReplace(const QString &originFileName, #else //Q_OS_WIN // You can not overwrite a read-only file on windows. + + Utility::NtfsPermissionLookupRAII ntfs_perm; + // Warning: This function does not manipulate ACLs, which may limit its effectiveness. + // this renders this check kind of pointless if (!QFileInfo(destinationFileName).isWritable()) { setFileReadOnly(destinationFileName, false); } @@ -362,6 +367,10 @@ bool FileSystem::remove(const QString &fileName, QString *errorString) #ifdef Q_OS_WIN // You cannot delete a read-only file on windows, but we want to // allow that. + + Utility::NtfsPermissionLookupRAII ntfs_perm; + // Warning: This function does not manipulate ACLs, which may limit its effectiveness. + // this renders this check kind of pointless if (!QFileInfo(fileName).isWritable()) { setFileReadOnly(fileName, false); } |