From e9060024fa2100ce5c8b2e8689d2ec72b75a3211 Mon Sep 17 00:00:00 2001 From: Pasi Pentikainen Date: Tue, 6 Sep 2011 16:39:24 +0300 Subject: Add documentation for Symbian QSettings locations and security Task-number: QTBUG-11192 Reviewed-by: Miikka Heikkinen --- doc/src/snippets/code/src_corelib_io_qsettings.cpp | 21 ++++++++++ src/corelib/io/qsettings.cpp | 47 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/doc/src/snippets/code/src_corelib_io_qsettings.cpp b/doc/src/snippets/code/src_corelib_io_qsettings.cpp index 5abb0e3..269aa44 100644 --- a/doc/src/snippets/code/src_corelib_io_qsettings.cpp +++ b/doc/src/snippets/code/src_corelib_io_qsettings.cpp @@ -314,3 +314,24 @@ int main(int argc, char *argv[]) ... } //! [29] + +//! [30] +QSettings settings(QApplication::applicationDirPath() + "/MySoft.conf"); +//! [30] + +//! [31] +#include +#include +int main(int argc, char *argv[]) +{ +#ifdef Q_OS_SYMBIAN + // Use QDesktopServices:storageLocation as QApplication is not yet created + QSettings::setPath( + QSettings::NativeFormat, QSettings::UserScope, + QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/settings"); +#endif + QApplication app(argc, argv); + + ... +} +//! [31] diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 79b2728..d35d845 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2338,6 +2338,25 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, %COMMON_APPDATA% path is usually \tt{C:\\Documents and Settings\\All Users\\Application Data}. + On Symbian, the following files are used for both IniFormat and + NativeFormat (in this example, we assume that the application is + installed on the \c e-drive and its Secure ID is \c{0xECB00931}): + + \list 1 + \o \c{c:\data\.config\MySoft\Star Runner.conf} + \o \c{c:\data\.config\MySoft.conf} + \o \c{e:\private\ecb00931\MySoft\Star Runner.conf} + \o \c{e:\private\ecb00931\MySoft.conf} + \endlist + + The SystemScope settings location is determined from the installation + drive and Secure ID (UID3) of the application. If the application is + built-in on the ROM, the drive used for SystemScope is \c c:. + + \note Symbian SystemScope settings are by default private to the + application and not shared between applications, unlike other + environments. + The paths for the \c .ini and \c .conf files can be changed using setPath(). On Unix and Mac OS X, the user can override them by by setting the \c XDG_CONFIG_HOME environment variable; see @@ -2395,6 +2414,32 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, On other platforms than Windows, "Default" and "." would be treated as regular subkeys. + \section2 Securing application settings in Symbian + + UserScope settings in Symbian are writable by any application by + default. To protect the application settings from access and tampering + by other applications, the settings need to be placed in the private + secure area of the application. This can be done by specifying the + settings storage path directly to the private area. The following + snippet changes the UserScope to \c{c:/private/ecb00931/MySoft.conf} + (provided the application is installed on the \c{c-drive} and its + Secure ID is \c{0xECB00931}: + + \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 30 + + Framework libraries (like Qt itself) may store configuration and cache + settings using UserScope, which is accessible and writable by other + applications. If the application is very security sensitive or uses + high platform security capabilities, it may be prudent to also force + framework settings to be stored in the private directory of the + application. This can be done by changing the default path of UserScope + before QApplication is created: + + \snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 31 + + Note that this may affect framework libraries' functionality if they expect + the settings to be shared between applications. + \section2 Platform Limitations While QSettings attempts to smooth over the differences between @@ -3429,6 +3474,8 @@ void QSettings::setUserIniPath(const QString &dir) \row \o SystemScope \o \c /etc/xdg \row \o{1,2} Mac OS X \o{1,2} IniFormat \o UserScope \o \c $HOME/.config \row \o SystemScope \o \c /etc/xdg + \row \o{1,2} Symbian \o{1,2} NativeFormat, IniFormat \o UserScope \o \c c:/data/.config + \row \o SystemScope \o \c /private/ \endtable The default UserScope paths on Unix and Mac OS X (\c -- cgit v0.12 From 0ed694bd074be42272bf795a3add4f55457ddd75 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Fri, 9 Sep 2011 16:00:19 +0100 Subject: More accurately determine bearer type for symbian GPRS/3G The symbian IAP records don't distinguish between GRPS/EDGE/3G/HSPA, although the phone knows what type of cell it is attached to. For the IAP records which are of packet data type (reported as KCommDbBearerWcdma), we now query the phone network mode to determine the bearer type to report. The Qt API doesn't distinguish GRPS/EDGE (both are "2G") The Symbian API doesn't distinguish 3G and HSPA unless there is an active connection. So we have to report both of these as WCDMA. When a connection becomes active, we update Qt's IAP record list to show the known connection type (which may include HSPA now). Qt already contained code to observe roaming between cell types, which reports all types. Note that the bearer type may change during connection (handover to another cell may occur), which should be covered by the already existing code. Task-Number: QTBUG-19011 Reviewed-By: mread --- src/plugins/bearer/symbian/symbianengine.cpp | 36 ++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index fc2791a..fdfe94a 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -505,8 +505,33 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( cpPriv->bearerType = QNetworkConfiguration::Bearer2G; break; case KCommDbBearerWcdma: - cpPriv->bearerType = QNetworkConfiguration::BearerWCDMA; - break; + { + //This is ambiguous, check the network status to find out what the expected connection will be + TUint mode; + TRequestStatus status; + iConnectionMonitor.GetUintAttribute(0, 0, KMobilePhoneNetworkMode, mode, status); + User::WaitForRequest(status); + if (status != KErrNone) + cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; + else switch (mode) { + case EConnMonNetworkModeCdma2000: + cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000; + break; + case EConnMonNetworkModeWcdma: + case EConnMonNetworkModeTdcdma: + cpPriv->bearerType = QNetworkConfiguration::BearerWCDMA; //includes HSDPA, as this API can't detect it + break; + case EConnMonNetworkModeGsm: + case EConnMonNetworkModeAmps: + case EConnMonNetworkModeCdma95: + cpPriv->bearerType = QNetworkConfiguration::Bearer2G; //includes GPRS and EDGE, Qt API treats them both as 2G + break; + default: + cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; + break; + } + break; + } case KCommDbBearerLAN: cpPriv->bearerType = QNetworkConfiguration::BearerEthernet; break; @@ -1122,6 +1147,13 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } ); } + + //update bearer type for 2G/3G connections + TInt bearer; + iConnectionMonitor.GetIntAttribute(connectionId, 0, KBearerInfo, bearer, status); + User::WaitForRequest(status); + if (status == KErrNone) + updateMobileBearerToConfigs(TConnMonBearerInfo(bearer)); } else if (connectionStatus == KConfigDaemonStartingDeregistration) { TUint connectionId = realEvent->ConnectionId(); QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); -- cgit v0.12 From 6144cd83d3bcc9783da54e0538c00642690d515d Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 13 Sep 2011 14:08:20 +0100 Subject: Fix uninitialised variable in temporary files The symbianFilePos variable was only initialised in the nativeOpen function and not in the constructor called init(). Due to the fix for QTBUG-4796, QTemporaryFile now bypasses the nativeOpen function. Zero initialising in init() ensures it is always valid (it only needs a non zero initialisation when opening a file for append, which is still covered by nativeOpen) Task-Number: QTBUG-21418 Reviewed-By: mread --- src/corelib/io/qfsfileengine.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index e1f3123..dd4c40f 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -120,9 +120,12 @@ void QFSFileEnginePrivate::init() openMode = QIODevice::NotOpen; fd = -1; fh = 0; -#if defined (Q_OS_SYMBIAN) && !defined(QT_SYMBIAN_USE_NATIVE_FILEMAP) +#if defined (Q_OS_SYMBIAN) + symbianFilePos = 0; +#if !defined(QT_SYMBIAN_USE_NATIVE_FILEMAP) fileHandleForMaps = -1; #endif +#endif lastIOCommand = IOFlushCommand; lastFlushFailed = false; closeFileHandle = false; -- cgit v0.12