diff --git a/autotests/server/CMakeLists.txt b/autotests/server/CMakeLists.txt --- a/autotests/server/CMakeLists.txt +++ b/autotests/server/CMakeLists.txt @@ -1,6 +1,7 @@ ######################################################## # Test WaylandServerDisplay ######################################################## +add_definitions(-DAUTOTEST_CURRENT_BIN_DIR="${CMAKE_CURRENT_BINARY_DIR}") set( testWaylandServerDisplay_SRCS test_display.cpp ) diff --git a/autotests/server/test_display.cpp b/autotests/server/test_display.cpp --- a/autotests/server/test_display.cpp +++ b/autotests/server/test_display.cpp @@ -137,6 +137,7 @@ QVERIFY(connection->groupId() != 0); QVERIFY(connection->processId() != 0); QCOMPARE(connection->display(), &display); + QCOMPARE(connection->executablePath(), QStringLiteral("%1/testWaylandServerDisplay").arg(AUTOTEST_CURRENT_BIN_DIR)); QCOMPARE((wl_client*)*connection, client); const ClientConnection &constRef = *connection; QCOMPARE((wl_client*)constRef, client); diff --git a/src/server/clientconnection.h b/src/server/clientconnection.h --- a/src/server/clientconnection.h +++ b/src/server/clientconnection.h @@ -109,6 +109,19 @@ gid_t groupId() const; /** + * The absolute path to the executable. + * + * Please note: if the ClientConnection got created with @link Display::createClient @endlink + * the executablePath will be identical to the process running the KWayland::Server::Display. + * + * If the executable path cannot be resolved an empty QString is returned. + * + * @see processId + * @since 5.6 + **/ + QString executablePath() const; + + /** * Cast operator the native wl_client this ClientConnection represents. **/ operator wl_client*(); diff --git a/src/server/clientconnection.cpp b/src/server/clientconnection.cpp --- a/src/server/clientconnection.cpp +++ b/src/server/clientconnection.cpp @@ -20,6 +20,7 @@ #include "clientconnection.h" #include "display.h" // Qt +#include #include // Wayland #include @@ -40,6 +41,7 @@ pid_t pid = 0; uid_t user = 0; gid_t group = 0; + QString executablePath; private: static void destroyListenerCallback(wl_listener *listener, void *data); @@ -59,6 +61,7 @@ listener.notify = destroyListenerCallback; wl_client_add_destroy_listener(c, &listener); wl_client_get_credentials(client, &pid, &user, &group); + executablePath = QFileInfo(QStringLiteral("/proc/%1/exe").arg(pid)).symLinkTarget(); } ClientConnection::Private::~Private() @@ -145,5 +148,10 @@ return d->user; } +QString ClientConnection::executablePath() const +{ + return d->executablePath; +} + } }