Skip to content

Commit c614b94

Browse files
committedMar 3, 2018
[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.
1 parent 0a6024b commit c614b94

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed
 

‎python/server/qgsserviceregistry.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ services. A module may register multiple services.
5959

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

62-
:param service: a QgsServerResponse to be registered
62+
:param service: a QgsService to be registered
6363
%End
6464

6565
int unregisterService( const QString &name, const QString &version = QString() );

‎src/server/qgsserviceregistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class SERVER_EXPORT QgsServiceRegistry
7373
*
7474
* The registry gain ownership of services and will call 'delete' on cleanup
7575
*
76-
* \param service a QgsServerResponse to be registered
76+
* \param service a QgsService to be registered
7777
*/
7878
void registerService( QgsService *service SIP_TRANSFER );
7979

‎src/server/services/wms/qgswmsrenderer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
#include "qgsdxfexport.h"
6969
#include "qgssymbollayerutils.h"
7070
#include "qgslayoutitemlegend.h"
71+
#include "qgsserverexception.h"
7172

7273
#include <QImage>
7374
#include <QPainter>
@@ -379,11 +380,11 @@ namespace QgsWms
379380
configurePrintLayout( layout.get(), mapSettings );
380381

381382
// Get the temporary output file
382-
QTemporaryFile tempOutputFile( QStringLiteral( "XXXXXX.%1" ).arg( formatString.toLower() ) );
383+
QTemporaryFile tempOutputFile( QDir::tempPath() + '/' + QStringLiteral( "XXXXXX.%1" ).arg( formatString.toLower() ) );
383384
if ( !tempOutputFile.open() )
384385
{
385-
// let the caller handle this
386-
return nullptr;
386+
throw QgsServerException( QStringLiteral( "Could not open temporary file for the GetPrint request." ) );
387+
387388
}
388389

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

0 commit comments

Comments
 (0)
Please sign in to comment.