From 72cc1daf22fb7cb24b4be2e491767a26957cf7ab Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 2 Mar 2021 13:29:32 +0200 Subject: [PATCH] wayland: Introduce an environment variable to disable Xauthority This is primarily intended for debugging purposes. --- src/xwl/xwayland.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/xwl/xwayland.cpp b/src/xwl/xwayland.cpp index 56695ccbd4..8f319a680c 100644 --- a/src/xwl/xwayland.cpp +++ b/src/xwl/xwayland.cpp @@ -141,10 +141,12 @@ void Xwayland::start() return; } - if (!generateXauthorityFile(socket->display(), &m_authorityFile)) { - qCWarning(KWIN_XWL) << "Failed to create an Xauthority file"; - emit errorOccurred(); - return; + if (!qEnvironmentVariableIsSet("KWIN_WAYLAND_NO_XAUTHORITY")) { + if (!generateXauthorityFile(socket->display(), &m_authorityFile)) { + qCWarning(KWIN_XWL) << "Failed to create an Xauthority file"; + emit errorOccurred(); + return; + } } m_socket.reset(socket.take()); @@ -220,9 +222,12 @@ bool Xwayland::startInternal() QStringLiteral("-displayfd"), QString::number(pipeFds[1]), QStringLiteral("-rootless"), QStringLiteral("-wm"), QString::number(fd), - QStringLiteral("-auth"), m_authorityFile.fileName(), }; + if (m_authorityFile.isOpen()) { + arguments << QStringLiteral("-auth") << m_authorityFile.fileName(); + } + #if defined(HAVE_XWAYLAND_LISTENFD) arguments << QStringLiteral("-listenfd") << QString::number(abstractSocket) << QStringLiteral("-listenfd") << QString::number(unixSocket); @@ -434,7 +439,9 @@ void Xwayland::handleXwaylandReady() qCInfo(KWIN_XWL) << "Xwayland server started on display" << displayName; qputenv("DISPLAY", displayName); - qputenv("XAUTHORITY", m_authorityFile.fileName().toUtf8()); + if (m_authorityFile.isOpen()) { + qputenv("XAUTHORITY", m_authorityFile.fileName().toUtf8()); + } // create selection owner for WM_S0 - magic X display number expected by XWayland m_selectionOwner.reset(new KSelectionOwner("WM_S0", kwinApp()->x11Connection(), kwinApp()->x11RootWindow())); @@ -450,7 +457,9 @@ void Xwayland::handleXwaylandReady() auto env = m_app->processStartupEnvironment(); env.insert(QStringLiteral("DISPLAY"), displayName); - env.insert(QStringLiteral("XAUTHORITY"), m_authorityFile.fileName()); + if (m_authorityFile.isOpen()) { + env.insert(QStringLiteral("XAUTHORITY"), m_authorityFile.fileName()); + } m_app->setProcessStartupEnvironment(env); Xcb::sync(); // Trigger possible errors, there's still a chance to abort