Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/common/Messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace DDM {
Hibernate,
HybridSleep,
BackToNormal,
Lock,
Unlock,
Logout,
};
Expand All @@ -45,7 +46,6 @@ namespace DDM {
enum class DaemonMessages {
HostName,
Capabilities,
LoginSucceeded,
LoginFailed,
InformationMessage,
UserActivateMessage,
Expand Down
48 changes: 30 additions & 18 deletions src/daemon/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ namespace DDM {
// connect logout signal
connect(m_socketServer, &SocketServer::logout, this, &Display::logout);

// connect lock signal
connect(m_socketServer, &SocketServer::lock, this, &Display::lock);

// connect unlock signal
connect(m_socketServer, &SocketServer::unlock,this, &Display::unlock);

// connect login result signals
connect(this, &Display::loginFailed, m_socketServer, &SocketServer::loginFailed);
connect(this, &Display::loginSucceeded, m_socketServer, &SocketServer::loginSucceeded);
}

Display::~Display() {
Expand Down Expand Up @@ -206,10 +208,13 @@ namespace DDM {
const QString &user, const QString &password,
const Session &session) {
if (user == QLatin1String("dde")) {
qWarning() << "Login attempt for user dde";
emit loginFailed(socket, user);
return;
}

qInfo() << "Start login user" << user;

// Get Auth object
Auth *auth = nullptr;
for (auto *item : std::as_const(auths)) {
Expand Down Expand Up @@ -252,8 +257,8 @@ namespace DDM {
}

// some information
qDebug() << "Session" << session.fileName() << "selected, command:" << session.exec()
<< "for VT" << auth->tty;
qInfo() << "Authentication succeed for user" << user << ", opening session"
<< session.fileName() << ", command:" << session.exec() << ", VT:" << auth->tty;

// save last user and last session
DaemonApp::instance()->displayManager()->setLastActivatedUser(user);
Expand Down Expand Up @@ -299,11 +304,13 @@ namespace DDM {
} else if (session.xdgSessionType() == QLatin1String("x11")) {
auth->type = X11;

qInfo() << "Stopping Treeland";
daemonApp->treelandConnector()->disconnect();
m_treeland->stop();
QThread::msleep(500); // give some time to treeland to stop properly

// Start X server
qInfo() << "Starting X11 display server";
m_x11Server = new XorgDisplayServer(this);
connect(m_x11Server, &XorgDisplayServer::stopped, this, &Display::stop);
if (!m_x11Server->start(auth->tty)) {
Expand All @@ -317,6 +324,7 @@ namespace DDM {
} else {
auth->type = Wayland;

qInfo() << "Stopping Treeland";
daemonApp->treelandConnector()->disconnect();
m_treeland->stop();
QThread::msleep(500); // give some time to treeland to stop properly
Expand All @@ -331,12 +339,6 @@ namespace DDM {
return;
}

if (auth->type == Treeland) {
Q_EMIT loginSucceeded(socket, user);
// Tell Treeland to enter the session
activateSession(auth->user, xdgSessionId);
}

connect(auth, &Auth::sessionFinished, this, [this, auth]() {
qWarning() << "Session for user" << auth->user << "finished";
auths.removeAll(auth);
Expand All @@ -349,9 +351,11 @@ namespace DDM {
// The user process is ongoing, append to active auths
// The auth will be delete later in userProcessFinished()
auths << auth;
qInfo() << "Successfully logged in user" << user;
}

void Display::logout([[maybe_unused]] QLocalSocket *socket, int id) {
qDebug() << "Logout requested for session id" << id;
// Do not kill the session leader process before
// TerminateSession! Logind will only kill the session's
// cgroup (session_stop_scope) when the session is not in
Expand All @@ -365,13 +369,22 @@ namespace DDM {
manager.TerminateSession(QString::number(id));
}

void Display::lock([[maybe_unused]] QLocalSocket *socket, int id) {
qDebug() << "Lock requested for session id" << id;

OrgFreedesktopLogin1ManagerInterface manager(Logind::serviceName(),
Logind::managerPath(),
QDBusConnection::systemBus());
manager.LockSession(QString::number(id));
}

void Display::unlock(QLocalSocket *socket, const QString &user, const QString &password) {
if (user == QLatin1String("dde")) {
emit loginFailed(socket, user);
return;
}

qDebug() << "Start identify user" << user;
qInfo() << "Start identify user" << user;

// Only run password check
//
Expand All @@ -394,17 +407,16 @@ namespace DDM {
// Find the auth that started the session, which contains full informations
for (auto *auth : std::as_const(auths)) {
if (auth->user == user && auth->xdgSessionId > 0) {
if (auth->type == Treeland) {
// TODO: Use exact ID when there're multiple sessions for a user
// TODO: Jump to auth->tty
Q_EMIT loginSucceeded(socket, user);
activateSession(user, auth->xdgSessionId);
} else {
VirtualTerminal::jumpToVt(auth->tty, false);
}
OrgFreedesktopLogin1ManagerInterface manager(Logind::serviceName(),
Logind::managerPath(),
QDBusConnection::systemBus());
manager.UnlockSession(QString::number(auth->xdgSessionId));
VirtualTerminal::jumpToVt(auth->tty, false);
qInfo() << "Successfully identified user" << user;
return;
}
}
qWarning() << "No active session found for user" << user;
Q_EMIT loginFailed(socket, user);
}
}
11 changes: 5 additions & 6 deletions src/daemon/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ namespace DDM {

void connected(QLocalSocket *socket);
void login(QLocalSocket *socket,
const QString &user, const QString &password,
const QString &user,
const QString &password,
const Session &session);
void logout(QLocalSocket *socket,
int id);
void unlock(QLocalSocket *socket,
const QString &user, const QString &password);
void logout(QLocalSocket *socket, int id);
void lock(QLocalSocket *socket, int id);
void unlock(QLocalSocket *socket, const QString &user, const QString &password);

signals:
/** Emitted when stop() */
Expand All @@ -116,7 +116,6 @@ namespace DDM {
/////////////////////////////////////////////////////

void loginFailed(QLocalSocket *socket, const QString &user);
void loginSucceeded(QLocalSocket *socket, const QString &user);

private:
/** Indicates whether the display is started */
Expand Down
13 changes: 9 additions & 4 deletions src/daemon/SocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ namespace DDM {
emit logout(socket, id);
}
break;
case GreeterMessages::Lock : {
// log message
qDebug() << "Message received from greeter: Lock";
int id;

input >> id;
emit lock(socket, id);
}
break;
case GreeterMessages::Unlock : {
// log message
qDebug() << "Message received from greeter: Unlock";
Expand Down Expand Up @@ -232,10 +241,6 @@ namespace DDM {
SocketWriter(socket) << quint32(DaemonMessages::LoginFailed) << user;
}

void SocketServer::loginSucceeded(QLocalSocket *socket, const QString &user) {
SocketWriter(socket) << quint32(DaemonMessages::LoginSucceeded) << user;
}

void SocketServer::informationMessage(QLocalSocket *socket, const QString &message) {
SocketWriter(socket) << quint32(DaemonMessages::InformationMessage) << message;
}
Expand Down
3 changes: 2 additions & 1 deletion src/daemon/SocketServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ namespace DDM {
public slots:
void informationMessage(QLocalSocket *socket, const QString &message);
void loginFailed(QLocalSocket *socket, const QString &user);
void loginSucceeded(QLocalSocket *socket, const QString &user);

signals:
void login(QLocalSocket *socket,
const QString &user, const QString &password,
const Session &session);
void logout(QLocalSocket *socket,
int id);
void lock(QLocalSocket *socket,
int id);
void unlock(QLocalSocket *socket,
const QString &user, const QString &password);
void connected(QLocalSocket *socket);
Expand Down
6 changes: 0 additions & 6 deletions src/daemon/TreelandDisplayServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,3 @@ void TreelandDisplayServer::onLoginFailed(const QString &user) {
SocketWriter(greeter) << quint32(DaemonMessages::LoginFailed) << user;
}
}

void TreelandDisplayServer::onLoginSucceeded(const QString &user) {
for (auto greeter : m_greeterSockets) {
SocketWriter(greeter) << quint32(DaemonMessages::LoginSucceeded) << user;
}
}
1 change: 0 additions & 1 deletion src/daemon/TreelandDisplayServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace DDM {
void stop();
void activateUser(const QString &user, int xdgSessionId);
void onLoginFailed(const QString &user);
void onLoginSucceeded(const QString &user);

private:
SocketServer *m_socketServer;
Expand Down
2 changes: 1 addition & 1 deletion src/daemon/UserSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace DDM {
case Display::Treeland: {
setProgram(mainConfig.Single.SessionCommand.get());
setArguments(QStringList{ command });
qInfo() << "Starting Wayland user session:" << program() << command;
qInfo() << "Starting Treeland session:" << program() << command;
QProcess::start();
closeWriteChannel();
closeReadChannel(QProcess::StandardOutput);
Expand Down