Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[bugfix][server] Fix temporary path permission issue
If I don't misread the docs, if a template is given, the file
is created in the current directory instead of the temporary
directory reported by QDir::tempPath()

Furthermore it cannot be set by env TMPDIR.

This issue drove me crazy (and no exceptions and no logs!)
until when I switched the server user to root (that is
of course not what we want).

As a temporary workaround, the server can be configured to
use /tmp or another www-data writeable directory as a working
directory.

By prefixing with tempPath() the file will be created
in the system temp directory.
  • Loading branch information
elpaso committed Mar 3, 2018
1 parent 0a6024b commit c614b94
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion python/server/qgsserviceregistry.sip.in
Expand Up @@ -59,7 +59,7 @@ services. A module may register multiple services.

The registry gain ownership of services and will call 'delete' on cleanup

:param service: a QgsServerResponse to be registered
:param service: a QgsService to be registered
%End

int unregisterService( const QString &name, const QString &version = QString() );
Expand Down
2 changes: 1 addition & 1 deletion src/server/qgsserviceregistry.h
Expand Up @@ -73,7 +73,7 @@ class SERVER_EXPORT QgsServiceRegistry
*
* The registry gain ownership of services and will call 'delete' on cleanup
*
* \param service a QgsServerResponse to be registered
* \param service a QgsService to be registered
*/
void registerService( QgsService *service SIP_TRANSFER );

Expand Down
7 changes: 4 additions & 3 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -68,6 +68,7 @@
#include "qgsdxfexport.h"
#include "qgssymbollayerutils.h"
#include "qgslayoutitemlegend.h"
#include "qgsserverexception.h"

#include <QImage>
#include <QPainter>
Expand Down Expand Up @@ -379,11 +380,11 @@ namespace QgsWms
configurePrintLayout( layout.get(), mapSettings );

// Get the temporary output file
QTemporaryFile tempOutputFile( QStringLiteral( "XXXXXX.%1" ).arg( formatString.toLower() ) );
QTemporaryFile tempOutputFile( QDir::tempPath() + '/' + QStringLiteral( "XXXXXX.%1" ).arg( formatString.toLower() ) );
if ( !tempOutputFile.open() )
{
// let the caller handle this
return nullptr;
throw QgsServerException( QStringLiteral( "Could not open temporary file for the GetPrint request." ) );

}

if ( formatString.compare( QLatin1String( "svg" ), Qt::CaseInsensitive ) == 0 )
Expand Down

0 comments on commit c614b94

Please sign in to comment.