Don't always chmod the XDG_RUNTIME_DIR

Since the current user is the owner of the dir, we'll get 0x7700 as
permissions, not just 0x700. With the wrong check, we were always doing
an unnecessary chmod.

Task-number: QTBUG-41735
Change-Id: Ib1fc258fef4bf526baa9c71201f9b78d36f5454f
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Thiago Macieira 2014-10-02 11:49:55 -07:00
parent 85da1625e4
commit fc2fcacfcc

View File

@ -131,8 +131,10 @@ QString QStandardPaths::writableLocation(StandardLocation type)
return QString(); return QString();
} }
// "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700." // "and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700."
// since the current user is the owner, set both xxxUser and xxxOwner
QFile file(xdgRuntimeDir); QFile file(xdgRuntimeDir);
const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser; const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser
| QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
if (file.permissions() != wantedPerms && !file.setPermissions(wantedPerms)) { if (file.permissions() != wantedPerms && !file.setPermissions(wantedPerms)) {
qWarning("QStandardPaths: wrong permissions on runtime directory %s", qPrintable(xdgRuntimeDir)); qWarning("QStandardPaths: wrong permissions on runtime directory %s", qPrintable(xdgRuntimeDir));
return QString(); return QString();