Skip to content

Commit

Permalink
Insure cert/key files are owned by the right user to restrict permiss…
Browse files Browse the repository at this point in the history
…ions properly
  • Loading branch information
nirvn committed Nov 8, 2024
1 parent f2a7893 commit 4ada435
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand All @@ -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() );
Expand Down

0 comments on commit 4ada435

Please sign in to comment.