Skip to content

feat: delegate Treeland sessions to authentication service - #126

Open
fly602 wants to merge 1 commit into
linuxdeepin:masterfrom
fly602:feat/da-login-service
Open

fly602 wants to merge 1 commit into
linuxdeepin:masterfrom
fly602:feat/da-login-service

Conversation

@fly602

@fly602 fly602 commented Dec 3, 2026 •

Copy link
Copy Markdown

Summary

  • Route Treeland authentication and desktop launch through the standalone DA login service.
  • Add an asynchronous Qt D-Bus client with credential/namespace FD transport.
  • Preserve seat and grouped-VT ownership across login, logout and service recovery.
  • Retain existing non-Treeland helper paths; do not fall back to local PAM on DA failure.

Service dependency

DA implementation: https://gerrit.uniontech.com/c/deepin-authentication/+/431667
Bus interface: org.deepin.dde.Authenticate1.LoginManager.
PMS: TASK-399545.

Verification

  • Built ddm, ddm-helper and tst_dasessionclient locally with CMake, Ninja and -Werror.
  • Ran isolated DA client tests: dasessionclient passed 1/1.
  • The final added reconnect-retention test code was not rerun locally after the user requested no more current-environment testing.
  • No real root PAM/Treeland login, installation or virtual-machine verification was performed.

Review scope

Review the login/session lifecycle, FD handling, root service boundary, autologin/unlock behavior and grouped-VT cleanup before merging.

Summary by Sourcery

Delegate Treeland authentication and desktop session management to the DA login service while preserving existing non-Treeland helper behavior.

New Features:

  • Route Treeland login, autologin, desktop launch, and unlock credential verification through the standalone DA authentication service.
  • Discover and adopt DA-managed Treeland sessions after display restart, preserving their session registration and grouped-VT ownership.

Bug Fixes:

  • Avoid treating an accepted Treeland launch as failed or releasing its grouped VT until DA confirms cleanup, including across service recovery.

Enhancements:

  • Keep existing helper-backed authentication and session launch paths for non-Treeland displays while making login and unlock handling asynchronous.
  • Preserve active Treeland sessions when DDM or a display shuts down, and reconcile their lifecycle when a display reconnects.

Tests:

  • Add isolated D-Bus client tests covering authentication, credential and namespace FD transport, launch, failures, cancellation, and broker-restart recovery.

Chores:

  • Add CTest integration and a Qt Test target for the DA session client.
  • Update DDM configuration, Debian dependency metadata, and the systemd service template.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

API

Define the DA session client and Auth interfaces, including the managed-session data passed between recovery and login code.

  • src/daemon/Auth.h L59-68, L97-101 (+3 small edits)
  • src/daemon/DASessionClient.h L1-108

Uses of the API

Use the asynchronous Auth lifecycle to coordinate login, unlock, managed-session recovery, and grouped-VT ownership across display shutdown.

  • src/daemon/Display.cpp L210-274, L356-590, L737-806 (+13 small edits)
  • src/daemon/Display.h L29-30, L128-146, L168-175

Implementation

Implement asynchronous DA authentication and session operations, credential and namespace FD transport, recovery, and the Auth bridge while retaining helper-backed non-Treeland behavior.

  • src/daemon/Auth.cpp L90-95, L232-235, L394-519 (+5 small edits)
  • src/daemon/DASessionClient.cpp L1-755

Configuration

Enable the test build and wire in the DA client source and updated package, service, and DConfig settings for deployment.

  • CMakeLists.txt L175-179
  • data/dconfig/org.deepin.dde.ddm.json.in L171-177
  • debian/control L31
  • services/ddm.service.in L5, L11
  • src/daemon/CMakeLists.txt L32

Tests

Exercise DA authentication, FD exchange, launch and failure handling, plus service recovery and managed-session adoption on a private D-Bus.

  • tests/CMakeLists.txt L1-11
  • tests/tst_dasessionclient.cpp L1-782

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 11 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/daemon/Auth.cpp" line_range="400" />
<code_context>
+            return d->da;
+        d->da = new DASessionClient(this);
+        connect(d->da, &DASessionClient::authenticationFinished, this, [this](bool success) {
+            sessionId = d->da->sessionId();
+            authenticated = success;
+            Q_EMIT authenticationFinished(success);
</code_context>
<issue_to_address>
**Grouped VT loses its session identity**

When a Treeland login succeeds through DA, `prepareUserSession()` creates the grouped VT with the generated `auth->sessionId`, then the authentication callback replaces that ID with the DA object-path ID. `registerSession` and cleanup use the replacement, so seatd/VT ownership lookups cannot match the registered session and cleanup can miss the grouped VT.

Keep the session ID used to create the grouped VT consistent with the ID used for DA registration and cleanup.

Also at `src/daemon/Display.cpp:346`.
</issue_to_address>

### Comment 2
<location path="src/daemon/Display.cpp" line_range="527" />
<code_context>
+        if (m_stopping || !m_started)
+            return;
+        const QPointer<Display> display(this);
+        const auto sessions = Auth::managedSessions(name);
+        if (!display || !m_started)
+            return;
</code_context>
<issue_to_address>
**Adopts sessions it does not own**

When a separate DA client has a live session on the same seat, another client creates a valid DA session on this seat, so `reconcileManagedSessions` adopts it without checking who created it and records its VT as locally owned. When that session ends, `removeAuth` calls `destroyGroupVt` for the adopted VT, disrupting a session whose VT this DDM did not allocate.

Restrict recovery to sessions verifiably created by this DDM instance, and only destroy grouped VTs that DDM allocated or explicitly took ownership of.

Also at `src/daemon/Display.cpp:565`.
</issue_to_address>

### Comment 3
<location path="src/daemon/Auth.cpp" line_range="465" />
<code_context>
+        }
+        if (!d->da)
+            return;
+        if (!daemonApp->seatdControl()->requestSwitchVt(tty)) {
+            d->da->cancel();
+            authenticated = false;
</code_context>
<issue_to_address>
**Failed launch hides greeter**

When DA rejects the start or the launch fails after the user VT has been selected, `requestSwitchVt(tty)` moves the display to the user VT before DA accepts the session start. If the start then fails, `failLogin` sends `ShowGreeter` without switching back to the greeter VT, so the greeter remains off-screen.

Switch back to the greeter VT when a Treeland launch fails and the greeter connection is still active.
</issue_to_address>

### Comment 4
<location path="src/daemon/DASessionClient.cpp" line_range="719-730" />
<code_context>
+        return sessions;
+    QElapsedTimer budget;
+    budget.start();
+    QDBusReply<QList<QDBusObjectPath>> list(connection.call(message(root, QStringLiteral("ListSessions")), QDBus::Block, 1000));
+    if (!list.isValid() || list.value().size() > 128)
+        return sessions;
+    for (const auto &path : list.value()) {
+        const auto remaining = 3000 - budget.elapsed();
+        if (remaining <= 0)
+            break;
+        if (stableSessionId(path.path()).isEmpty())
+            continue;
+        QDBusReply<QVariantMap> reply(connection.call(message(path.path(), QStringLiteral("GetInfo")), QDBus::Block,
+                                                    static_cast<int>(qMin<qint64>(1000, remaining))));
+        ManagedSessionInfo info;
+        if (reply.isValid() && decodeInfo(path.path(), reply.value(), info, true) && info.seat == seat)
+            sessions.append(info);
</code_context>
<issue_to_address>
**Slow DA calls stall the daemon**

When the DA service responds slowly to session-list or metadata requests, `DASessionClient::managedSessions()` makes blocking D-Bus calls on the daemon event-loop thread, and `Display::connected` runs this scan before replying to the greeter. The calls can stall greeter connections and other daemon event processing for up to three seconds.

Make the DA session enumeration nonblocking on the daemon event-loop thread.

Also at `src/daemon/Display.cpp:205`, `src/daemon/Display.cpp:266`, `src/daemon/Display.cpp:527`.
</issue_to_address>

### Comment 5
<location path="src/daemon/Auth.cpp" line_range="478" />
<code_context>
+            delete d->da;
+            d->da = nullptr;
+            return;
+        }
         if (sessionOpened) {
             if (sessionPid > 0)
</code_context>
<issue_to_address>
**Wrapped desktops fail to launch**

When `singleSessionCommand` is configured and the desktop command contains arguments, `openSessionAsync` appends the entire desktop command as one argument to the wrapper. When the desktop command contains arguments and the wrapper executes its arguments as an argv vector, it receives a single executable name containing spaces and the DA session fails to start.

Append `QProcess::splitCommand(command)` to the wrapper argv, or explicitly implement and test the wrapper’s intended command-string interface.
</issue_to_address>

### Comment 6
<location path="src/daemon/Display.cpp" line_range="318" />
<code_context>
+            // DASessionClient cancels unfinished attempts and detaches running sessions.
+            delete d->da;
+            d->da = nullptr;
+            return;
+        }
         if (sessionOpened) {
</code_context>
<issue_to_address>
**Duplicate requests get no reply**

When a second login for the same user or unlock for the same session arrives on a separate socket while the first request is pending, the duplicate login or unlock request returns without emitting `loginFailed` or another result. `SocketServer::loginFailed` is the response path, so a caller on a separate socket waits indefinitely while the first request is in progress.

Send an explicit failure or pending response to each rejected duplicate request.

Also at `src/daemon/Display.cpp:746`.
</issue_to_address>

### Comment 7
<location path="src/daemon/Display.cpp" line_range="684" />
<code_context>
+            return d->da && d->da->stop();
         if (!sessionOpened) {
             qWarning() << "[Auth] closeSession: Session was not opened.";
             return true;
</code_context>
<issue_to_address>
**Reconnect hangs during autologin**

When a Treeland connection arrives while the first connection’s asynchronous autologin is still pending, `startAutologin` returns true for an already-pending login, so `connected` returns without writing a response to the new socket; that greeter connection waits without receiving `ShowGreeter` or a login result.

Send the appropriate current/pending-login response to the new connection, or do not treat an already-pending autologin as a handled connection.
</issue_to_address>

### Comment 8
<location path="src/daemon/DASessionClient.cpp" line_range="345" />
<code_context>
+    if (m_phase != Phase::Authenticated)
+        return;
+    m_phase = Phase::Starting;
+    if (argv.isEmpty() || !argv.first().startsWith(QLatin1Char('/')) || argv.first() == QLatin1String("/")
+            || argv.size() > 128 || namespacePaths.size() > 16 || environment.size() > 128) {
+        fail(QStringLiteral("Invalid DA start payload"));
</code_context>
<issue_to_address>
**Valid session commands are rejected**

When a Treeland session entry uses a bare executable name in `Exec` and no wrapper is configured, `Session::exec()` is passed through as the launch command, but `DASessionClient::start()` rejects it unless its first token is an absolute path. Valid desktop entries whose `Exec` names a program found through `PATH` therefore fail to launch when the optional wrapper is empty, and the login is reported as failed.

Resolve the executable against the session’s configured `PATH` before calling `start()`, or support `PATH` lookup at the trusted launch boundary.
</issue_to_address>

### Comment 9
<location path="tests/tst_dasessionclient.cpp" line_range="510-516" />
<code_context>
+        }), authenticating), 2000);
+        onBackend([](SyntheticManager &manager) {
+            manager.session.state = QStringLiteral("failed");
+            Q_EMIT manager.session.StateChanged(manager.session.state);
+            Q_EMIT manager.session.Failed(QStringLiteral("account"), 13, QStringLiteral("Account expired"));
+        });
+        QTRY_COMPARE_WITH_TIMEOUT(result.count(), 1, 2000);
+        QVERIFY(!result.first().first().toBool());
+        QVERIFY(!messages.isEmpty());
+    }
+
+    void destructionDuringCreateCancelsReturnedObject()
</code_context>
<issue_to_address>
**PAM failure detail goes unchecked**

When the client stops processing `Failed` signals but still handles `StateChanged("failed")`, the `accountPolicyFailureSignal` test still passes because `stateChanged("failed")` independently schedules a generic failure, while lines 514–515 accept any nonempty message; losing the account-specific `Failed` detail is not detected.

Assert that the information message contains `Account expired`.
</issue_to_address>

### Comment 10
<location path="tests/tst_dasessionclient.cpp" line_range="409-410" />
<code_context>
+        DASessionClient client(*clientBus);
+        QSignalSpy result(&client, &DASessionClient::authenticationFinished);
+        client.authenticate(QStringLiteral("alice"), QStringLiteral("login"), QStringLiteral("seat0"), 7, QByteArray("password"));
+        QTRY_COMPARE_WITH_TIMEOUT(result.count(), 1, 2000);
+        QVERIFY(!result.first().first().toBool());
+        QVERIFY(!client.isBusy());
+    }
+
+    void startFailure()
+    {
+        onBackend([](SyntheticManager &manager) { manager.session.rejectStart = true; });
+        DASessionClient client(*clientBus);
+        authenticate(client);
+        QSignalSpy result(&client, &DASessionClient::sessionStartFailed);
+        QSignalSpy started(&client, &DASessionClient::sessionStarted);
+        client.start({QStringLiteral("/usr/bin/desktop")}, {}, {}, QString());
+        QTRY_COMPARE_WITH_TIMEOUT(result.count(), 1, 2000);
+        QCOMPARE(started.count(), 0);
+    }
+
</code_context>
<issue_to_address>
**Rejected start is not verified**

When the client reports a local start failure without submitting the DA `Start` request, the `startFailure` test passes if `start()` emits `sessionStartFailed` without calling the service: lines 409–410 assert only failure and no start, and never check that the fixture received a `Start` request.

Assert that the fixture received exactly one `Start` request before accepting the failure result.
</issue_to_address>

### Comment 11
<location path="src/daemon/Auth.cpp" line_range="434-437" />
<code_context>
+        if (isBusy() || authenticated || sessionOpened || d->da)
+            return;
+        if (type == Display::Treeland) {
+            ensureDAClient()->authenticate(user, pamService == QLatin1String("ddm-autologin")
+                                          ? QStringLiteral("autologin") : QStringLiteral("login"),
+                                          seat, tty > 0 ? static_cast<quint32>(tty) : 0, secret);
+            return;
+        }
+        d->busy = true;
</code_context>
<issue_to_address>
**Treeland bypasses documented UserSession path**

When a login uses Treeland, for Treeland, `Auth::authenticateAsync` authenticates through `DASessionClient`, and `openSessionAsync` launches through DA instead of `UserSession`, so the documented login path is false for every Treeland login.

Update kb-965847 to describe DA-managed Treeland authentication and session launch while retaining the `UserSession` path for other display types.

Also at `src/daemon/Auth.cpp:490`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/daemon/Auth.cpp
return d->da;
d->da = new DASessionClient(this);
connect(d->da, &DASessionClient::authenticationFinished, this, [this](bool success) {
sessionId = d->da->sessionId();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Grouped VT loses its session identity

When a Treeland login succeeds through DA, prepareUserSession() creates the grouped VT with the generated auth->sessionId, then the authentication callback replaces that ID with the DA object-path ID. registerSession and cleanup use the replacement, so seatd/VT ownership lookups cannot match the registered session and cleanup can miss the grouped VT.

Keep the session ID used to create the grouped VT consistent with the ID used for DA registration and cleanup.

Also at src/daemon/Display.cpp:346.

Prompt for AI agents
In `src/daemon/Auth.cpp` at line 400:

**Grouped VT loses its session identity**

When a Treeland login succeeds through DA, `prepareUserSession()` creates the grouped VT with the generated `auth->sessionId`, then the authentication callback replaces that ID with the DA object-path ID. `registerSession` and cleanup use the replacement, so seatd/VT ownership lookups cannot match the registered session and cleanup can miss the grouped VT.

Keep the session ID used to create the grouped VT consistent with the ID used for DA registration and cleanup.

Also at `src/daemon/Display.cpp:346`.

Comment thread src/daemon/Display.cpp
if (m_stopping || !m_started)
return;
const QPointer<Display> display(this);
const auto sessions = Auth::managedSessions(name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Adopts sessions it does not own

When a separate DA client has a live session on the same seat, another client creates a valid DA session on this seat, so reconcileManagedSessions adopts it without checking who created it and records its VT as locally owned. When that session ends, removeAuth calls destroyGroupVt for the adopted VT, disrupting a session whose VT this DDM did not allocate.

Restrict recovery to sessions verifiably created by this DDM instance, and only destroy grouped VTs that DDM allocated or explicitly took ownership of.

Also at src/daemon/Display.cpp:565.

Prompt for AI agents
In `src/daemon/Display.cpp` at line 527:

**Adopts sessions it does not own**

When a separate DA client has a live session on the same seat, another client creates a valid DA session on this seat, so `reconcileManagedSessions` adopts it without checking who created it and records its VT as locally owned. When that session ends, `removeAuth` calls `destroyGroupVt` for the adopted VT, disrupting a session whose VT this DDM did not allocate.

Restrict recovery to sessions verifiably created by this DDM instance, and only destroy grouped VTs that DDM allocated or explicitly took ownership of.

Also at `src/daemon/Display.cpp:565`.

Comment thread src/daemon/Auth.cpp
}
if (!d->da)
return;
if (!daemonApp->seatdControl()->requestSwitchVt(tty)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Failed launch hides greeter

When DA rejects the start or the launch fails after the user VT has been selected, requestSwitchVt(tty) moves the display to the user VT before DA accepts the session start. If the start then fails, failLogin sends ShowGreeter without switching back to the greeter VT, so the greeter remains off-screen.

Switch back to the greeter VT when a Treeland launch fails and the greeter connection is still active.

Prompt for AI agents
In `src/daemon/Auth.cpp` at line 465:

**Failed launch hides greeter**

When DA rejects the start or the launch fails after the user VT has been selected, `requestSwitchVt(tty)` moves the display to the user VT before DA accepts the session start. If the start then fails, `failLogin` sends `ShowGreeter` without switching back to the greeter VT, so the greeter remains off-screen.

Switch back to the greeter VT when a Treeland launch fails and the greeter connection is still active.

Comment on lines +719 to +730
QDBusReply<QList<QDBusObjectPath>> list(connection.call(message(root, QStringLiteral("ListSessions")), QDBus::Block, 1000));
if (!list.isValid() || list.value().size() > 128)
return sessions;
for (const auto &path : list.value()) {
const auto remaining = 3000 - budget.elapsed();
if (remaining <= 0)
break;
if (stableSessionId(path.path()).isEmpty())
continue;
QDBusReply<QVariantMap> reply(connection.call(message(path.path(), QStringLiteral("GetInfo")), QDBus::Block,
static_cast<int>(qMin<qint64>(1000, remaining))));
ManagedSessionInfo info;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Slow DA calls stall the daemon

When the DA service responds slowly to session-list or metadata requests, DASessionClient::managedSessions() makes blocking D-Bus calls on the daemon event-loop thread, and Display::connected runs this scan before replying to the greeter. The calls can stall greeter connections and other daemon event processing for up to three seconds.

Make the DA session enumeration nonblocking on the daemon event-loop thread.

Also at src/daemon/Display.cpp:205, src/daemon/Display.cpp:266, src/daemon/Display.cpp:527.

Prompt for AI agents
In `src/daemon/DASessionClient.cpp` at lines 719-730:

**Slow DA calls stall the daemon**

When the DA service responds slowly to session-list or metadata requests, `DASessionClient::managedSessions()` makes blocking D-Bus calls on the daemon event-loop thread, and `Display::connected` runs this scan before replying to the greeter. The calls can stall greeter connections and other daemon event processing for up to three seconds.

Make the DA session enumeration nonblocking on the daemon event-loop thread.

Also at `src/daemon/Display.cpp:205`, `src/daemon/Display.cpp:266`, `src/daemon/Display.cpp:527`.

Comment thread src/daemon/Auth.cpp
} else {
argv = QProcess::splitCommand(wrapper);
argv.append(command);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Wrapped desktops fail to launch

When singleSessionCommand is configured and the desktop command contains arguments, openSessionAsync appends the entire desktop command as one argument to the wrapper. When the desktop command contains arguments and the wrapper executes its arguments as an argv vector, it receives a single executable name containing spaces and the DA session fails to start.

Append QProcess::splitCommand(command) to the wrapper argv, or explicitly implement and test the wrapper’s intended command-string interface.

Prompt for AI agents
In `src/daemon/Auth.cpp` at line 478:

**Wrapped desktops fail to launch**

When `singleSessionCommand` is configured and the desktop command contains arguments, `openSessionAsync` appends the entire desktop command as one argument to the wrapper. When the desktop command contains arguments and the wrapper executes its arguments as an argv vector, it receives a single executable name containing spaces and the DA session fails to start.

Append `QProcess::splitCommand(command)` to the wrapper argv, or explicitly implement and test the wrapper’s intended command-string interface.

Comment thread src/daemon/Display.cpp
if (auth->user == user
&& (m_pendingLogins.contains(auth) || auth->isBusy()
|| auth->authenticated || auth->sessionOpened))
return true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Reconnect hangs during autologin

When a Treeland connection arrives while the first connection’s asynchronous autologin is still pending, startAutologin returns true for an already-pending login, so connected returns without writing a response to the new socket; that greeter connection waits without receiving ShowGreeter or a login result.

Send the appropriate current/pending-login response to the new connection, or do not treat an already-pending autologin as a handled connection.

Prompt for AI agents
In `src/daemon/Display.cpp` at line 684:

**Reconnect hangs during autologin**

When a Treeland connection arrives while the first connection’s asynchronous autologin is still pending, `startAutologin` returns true for an already-pending login, so `connected` returns without writing a response to the new socket; that greeter connection waits without receiving `ShowGreeter` or a login result.

Send the appropriate current/pending-login response to the new connection, or do not treat an already-pending autologin as a handled connection.

if (m_phase != Phase::Authenticated)
return;
m_phase = Phase::Starting;
if (argv.isEmpty() || !argv.first().startsWith(QLatin1Char('/')) || argv.first() == QLatin1String("/")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Valid session commands are rejected

When a Treeland session entry uses a bare executable name in Exec and no wrapper is configured, Session::exec() is passed through as the launch command, but DASessionClient::start() rejects it unless its first token is an absolute path. Valid desktop entries whose Exec names a program found through PATH therefore fail to launch when the optional wrapper is empty, and the login is reported as failed.

Resolve the executable against the session’s configured PATH before calling start(), or support PATH lookup at the trusted launch boundary.

Prompt for AI agents
In `src/daemon/DASessionClient.cpp` at line 345:

**Valid session commands are rejected**

When a Treeland session entry uses a bare executable name in `Exec` and no wrapper is configured, `Session::exec()` is passed through as the launch command, but `DASessionClient::start()` rejects it unless its first token is an absolute path. Valid desktop entries whose `Exec` names a program found through `PATH` therefore fail to launch when the optional wrapper is empty, and the login is reported as failed.

Resolve the executable against the session’s configured `PATH` before calling `start()`, or support `PATH` lookup at the trusted launch boundary.

Comment on lines +510 to +516
Q_EMIT manager.session.StateChanged(manager.session.state);
Q_EMIT manager.session.Failed(QStringLiteral("account"), 13, QStringLiteral("Account expired"));
});
QTRY_COMPARE_WITH_TIMEOUT(result.count(), 1, 2000);
QVERIFY(!result.first().first().toBool());
QVERIFY(!messages.isEmpty());
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · PAM failure detail goes unchecked

When the client stops processing Failed signals but still handles StateChanged("failed"), the accountPolicyFailureSignal test still passes because stateChanged("failed") independently schedules a generic failure, while lines 514–515 accept any nonempty message; losing the account-specific Failed detail is not detected.

Assert that the information message contains Account expired.

Prompt for AI agents
In `tests/tst_dasessionclient.cpp` at lines 510-516:

**PAM failure detail goes unchecked**

When the client stops processing `Failed` signals but still handles `StateChanged("failed")`, the `accountPolicyFailureSignal` test still passes because `stateChanged("failed")` independently schedules a generic failure, while lines 514–515 accept any nonempty message; losing the account-specific `Failed` detail is not detected.

Assert that the information message contains `Account expired`.

Comment on lines +409 to +410
QTRY_COMPARE_WITH_TIMEOUT(result.count(), 1, 2000);
QCOMPARE(started.count(), 0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Rejected start is not verified

When the client reports a local start failure without submitting the DA Start request, the startFailure test passes if start() emits sessionStartFailed without calling the service: lines 409–410 assert only failure and no start, and never check that the fixture received a Start request.

Assert that the fixture received exactly one Start request before accepting the failure result.

Prompt for AI agents
In `tests/tst_dasessionclient.cpp` at lines 409-410:

**Rejected start is not verified**

When the client reports a local start failure without submitting the DA `Start` request, the `startFailure` test passes if `start()` emits `sessionStartFailed` without calling the service: lines 409–410 assert only failure and no start, and never check that the fixture received a `Start` request.

Assert that the fixture received exactly one `Start` request before accepting the failure result.

Comment thread src/daemon/Auth.cpp
Comment on lines +434 to +437
ensureDAClient()->authenticate(user, pamService == QLatin1String("ddm-autologin")
? QStringLiteral("autologin") : QStringLiteral("login"),
seat, tty > 0 ? static_cast<quint32>(tty) : 0, secret);
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Low · Treeland bypasses documented UserSession path

When a login uses Treeland, for Treeland, Auth::authenticateAsync authenticates through DASessionClient, and openSessionAsync launches through DA instead of UserSession, so the documented login path is false for every Treeland login.

Update kb-965847 to describe DA-managed Treeland authentication and session launch while retaining the UserSession path for other display types.

Also at src/daemon/Auth.cpp:490.

Prompt for AI agents
In `src/daemon/Auth.cpp` at lines 434-437:

**Treeland bypasses documented UserSession path**

When a login uses Treeland, for Treeland, `Auth::authenticateAsync` authenticates through `DASessionClient`, and `openSessionAsync` launches through DA instead of `UserSession`, so the documented login path is false for every Treeland login.

Update kb-965847 to describe DA-managed Treeland authentication and session launch while retaining the `UserSession` path for other display types.

Also at `src/daemon/Auth.cpp:490`.

From .github/copilot-instructions.md L17:

        - When user login, Auth will startup UserSession, which will call PAM to open session, as well as starting up desktop environment.

1. Add an asynchronous DA login client with credential FD transport.
2. Move Treeland login, logout and recovery to the session service.
3. Bind seat/VT context and preserve existing non-Treeland paths.
4. Preserve live sessions when metadata recovery is unavailable.
5. Treat lock-screen Login for a running session as unlock verification.

Log: Manage Treeland login sessions through the authentication service.

Influence:
1. Build DDM and run the isolated DA client tests in the supplied environment.
2. Verify login, autologin, unlock and grouped VT cleanup.
3. Verify lock-screen unlock no longer starts a duplicate login.

feat: 将 Treeland 登录会话接入统一认证服务

1. 新增异步 DA 登录客户端及口令 FD 传输。
2. 将 Treeland 登录、注销和会话接管交给独立服务。
3. 绑定 seat/VT 上下文,保留非 Treeland 原有路径。
4. 元数据恢复不可用时保留运行中的会话。
5. 锁屏界面对已运行会话的 Login 改为验证解锁。

Log: Treeland 登录会话改由统一认证服务管理。

Influence:
1. 在提供的环境中构建 DDM 并运行隔离 DA 客户端测试。
2. 验证登录、自动登录、解锁和分组 VT 回收。
3. 验证锁屏解锁不再触发重复登录。

PMS: TASK-399545
@fly602
fly602 force-pushed the feat/da-login-service branch from 563dfed to 4c2c870 Compare December 3, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants