Skip to content
Permalink
Browse files

Ensure qgis.db is writable when copied from RO source

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 31a8f3f1adcedadce90ee0e08ac09f1fba89795c
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/core/qgsapplication.cpp
@@ -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
{

0 comments on commit 31a8f3f

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