summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qsharedmemory_posix.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-06-14 18:10:15 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2021-06-16 15:53:23 +0200
commit9661cde1615e21f5b6bbffe3e687cacba247f514 (patch)
tree59c87f748cf2fce86a6b8a1ab8e3d4dfdc71e071 /src/corelib/kernel/qsharedmemory_posix.cpp
parent20f835329a35651c720b73a8d217e3b48ebd2fcf (diff)
Apple: Use POSIX IPC instead of System V in sandboxed applications
System V semaphores are not supported in sandboxed applications, so when Qt is configured with App Store compliance, or the user requests POSIX IPC explicitly, we use that instead. https://developer.apple.com/library/archive/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW24 As the shared memory name limit on Apple platforms is very low, we have to skip the existing logic for naming, and instead use a truncated hash of the key. This should still be fine for avoiding any collisions in practice. An explicit check for the ENAMETOOLONG error has been added to catch any cases where they key goes beyond the allowed length. Sandboxed applications also have an extra requirement that the key must include an application group identifier. This requirement has been pushed up to the user and documented, as we don't have enough information in Qt to know which identifier to use. Both tst_QSystemSemaphore and tst_QSharedMemory work as before with both sandboxed and non-sandboxed applications, after removing some assumptions in tst_QSharedMemory about System V behavior. Fixes: QTBUG-91130 Change-Id: Iaf1edb36a5d84d69e42ec31471a48d112faa8c6a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qsharedmemory_posix.cpp')
-rw-r--r--src/corelib/kernel/qsharedmemory_posix.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/src/corelib/kernel/qsharedmemory_posix.cpp b/src/corelib/kernel/qsharedmemory_posix.cpp
index d83ff4cb92..9406e200be 100644
--- a/src/corelib/kernel/qsharedmemory_posix.cpp
+++ b/src/corelib/kernel/qsharedmemory_posix.cpp
@@ -102,7 +102,6 @@ bool QSharedMemoryPrivate::create(qsizetype size)
const int errorNumber = errno;
const QLatin1String function("QSharedMemory::attach (shm_open)");
switch (errorNumber) {
- case ENAMETOOLONG:
case EINVAL:
errorString = QSharedMemory::tr("%1: bad name").arg(function);
error = QSharedMemory::KeyError;
@@ -146,7 +145,6 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
const int errorNumber = errno;
const QLatin1String function("QSharedMemory::attach (shm_open)");
switch (errorNumber) {
- case ENAMETOOLONG:
case EINVAL:
errorString = QSharedMemory::tr("%1: bad name").arg(function);
error = QSharedMemory::KeyError;