Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 37 additions & 30 deletions src/daemon/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,57 +22,64 @@
#include "Display.h"

#include "Auth.h"
#include "Configuration.h"

Check warning on line 25 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "Configuration.h" not found.
#include "DaemonApp.h"
#include "DisplayManager.h"
#include "XorgDisplayServer.h"
#include "TreelandDisplayServer.h"
#include "Messages.h"

Check warning on line 28 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "Messages.h" not found.
#include "SeatManager.h"
#include "SocketServer.h"
#include "Messages.h"
#include "SocketWriter.h"

Check warning on line 31 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "SocketWriter.h" not found.
#include "TreelandConnector.h"
#include "TreelandDisplayServer.h"
#include "XorgDisplayServer.h"

#include "config.h"

Check warning on line 36 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "config.h" not found.
#include "Login1Manager.h"

Check warning on line 37 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "Login1Manager.h" not found.
#include "VirtualTerminal.h"

#include <QDBusConnection>

Check warning on line 40 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDBusConnection> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QDebug>

Check warning on line 41 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QDebug> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QFile>

Check warning on line 42 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QFile> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>
#include <QLocalSocket>

Check warning on line 43 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLocalSocket> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScopeGuard>

Check warning on line 44 in src/daemon/Display.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QScopeGuard> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QTimer>

#include <fcntl.h>
#include <linux/vt.h>
#include <pwd.h>
#include <qstringliteral.h>
#include <unistd.h>
#include <sys/time.h>

#include <systemd/sd-login.h>
#include <sys/ioctl.h>
#include <fcntl.h>

#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusReply>

#include "Login1Manager.h"
#include "Login1Session.h"
#include "VirtualTerminal.h"
#include "config.h"
#include <sys/time.h>
#include <unistd.h>

#define STRINGIFY(x) #x

namespace DDM {
static bool isTtyInUse(const QString &desiredTty) {
if (Logind::isAvailable()) {
OrgFreedesktopLogin1ManagerInterface manager(Logind::serviceName(), Logind::managerPath(), QDBusConnection::systemBus());
auto reply = manager.ListSessions();
reply.waitForFinished();

const auto info = reply.value();
for(const SessionInfo &s : info) {
OrgFreedesktopLogin1SessionInterface session(Logind::serviceName(), s.sessionPath.path(), QDBusConnection::systemBus());
if (desiredTty == session.tTY() && session.state() != QLatin1String("closing")) {
qDebug() << "tty" << desiredTty << "already in use by" << session.user().path.path() << session.state()
<< session.display() << session.desktop() << session.vTNr();
return true;
}
char **sessions = nullptr;
auto guard = qScopeGuard([&sessions] {
if (sessions) {
for (char **s = sessions; s && *s; ++s)
free(*s);
free(sessions);
}
});
sd_get_sessions(&sessions);
for (char **s = sessions; s && *s; ++s) {
char *tty = nullptr;
char *state = nullptr;
auto guard2 = qScopeGuard([&tty, &state] {
if (tty)
free(tty);
if (state)
free(state);
});
if (sd_session_get_tty(*s, &tty) < 0 || sd_session_get_state(*s, &state) < 0)
continue;
if (desiredTty == tty && strcmp(state, "closing") != 0) {
qDebug() << "tty" << desiredTty << "already in use by session" << *s;
return true;
}
}
return false;
Expand Down