-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Use Lock/Unlock signal from org.freedesktop.login1.Session for session lock #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hi @calsys456. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's GuideImplements session lock/unlock via org.freedesktop.login1 instead of custom LoginSucceeded signaling and refines daemon logging for login, session management, and greeter communication. Sequence diagram for session lock via org.freedesktop.login1sequenceDiagram
actor Greeter
participant SocketServer
participant Display
participant Login1Manager as OrgFreedesktopLogin1ManagerInterface
Greeter->>SocketServer: send GreeterMessages::Lock(id)
SocketServer->>SocketServer: read id from socket
SocketServer->>SocketServer: qDebug Message received from greeter: Lock
SocketServer->>Display: emit lock(socket, id)
Display->>Display: qDebug Lock requested for session id
Display->>Login1Manager: create with Logind::serviceName, Logind::managerPath, system bus
Display->>Login1Manager: LockSession(QString::number(id))
Sequence diagram for session unlock via org.freedesktop.login1sequenceDiagram
actor Greeter
participant SocketServer
participant Display
participant Login1Manager as OrgFreedesktopLogin1ManagerInterface
participant VirtualTerminal
Greeter->>SocketServer: send GreeterMessages::Unlock(user, password)
SocketServer->>SocketServer: read user, password from socket
SocketServer->>Display: emit unlock(socket, user, password)
alt user is dde
Display->>Display: check user == dde
Display-->>SocketServer: emit loginFailed(socket, user)
else normal user
Display->>Display: qInfo Start identify user
Display->>Display: find Auth in auths with auth->user == user and auth->xdgSessionId > 0
alt matching Auth found
Display->>Login1Manager: create with Logind::serviceName, Logind::managerPath, system bus
Display->>Login1Manager: UnlockSession(QString::number(auth->xdgSessionId))
Display->>VirtualTerminal: jumpToVt(auth->tty, false)
Display->>Display: qInfo Successfully identified user
else no matching Auth
Display->>Display: qWarning No active session found for user
Display-->>SocketServer: emit loginFailed(socket, user)
end
end
Updated class diagram for Display, SocketServer and TreelandDisplayServerclassDiagram
class Display {
+connected(socket: QLocalSocket*)
+login(socket: QLocalSocket*, user: QString, password: QString, session: Session)
+logout(socket: QLocalSocket*, id: int)
+lock(socket: QLocalSocket*, id: int)
+unlock(socket: QLocalSocket*, user: QString, password: QString)
<<signal>> loginFailed(socket: QLocalSocket*, user: QString)
-auths: QList~Auth*~
-m_socketServer: SocketServer*
}
class SocketServer {
+informationMessage(socket: QLocalSocket*, message: QString)
+loginFailed(socket: QLocalSocket*, user: QString)
<<signal>> login(socket: QLocalSocket*, user: QString, password: QString, session: Session)
<<signal>> logout(socket: QLocalSocket*, id: int)
<<signal>> lock(socket: QLocalSocket*, id: int)
<<signal>> unlock(socket: QLocalSocket*, user: QString, password: QString)
<<signal>> connected(socket: QLocalSocket*)
}
class TreelandDisplayServer {
+start(socketServer: SocketServer*)
+stop()
+activateUser(user: QString, xdgSessionId: int)
+onLoginFailed(user: QString)
-m_socketServer: SocketServer*
-m_greeterSockets: QList~QLocalSocket*~
}
class GreeterMessages {
<<enum>>
+Lock
+Unlock
+Logout
+Suspend
+Hibernate
+HybridSleep
+BackToNormal
}
class DaemonMessages {
<<enum>>
+HostName
+Capabilities
+LoginFailed
+InformationMessage
+UserActivateMessage
}
class OrgFreedesktopLogin1ManagerInterface {
+LockSession(id: QString)
+UnlockSession(id: QString)
}
Display --> SocketServer : uses
TreelandDisplayServer --> SocketServer : uses
Display --> OrgFreedesktopLogin1ManagerInterface : locks_unlocks_sessions
SocketServer --> GreeterMessages : parses
SocketServer --> DaemonMessages : sends
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've found 1 issue, and left some high level feedback:
- The new lock/unlock paths call login1
LockSession/UnlockSessionsynchronously without checking for DBus errors or unavailable logind; consider usingQDBusPendingReplyor checking the return value and logging/handling failures to avoid silently ignoring issues. - Logging has been made more verbose but is a mix of
qDebug,qInfo, andqWarningfor similar events (e.g., logout vs. lock vs. login); it may be worth standardizing the log levels and including consistent identifiers (session id, user, tty) to make traces easier to follow.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new lock/unlock paths call login1 `LockSession`/`UnlockSession` synchronously without checking for DBus errors or unavailable logind; consider using `QDBusPendingReply` or checking the return value and logging/handling failures to avoid silently ignoring issues.
- Logging has been made more verbose but is a mix of `qDebug`, `qInfo`, and `qWarning` for similar events (e.g., logout vs. lock vs. login); it may be worth standardizing the log levels and including consistent identifiers (session id, user, tty) to make traces easier to follow.
## Individual Comments
### Comment 1
<location> `src/daemon/Display.cpp:307-310` </location>
<code_context>
} 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
</code_context>
<issue_to_address>
**suggestion:** Consider extracting the Treeland shutdown sequence into a helper to avoid duplication.
The `disconnect()`, `m_treeland->stop()`, and `QThread::msleep(500)` pattern is duplicated in both the X11 and non-X11 paths (now with an added log line). Centralizing this sequence in a small helper like `stopTreeland()` would make future changes (e.g., timeout or additional cleanup) safer and keep the behavior aligned across branches.
Suggested implementation:
```cpp
auth->type = X11;
stopTreeland();
// Start X server
```
```cpp
} else {
auth->type = Wayland;
stopTreeland();
```
To fully implement the refactoring, you should also:
1. **Implement the helper in `src/daemon/Display.cpp`**, as a `Display` member function, somewhere near other small helpers:
```cpp
void Display::stopTreeland()
{
qInfo() << "Stopping Treeland";
daemonApp->treelandConnector()->disconnect();
if (m_treeland) {
m_treeland->stop();
}
// Give some time to Treeland to stop properly
QThread::msleep(500);
}
```
2. **Declare the helper in `src/daemon/Display.h`** in the `Display` class, preferably in the `private:` section:
```cpp
private:
void stopTreeland();
// ... existing members
```
3. If `QThread` is not already included in `Display.cpp`, ensure the correct include exists at the top of the file:
```cpp
#include <QThread>
```
These changes will centralize the Treeland shutdown sequence, keep the logging consistent, and make future adjustments (e.g., changing the timeout or adding extra cleanup) safer and easier.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Paired with linuxdeepin/treeland#735 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the daemon↔greeter integration to support explicit session lock handling via logind, removes the now-obsolete “login succeeded” IPC signaling, and refines several daemon log messages for clearer session lifecycle tracing.
Changes:
- Add greeter→daemon
LockIPC path and forward it to logind (LockSession), and route unlock through logind (UnlockSession). - Remove
LoginSucceededmessaging/signals between daemon and greeter/Treeland display server. - Adjust/clarify various informational logs around login/session startup.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/daemon/UserSession.cpp |
Log text updated for Treeland session start. |
src/daemon/TreelandDisplayServer.h |
Removes onLoginSucceeded declaration. |
src/daemon/TreelandDisplayServer.cpp |
Removes onLoginSucceeded implementation and message emission. |
src/daemon/SocketServer.h |
Removes loginSucceeded slot; adds lock signal. |
src/daemon/SocketServer.cpp |
Parses GreeterMessages::Lock and emits lock; removes loginSucceeded reply path. |
src/daemon/Display.h |
Adds lock slot; removes loginSucceeded signal; adjusts slot formatting. |
src/daemon/Display.cpp |
Wires lock signal, adds lock/unlock logind calls, removes Treeland-specific loginSucceeded path, improves logs. |
src/common/Messages.h |
Adds GreeterMessages::Lock; removes DaemonMessages::LoginSucceeded. |
(中文)
本 PR 更新 daemon↔greeter 的交互:通过 logind 支持会话锁定/解锁处理,移除不再需要的 “login succeeded” IPC 信号,并优化若干日志以更清晰地反映会话生命周期。
变更点:
- 新增 greeter→daemon 的
LockIPC,并转发到 logind(LockSession);解锁路径改为通过 logind(UnlockSession)。 - 移除 daemon 与 greeter/TreelandDisplayServer 之间的
LoginSucceeded消息与信号。 - 调整/澄清与登录和会话启动相关的若干日志。
src/daemon/Display.cpp
Outdated
| // some information | ||
| qDebug() << "Session" << session.fileName() << "selected, command:" << session.exec() | ||
| << "for VT" << auth->tty; | ||
| qInfo() << "Authentication succeed for user" << user << ", opening session" |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log message grammar: "Authentication succeed" should be "Authentication succeeded" (or “Authentication succeeded for user …”) to be correct English.
中文:日志语法问题:"Authentication succeed" 语法不正确,建议改为 "Authentication succeeded"(或 “Authentication succeeded for user …”)。
| qInfo() << "Authentication succeed for user" << user << ", opening session" | |
| qInfo() << "Authentication succeeded for user" << user << ", opening session" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
…session lock This is more portable and robustic. Refined the logging system to make them more informative as well.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: calsys456 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1 similar comment
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: calsys456 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This is more portable and robustic.
Refined the logging system to make them more informative as well.
Summary by Sourcery
Integrate session lock and unlock handling with logind and clean up obsolete login success signaling while improving daemon logging clarity.
New Features:
Enhancements: