summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-10 08:27:13 (GMT)
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2009-09-10 08:27:13 (GMT)
commit27d3905f3d08ef0498ceba1eeb367403cf9f2980 (patch)
tree21595c15c4b2ed101cbe6d14a9d90382f3154075 /src/corelib/kernel
parent20a61e1cf39ee66cf0880c6f8f36634115cf610e (diff)
downloadQt-27d3905f3d08ef0498ceba1eeb367403cf9f2980.zip
Qt-27d3905f3d08ef0498ceba1eeb367403cf9f2980.tar.gz
Qt-27d3905f3d08ef0498ceba1eeb367403cf9f2980.tar.bz2
Fixed various PlatSec violations when app had no AllFiles capability.
Fixed QtCore in various places that caused Platform Security violations in Symbian if AllFiles capability was missing from the application. All of these these were caused by trying to access /private folder unnecessarily, either by Qt code or Open C. Task-number: 249008 Reviewed-by: Janne Koskinen
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 423bdf8..25098cc 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1806,18 +1806,35 @@ QString QCoreApplication::applicationDirPath()
RProcess proc;
TInt err = proc.Open(proc.Id());
if (err == KErrNone) {
+ QChar driveChar;
#if defined(Q_CC_NOKIAX86)
// In emulator, always resolve the private dir on C-drive
- appPath.append(QChar('C'));
+ driveChar = QLatin1Char('C');
#else
- appPath.append(QChar((proc.FileName())[0]));
+ driveChar = QLatin1Char((proc.FileName())[0]);
#endif
- appPath.append(QLatin1String(":\\private\\"));
- QString sid;
- sid.setNum(proc.SecureId().iId, 16);
- appPath.append(sid);
- appPath.append(QLatin1Char('\\'));
proc.Close();
+
+ driveChar = driveChar.toUpper();
+
+ TFileName privatePath;
+ RFs& fs = qt_s60GetRFs();
+ fs.PrivatePath(privatePath);
+ appPath = qt_TDesC2QString(privatePath);
+ appPath.prepend(QLatin1Char(':')).prepend(driveChar);
+
+ // Create the appPath if it doesn't exist. Non-existing appPath will cause
+ // Platform Security violations later on if the app doesn't have AllFiles capability.
+ // Can't create appPath for ROM unfortunately, so applications meant for
+ // ROM should always deploy something to their private dir to ensure appPath exists,
+ // if the PlatSec violations are an issue.
+ char driveDiff = QLatin1Char('Z').toLatin1() - driveChar.toLatin1();
+ TInt driveId = EDriveZ - static_cast<TInt>(driveDiff);
+ if (driveId != EDriveZ) {
+ TInt err = fs.CreatePrivatePath(driveId);
+ if (err != KErrNone)
+ qWarning("QCoreApplication::applicationDirPath: Failed to create private path.");
+ }
}
QFileInfo fi(appPath);