Details
-
Bug
-
Resolution: Duplicate
-
P3: Somewhat important
-
None
-
5.15.0 RC2
-
None
Description
QSharedMemory can't be shared between proccess owned by different users. Probably it was done by secure reasons. But it's not expected behaviour and it is not documented.
In my personol case I run my app first in one user then killall -9 my_app then run it with another user and get weird error about QSharedMemory. Then I looked at QSharedMemory documentation and found nothing. Then I opened QSharedMemory sources and found
QString QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, const QString &prefix) { if (key.isEmpty()) return QString(); QString result = prefix; for (QChar ch : key) { if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) || (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z'))) result += ch; } QByteArray hex = QCryptographicHash::hash(key.toUtf8(), QCryptographicHash::Sha1).toHex(); result.append(QLatin1String(hex)); #ifdef Q_OS_WIN return result; #elif defined(QT_POSIX_IPC) return QLatin1Char('/') + result; #else return QDir::tempPath() + QLatin1Char('/') + result; #endif }
and
int QSharedMemoryPrivate::createUnixKeyFile(const QString &fileName) { int fd = qt_safe_open(QFile::encodeName(fileName).constData(), O_EXCL | O_CREAT | O_RDWR, 0640); ... }
So please update documentation. Add some note that QSharedMemory can't be used for inter-user communication and that filename of key must be different for different users.
Attachments
Issue Links
- duplicates
-
QTBUG-86258 QSharedMemory memory cannot be shared with other accounts
- Open