diff --git a/src/compositor/compositor_api/aurorawaylandcompositor.cpp b/src/compositor/compositor_api/aurorawaylandcompositor.cpp index cc73daa9..a5bfb219 100644 --- a/src/compositor/compositor_api/aurorawaylandcompositor.cpp +++ b/src/compositor/compositor_api/aurorawaylandcompositor.cpp @@ -38,8 +38,12 @@ #include "aurorawaylandsharedmemoryformathelper_p.h" #include +#include +#include +#include #include #include +#include #include #include @@ -149,6 +153,8 @@ WaylandCompositorPrivate::WaylandCompositorPrivate(WaylandCompositor *compositor ownsDisplay = true; } + verifyXdgRuntimeDir(); + eventHandler.reset(new Internal::WindowSystemEventHandler(compositor)); timer.start(); @@ -163,6 +169,48 @@ WaylandCompositorPrivate::WaylandCompositorPrivate(WaylandCompositor *compositor #endif } +void WaylandCompositorPrivate::verifyXdgRuntimeDir() +{ + const auto runtimePath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); + if (runtimePath.isEmpty()) { + qFatal("The XDG_RUNTIME_DIR environment variable is not set.\n" + "Refer to your distribution on how to get it, or read\n" + "http://www.freedesktop.org/wiki/Specifications/basedir-spec\n" + "on how to implement it."); + } + + const auto runtimeDir = QDir(runtimePath); + if (!runtimeDir.exists()) { + qFatal("Runtime directory does not exist, please check the " + "XDG_RUNTIME_DIR environment variable.\n" + "Refer to your distribution on how to get it, or read\n" + "http://www.freedesktop.org/wiki/Specifications/basedir-spec\n" + "on how to implement it."); + } + + // Check directory permissions + QFileInfo fileInfo(runtimePath); + if (!(fileInfo.permissions() & QFile::ReadUser) || !(fileInfo.permissions() & QFile::WriteUser) + || !(fileInfo.permissions() & QFile::ExeUser)) { + qFatal("Runtime directory \"%s\" does not have 700 permissions.\n" + "Please check the XDG_RUNTIME_DIR environment variable." + "Refer to your distribution on how to get it, or read\n" + "http://www.freedesktop.org/wiki/Specifications/basedir-spec\n" + "on how to implement it.", + qPrintable(runtimePath)); + } + + // Check owner + if (fileInfo.ownerId() != getuid()) { + qFatal("Current user is not the owner of the runtime directory." + "Please check the XDG_RUNTIME_DIR environment variable." + "Refer to your distribution on how to get it, or read\n" + "http://www.freedesktop.org/wiki/Specifications/basedir-spec\n" + "on how to implement it.", + qPrintable(runtimePath)); + } +} + void WaylandCompositorPrivate::init() { Q_Q(WaylandCompositor); diff --git a/src/compositor/compositor_api/aurorawaylandcompositor_p.h b/src/compositor/compositor_api/aurorawaylandcompositor_p.h index 6e0bb1e7..ca8557c4 100644 --- a/src/compositor/compositor_api/aurorawaylandcompositor_p.h +++ b/src/compositor/compositor_api/aurorawaylandcompositor_p.h @@ -62,6 +62,8 @@ class LIRIAURORACOMPOSITOR_EXPORT WaylandCompositorPrivate : public QObjectPriva void preInit(); void init(); + void verifyXdgRuntimeDir(); + void destroySurface(WaylandSurface *surface); void unregisterSurface(WaylandSurface *surface);