Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 9d41db1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/qgsuserprofilemanager.cpp
Expand Up @@ -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() )
Expand Down

0 comments on commit 9d41db1

Please sign in to comment.