From 4ada435f78f229e9f0a3644776aaa07380a88eb3 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Fri, 8 Nov 2024 15:56:46 +0700 Subject: [PATCH] Insure cert/key files are owned by the right user to restrict permissions properly --- src/core/qgismobileapp.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/qgismobileapp.cpp b/src/core/qgismobileapp.cpp index 37b03ccaa6..c12a673625 100644 --- a/src/core/qgismobileapp.cpp +++ b/src/core/qgismobileapp.cpp @@ -283,7 +283,7 @@ QgisMobileapp::QgisMobileapp( QgsApplication *app, QObject *parent ) if ( !dataDirs.isEmpty() ) { -#if defined( Q_OS_ANDROID ) || defined( Q_OS_IOS ) +#if !defined( Q_OS_ANDROID ) || defined( Q_OS_IOS ) for ( const QString &dataDir : dataDirs ) { QFileInfo pgServiceFile( QStringLiteral( "%1/pg_service.conf" ).arg( dataDir ) ); @@ -293,6 +293,15 @@ QgisMobileapp::QgisMobileapp( QgsApplication *app, QObject *parent ) QStringList files = dir.entryList( QStringList() << QStringLiteral( "*.crt" ) << QStringLiteral( "*.key" ), QDir::Files ); for ( const QString &file : files ) { + const QString filename = QStringLiteral( "%1/%2" ).arg( dataDir, file ); + QFile f( filename ); + f.open( QIODeviceBase::ReadOnly ); + QByteArray content = f.readAll(); + f.close(); + f.remove( filename ); + f.open( QIODeviceBase::WriteOnly ); + f.write( content ); + f.close(); QFileInfo fi( QStringLiteral( "%1/%2" ).arg( dataDir, file ) ); qInfo() << QStringLiteral( "Owner ID %1 name %2" ).arg( fi.ownerId() ).arg( fi.owner() ); qInfo() << QStringLiteral( "Group ID %1 name %2" ).arg( fi.groupId() ).arg( fi.group() );