Skip to content

fix(xwayland): refresh user Xauthority after Xwayland restart - #1448

Merged
wineee merged 1 commit into
linuxdeepin:masterfrom
gugullll:fix/tran_new
Sep 29, 2026
Merged

wineee merged 1 commit into
linuxdeepin:masterfrom
gugullll:fix/tran_new

Conversation

@gugullll

@gugullll gugullll commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Xwayland regenerates /tmp/.xauth_ on every start, but treeland-sd only fetched it at startup, on compositor re-registration, or after a failed activation. An in-place restart inside a running compositor triggers none of those, so the user's XAUTHORITY kept stale MIT-MAGIC-COOKIE-1 data and X11 clients failed with "Invalid MIT-MAGIC-COOKIE-1 key".

Add XWaylandAuthChanged instead of reusing SessionChanged: an in-place restart re-generates the auth data without switching the active session, so reusing SessionChanged would also wake the wayland helper into re-running ActivateWayland. Xwayland now subscribes to the new signal, which requires dropping the per-type early return in tryStart().

Xwayland 每次(重)启动都会重新生成 /tmp/.xauth_,但 treeland-sd 只在 进程启动、compositor 重新注册或上次激活失败时才重新获取。compositor 运行期间
的 Xwayland 原地重启不会触发上述任何一条,导致用户 XAUTHORITY 文件保留过期的
MIT-MAGIC-COOKIE-1,X11 客户端报 Invalid MIT-MAGIC-COOKIE-1 key。

新增 XWaylandAuthChanged 而不复用 SessionChanged:原地重启只重新生成认证数据, 并未切换活动会话,复用 SessionChanged 会连带唤醒 wayland helper 重复执行 ActivateWayland。Xwayland 改为订阅新信号,因此需要去掉 tryStart() 中按类型提前 返回的分支。

Log: 修复 Xwayland 重启后用户 XAUTHORITY 未刷新
PMS: BUG-378331
Influence: treeland-sd(xwayland 类型)改订 XWaylandAuthChanged,Xwayland 重启 后用户侧 XAUTHORITY 自动刷新,X11 应用不再报 Invalid MIT-MAGIC-COOKIE-1 key。 新增 D-Bus 信号,旧客户端不受影响。

Summary by Sourcery

Refresh XWayland authentication state after restarts without changing the active session.

New Features:

  • Add an XWaylandAuthChanged D-Bus signal to notify clients when XWayland authentication data is regenerated.

Bug Fixes:

  • Refresh user XAUTHORITY after in-place XWayland restarts so X11 clients continue authenticating successfully.

Enhancements:

  • Update XWayland socket activation to respond to authentication changes without triggering unnecessary Wayland session activation.

Xwayland regenerates /tmp/.xauth_<display> on every start, but treeland-sd
only fetched it at startup, on compositor re-registration, or after a failed
activation. An in-place restart inside a running compositor triggers none of
those, so the user's XAUTHORITY kept stale MIT-MAGIC-COOKIE-1 data and X11
clients failed with "Invalid MIT-MAGIC-COOKIE-1 key".

Add XWaylandAuthChanged instead of reusing SessionChanged: an in-place
restart re-generates the auth data without switching the active session, so
reusing SessionChanged would also wake the wayland helper into re-running
ActivateWayland. Xwayland now subscribes to the new signal, which requires
dropping the per-type early return in tryStart().

Xwayland 每次(重)启动都会重新生成 /tmp/.xauth_<display>,但 treeland-sd 只在
进程启动、compositor 重新注册或上次激活失败时才重新获取。compositor 运行期间
的 Xwayland 原地重启不会触发上述任何一条,导致用户 XAUTHORITY 文件保留过期的
MIT-MAGIC-COOKIE-1,X11 客户端报 Invalid MIT-MAGIC-COOKIE-1 key。

新增 XWaylandAuthChanged 而不复用 SessionChanged:原地重启只重新生成认证数据,
并未切换活动会话,复用 SessionChanged 会连带唤醒 wayland helper 重复执行
ActivateWayland。Xwayland 改为订阅新信号,因此需要去掉 tryStart() 中按类型提前
返回的分支。

Log: 修复 Xwayland 重启后用户 XAUTHORITY 未刷新
PMS: BUG-378331
Influence: treeland-sd(xwayland 类型)改订 XWaylandAuthChanged,Xwayland 重启
后用户侧 XAUTHORITY 自动刷新,X11 应用不再报 Invalid MIT-MAGIC-COOKIE-1 key。
新增 D-Bus 信号,旧客户端不受影响。
@sourcery-ai

sourcery-ai Bot commented Sep 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a dedicated XWaylandAuthChanged D-Bus signal emitted when Xwayland becomes ready, allowing treeland-sd to refresh user XAUTHORITY after in-place restarts. Xwayland activation now listens only for this authentication event, avoiding unnecessary ActivateWayland runs while preserving existing session-change behavior for other types.

Sequence diagram for Xwayland authentication refresh after restart

sequenceDiagram
    participant Xwayland
    participant SessionManager
    participant TreelandDBus as Treeland_DBus
    participant TreelandSD as treeland_sd
    participant X11Client as X11_Client

    Xwayland->>SessionManager: ready
    SessionManager->>TreelandDBus: XWaylandAuthChanged()
    TreelandDBus-->>TreelandSD: XWaylandAuthChanged
    treeland_sd->>Xwayland: activate()
    Xwayland-->>X11Client: refreshed XAUTHORITY
    X11Client->>Xwayland: X11 connection
    Xwayland-->>X11Client: authentication succeeds
Loading

File-Level Changes

Change Details Files
Introduce a dedicated D-Bus notification for Xwayland authentication regeneration.
  • Declare and expose the XWaylandAuthChanged signal in the D-Bus XML and compositor adaptor.
  • Forward SessionManager Xwayland-ready events to the new compositor signal.
  • Emit the notification whenever an Xwayland instance becomes ready, including restarts.
misc/dbus/org.deepin.compositor1.xml
src/core/treeland.cpp
src/core/treeland.h
src/seat/helper.cpp
src/session/session.cpp
src/session/session.h
Update socket activation so Xwayland refreshes authentication without triggering session activation.
  • Remove the Xwayland-specific early return that prevented signal subscriptions.
  • Subscribe Xwayland helpers to XWaylandAuthChanged while retaining SessionChanged for other helper types.
  • Disconnect and reconnect using the signal appropriate to each helper type.
src/systemd-socket.cpp

Possibly linked issues

  • #unknown: PR直接修复该问题的核心症状:Xwayland重启后自动刷新Xauthority,避免Invalid MIT-MAGIC-COOKIE-1。

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 reviewed your changes and they look great!


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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Refreshes XWayland authentication after in-place restarts without reactivating Wayland sessions.

Changes:

  • Adds and propagates XWaylandAuthChanged.
  • Updates XWayland socket activation to refresh authentication.
  • Removes the XWayland-specific activation bypass.
  • Updates the D-Bus interface definition.
File Description
src/​systemd-socket.cpp Subscribes XWayland helpers to authentication changes.
src/​session/​session.h Declares the authentication signal.
src/​session/​session.cpp Emits the signal when XWayland is ready.
src/​seat/​helper.cpp Forwards the signal to Treeland.
src/​core/​treeland.h Declares the compositor signal.
src/​core/​treeland.cpp Exposes the signal through D-Bus.
misc/​dbus/​org.deepin.compositor1.xml Documents the new D-Bus signal.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gugullll, wineee

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

@wineee
wineee merged commit d6995c3 into linuxdeepin:master Sep 29, 2026
7 checks passed
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.

4 participants