Skip to content

Commit

Permalink
Ensure qgis.db is writable when copied from RO source
Browse files Browse the repository at this point in the history
In some package managers (such as NIX[1], used in NixOS[2]), all the data is
installed into a read-only file system.

When QGis is first launched on those systems, it copies the template
`qgis.db` from the share directory into the user private .local
directory, but keeps its permissions unchanged: readonly. Any attempt
from QGIS to update this file fails.

This commit makes sure that the `qgis.db` file is user writable when it
is copied from the installation directory.

[1] https://nixos.org/nix/
[2] https://nixos.org/
  • Loading branch information
lsix authored and nyalldawson committed Jun 19, 2018
1 parent 81330ec commit 31a8f3f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/core/qgsapplication.cpp
Expand Up @@ -1536,6 +1536,19 @@ bool QgsApplication::createDatabase( QString *errorMessage )
}
return false;
}

QFile::Permissions perms = QFile( qgisPrivateDbFile.fileName() ).permissions();
if ( !( perms & QFile::WriteOwner ) )
{
if ( !qgisPrivateDbFile.setPermissions( perms | QFile::WriteOwner ) )
{
if ( errorMessage )
{
*errorMessage = tr( "Can not make '%1' user writable" ).arg( qgisPrivateDbFile.fileName() );
}
return false;
}
}
}
else
{
Expand Down

0 comments on commit 31a8f3f

Please sign in to comment.