diff options
| author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2025-11-03 17:35:32 +0100 |
|---|---|---|
| committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2025-11-26 15:59:24 +0100 |
| commit | 0edcb27891ee5576acd90139d99664dc7d6a4847 (patch) | |
| tree | 820ad866beed1f03c8cf2fb0a1b27ac8f5f8d27f /src/corelib/io/qfilesystemengine.cpp | |
| parent | 6aaf3bbc6ba6c642cb46211bfbd8272f1b21f790 (diff) | |
Add security scoped file engine for Apple operating systems
On Apple operating systems where the app runs in a sandbox,
the application can not access files outside of its sandbox
without explicit user approval.
This applies to iOS and friends, as well as optionally for
macOS (when the sandbox is enabled, which is a requirement
for publishing apps to the macOS App Store).
When the user gives explicit access to a file or directory,
we need to manage this access at runtime by starting and
stopping the access via startAccessingSecurityScopedResource
and stopAccessingSecurityScopedResource, and these functions
must be balanced, to avoid leaking kernel resources.
The access unfortunately doesn't persist automatically when
the application terminates (unlike takePersistableUriPermission
on Android), so we have to manually persist the access via
security scoped bookmarks. We store these inside the app's
own sandbox, in a way that limits the access to only that
application, so persisting them on behalf of the user should
be fine.
The persisted bookmarks are loaded in the background on
application start, ready for when the application wants
to open earlier accessed file or directories.
[ChangeLog][Apple] Sandboxed applications on Apple platforms,
(including macOS if opted in to) can now access files outside
of the application sandbox (so called security scoped resources)
for both reading and writing. Files or folders chosen by the user
via file dialogs or similar native mechanism are automatically
and transparently handled, including persistent access across
application and device restarts.
Fixes: QTBUG-120528
Task-number: QTBUG-117832
Task-number: QTBUG-120528
Task-number: QTBUG-141414
Change-Id: I90d94066cbf7cd74750049d5d1b990917fd10cad
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/corelib/io/qfilesystemengine.cpp')
| -rw-r--r-- | src/corelib/io/qfilesystemengine.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp index 03da2331e05..46d4cb709e2 100644 --- a/src/corelib/io/qfilesystemengine.cpp +++ b/src/corelib/io/qfilesystemengine.cpp @@ -190,6 +190,14 @@ QFileSystemEngine::createLegacyEngine(QFileSystemEntry &entry, QFileSystemMetaDa return engine; } +std::unique_ptr<QAbstractFileEngine> +QFileSystemEngine::createLegacyEngine(const QString &fileName) +{ + QFileSystemEntry entry(fileName); + QFileSystemMetaData metaData; + return createLegacyEngine(entry, metaData); +} + //static QString QFileSystemEngine::resolveUserName(const QFileSystemEntry &entry, QFileSystemMetaData &metaData) { |
