-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Add logout cleanup #47
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
Conversation
This commit exposes an interface to treeland to terminate systemd session with priviledge.
|
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 GuideThis PR adds a privileged logout workflow by wiring a new Logout message from the greeter through SocketServer to Display, where a D-Bus-based cleanup terminates the user’s systemd sessions. Sequence diagram for the new privileged logout workflowsequenceDiagram
actor Greeter
participant SocketServer
participant Display
participant "org.freedesktop.login1.Manager"
participant "org.freedesktop.login1.Session"
Greeter->>SocketServer: Send Logout message (with username)
SocketServer->>Display: emit logout(socket, user)
Display->>"org.freedesktop.login1.Manager": ListSessions()
"org.freedesktop.login1.Manager"-->>Display: Return sessions
loop For each session of user
Display->>"org.freedesktop.login1.Session": Terminate (if session is active)
end
Entity relationship diagram for GreeterMessages enum updateerDiagram
GreeterMessages {
int ActivateUser
int BackToNormal
int Unlock
int Logout
}
Class diagram for updated Display and SocketServer classesclassDiagram
class SocketServer {
+login(QLocalSocket*, QString, QString, Session)
+logout(QLocalSocket*, QString)
+unlock(QLocalSocket*, QString, QString)
+connected(QLocalSocket*)
<<signal>> logout(QLocalSocket*, QString)
}
class Display {
+login(QLocalSocket*, QString, QString, Session)
+logout(QLocalSocket*, QString)
+unlock(QLocalSocket*, QString, QString)
+attemptAutologin()
+logout(QLocalSocket*, QString) // new method
}
class org_freedesktop_login1_Manager
class org_freedesktop_login1_Session
SocketServer --> Display : emits logout signal
Display ..> org_freedesktop_login1_Manager : uses D-Bus interface
Display ..> org_freedesktop_login1_Session : uses D-Bus interface
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 there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/daemon/Display.cpp:402-403` </location>
<code_context>
startAuth(user, password, session);
}
+ void Display::logout([[maybe_unused]] QLocalSocket *socket, const QString &user) {
+ struct passwd *pw = getpwnam(user.toLocal8Bit().data());
+ QDBusInterface managerInterface("org.freedesktop.login1",
+ "/org/freedesktop/login1",
</code_context>
<issue_to_address>
**issue (bug_risk):** Check for null return value from getpwnam to avoid possible crash.
Add a null check for pw after getpwnam and handle the error to prevent undefined behavior.
</issue_to_address>
### Comment 2
<location> `src/daemon/Display.cpp:408-410` </location>
<code_context>
+ "/org/freedesktop/login1",
+ "org.freedesktop.login1.Manager",
+ QDBusConnection::systemBus());
+ QDBusReply<QList<SessionInfo>> sessions = managerInterface.call("ListSessions");
+ QStringList userSessions;
+ for (const SessionInfo &session : sessions.value())
+ // TODO multiple seats.
+ if (session.userId == pw->pw_uid && !session.seatId.isEmpty())
</code_context>
<issue_to_address>
**issue (bug_risk):** Handle possible DBus call failure for ListSessions.
Check sessions.isValid() before using sessions.value() to prevent issues if the DBus call fails.
</issue_to_address>
### Comment 3
<location> `src/daemon/Display.cpp:422-423` </location>
<code_context>
+ sessionPath,
+ "org.freedesktop.login1.Session",
+ QDBusConnection::systemBus());
+ if (sessionInterface.property("Active").toBool())
+ sessionInterface.call("Terminate");
+ }
+ }
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Check for DBus call success when terminating sessions.
Check the result of sessionInterface.call("Terminate") and handle any errors to improve reliability.
```suggestion
if (sessionInterface.property("Active").toBool()) {
QDBusReply<void> terminateReply = sessionInterface.call("Terminate");
if (!terminateReply.isValid()) {
qWarning() << "Failed to terminate session at" << sessionPath << ":" << terminateReply.error().message();
}
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
In this commit we extract systemd-logind session ID after user logged in, and send it to treeland as a necessary info for current user session. And we fixed some misbehaviour btw.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: calsys456, zccrs 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 commit exposes an interface to treeland to terminate systemd session with priviledge.
Summary by Sourcery
Add a logout cleanup feature by extending the IPC protocol with a Logout message, wiring it through the daemon, and using the systemd logind D-Bus API to terminate the user’s active sessions on logout.
New Features: