Skip to content
Permalink
Browse files

createUserProfile: ensure qgis.db file is user writable

In some package managers (such as NIX[1], used in NixOS[2]), packaged
data is installed read-only.

When creating a new user profile, QGis copies the `qgis.db` file from
the packages and the user ends having a read-only `qgis.db` database.

This commit ensures that once copied when creating a ne profile, the
`qgis.db` file is made user writable.

[1] https://nixos.org/nix/
[2] https://nixos.org/
  • Loading branch information
lsix authored and nyalldawson committed Jul 20, 2020
1 parent ffe8f03 commit 9d41db14cc63ce552b2cf5c8ece16543f31ade39
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/core/qgsuserprofilemanager.cpp
@@ -156,6 +156,17 @@ QgsError QgsUserProfileManager::createUserProfile( const QString &name )

//now copy the master file into the users .qgis dir
masterFile.copy( qgisPrivateDbFile.fileName() );

// In some packaging systems, the master can be read-only. Make sure to make
// the copy user writable.
const QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
if ( !( perms & QFile::WriteOwner ) )
{
if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
{
error.append( tr( "Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() ) );
}
}
}

if ( error.isEmpty() )

0 comments on commit 9d41db1

Please sign in to comment.
You can’t perform that action at this time.