Skip to content

feat: integrate D-Bus event relay - #281

Merged
deepin-bot[bot] merged 3 commits into
linuxdeepin:develop/snipefrom
wangrong1069:pr1012
Oct 12, 2026
Merged

deepin-bot[bot] merged 3 commits into
linuxdeepin:develop/snipefrom
wangrong1069:pr1012

Conversation

@wangrong1069

@wangrong1069 wangrong1069 commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Integrate filesystem event delivery through a secured D-Bus relay service and update the index and server components to use the new event-channel architecture.

New Features:

  • Expose the filesystem event relay through the org.deepin.Anything system D-Bus service, including caller allow-listing and passed event-channel file descriptors.
  • Relay raw filesystem events to multiple clients through a dedicated server-side dispatcher and D-Bus channel API.
  • Add security-loader D-Bus trust negotiation and systemd journal integration for the index service.

Bug Fixes:

  • Improve filesystem event path resolution across mount aliases and lower-filesystem mounts.
  • Harden event listener and relay startup and shutdown handling.

Enhancements:

  • Replace the legacy event-dispatcher socket integration with the D-Bus event relay protocol.
  • Move the index executable to the deepin libexec directory and update service packaging and runtime dependencies.
  • Add relay dispatcher lifecycle, channel, broadcast, limit, and shutdown tests.

Build:

  • Update CMake targets and package dependencies for GIO, libsystemd, the dispatcher relay, and the new installation layout.

Deployment:

  • Install the D-Bus system policy and update service units for the new relay-based deployment.

Tests:

  • Add server-side event relay dispatcher coverage for lifecycle management, channel allocation, event broadcast, client limits, and shutdown behavior.
  • Remove obsolete mock-socket watcher reconnect and throughput tests.

Replace socket-based event dispatcher with a D-Bus service exporting
org.deepin.Anything interface and a relay dispatcher that broadcasts
raw fs_event structs to connected channels via a worker thread.

新增D-Bus服务接口org.deepin.Anything,提供SetAllowCaller和
GetEventChannel方法;新增事件中继分发器通过worker线程广播
原始fs_event;修复监听器GSource附加到错误GMainContext的问题;
fs_event结构src/dst合并为path字段,minor类型扩展为guint32。

Log: 新增D-Bus服务及事件中继分发器,替换旧的socket分发方式
PMS: BUG-370779
Influence: server服务改为D-Bus方式提供事件通道,影响事件监听和分发的整体流程
Add trust negotiation with deepin-security-loader via fd passing,
switch VfsMonitor to D-Bus GetEventChannel relay, enable systemd
notify and journal logging.

添加与deepin-security-loader的信任协商,通过fd传递实现;
VfsMonitor事件通道从Unix socket切换到D-Bus GetEventChannel
中继;启用systemd notify和journal日志重定向。

Log: 集成安全信任客户端与D-Bus事件中继
PMS: BUG-370779
Influence: 索引服务启动时需通过deepin-security-loader信任验证,事件接收改为D-Bus中继方式,安装路径迁移至libexec/deepin。
Replace isParentChainUnderRoot with mutual-containment check between
mount points and rootPaths. Store root and isRootEqMountPoint in
MountPointInfo so resolveAndFilterFullPath can strip the root prefix
and prepend the correct mount point. Remove the overlay fallback hack
and drop overlay from isLowerFsType.

重写挂载点解析逻辑:用挂载点与rootPaths的互相包含检查代替
isParentChainUnderRoot;在MountPointInfo中保存root字段,使路径解析
能正确剥离root前缀并拼接挂载点。移除overlay回退逻辑,不再将
overlay视为lowerfs。

Log: 修复VFS监控挂载点路径解析错误
PMS: BUG-370779
Influence: 修复挂载环境下文件监控路径解析不准确的问题,提升监控可靠性。
@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Sorry @wangrong1069, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 days and 6 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@github-actions

Copy link
Copy Markdown
  • 检测到敏感词unset, export变动
详情
    {
    "unset": {
        "autotests/index/test_vfsmonitorfilesystemwatcher.cpp": {
            "a": [
                "        qunsetenv(\"DFM_VFSMONITOR_SOCKET_PATH\");",
                "    qunsetenv(\"DFM_VFSMONITOR_SOCKET_PATH\");",
                "    qunsetenv(\"DFM_VFSMONITOR_SOCKET_PATH\");",
                "    qunsetenv(\"DFM_VFSMONITOR_SOCKET_PATH\");",
                "        qunsetenv(\"DFM_VFSMONITOR_SOCKET_PATH\");",
                "        qunsetenv(\"DFM_VFSMONITOR_MAX_QUEUE\");"
            ]
        }
    },
    "export": {
        "src/server/dbus-service.h": {
            "b": [
                " * An opaque D-Bus service object that exports the org.deepin.Anything"
            ]
        }
    }
}

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR replaces the legacy Unix dispatcher socket with a system-bus D-Bus event-relay API: the server forwards raw filesystem events through worker-thread-managed channels and authorizes clients, while the index obtains a passed FD, decodes the new protocol, updates mount-aware filtering, negotiates security-loader trust, and gains journal logging. Build, packaging, service definitions, and tests are updated accordingly.

Sequence diagram for authorized event-channel acquisition

sequenceDiagram
    participant Index
    participant Loader as SecurityLoader
    participant Bus as SystemBus
    participant Service as AnythingDBusService
    participant Relay as RelayDispatcher

    Index->>Loader: request_dbus_trust
    Loader-->>Index: Result=true
    Index->>Bus: GetEventChannel
    Bus->>Service: handle_get_event_channel
    Service->>Relay: server_event_relay_dispatcher_get_event_channel
    Relay-->>Service: get_event_channel_callback(fd, protocol_id)
    Service-->>Index: D-Bus reply with Unix FD and protocol_id
    Index->>Index: recv fs_event and process filesystem event
Loading

Flow diagram for filesystem event delivery

flowchart TD
    Event["Raw fs_event from netlink"] --> Queue["Relay event queue"]
    Queue --> Worker["Relay worker thread"]
    Worker --> Channel["Per-client SOCK_SEQPACKET channel"]
    Channel --> Decode["Index recv and decode fs_event"]
    Decode --> Resolve["resolveAndFilterFullPath"]
    Resolve --> Batch["Queue and flush filtered events"]
Loading

File-Level Changes

Change Details Files
Replace the filesystem event socket path with a D-Bus-mediated event relay channel.
  • Expose org.deepin.Anything SetAllowCaller and GetEventChannel methods over the system bus.
  • Implement server-side allow-listing, Unix FD passing, channel limits, and raw event broadcasting.
  • Obtain and duplicate the relay FD in the index client, then consume the new fs_event wire format.
  • Update packaging, service installation, dependencies, and integration targets for the relay and D-Bus service.
src/server/dbus-service.c
src/server/dbus-service.h
src/server/event-relay-dispatcher.c
src/server/event-relay-dispatcher.h
src/server/main.c
src/server/fs-event.h
src/index/fsmonitor/vfsmonitorwatcher.cpp
src/index/fsmonitor/vfsmonitorwatcher.h
src/index/fsmonitor/vfsmonitorwatcher_p.h
src/server/org.deepin.Anything.conf
src/server/CMakeLists.txt
src/index/CMakeLists.txt
debian/control
debian/deepin-anything-index.install
debian/deepin-anything-server.install
Adapt event production, transport, and filesystem path resolution to the relay protocol and mount metadata.
  • Switch netlink events to the unified fs_event structure with device major/minor and a single path field.
  • Run listener and relay workers on dedicated threads with startup synchronization and shutdown wakeups.
  • Decode one SOCK_SEQPACKET fs_event per recv, preserve batching, reconnect through D-Bus, and filter lower-filesystem events.
  • Rework mount-table selection and path translation around source roots, child mounts, and lower filesystem detection.
src/server/event-listener.c
src/server/event-dispatcher.c
src/index/fsmonitor/vfsmonitorwatcher.cpp
src/index/fsmonitor/vfsmonitorwatcher_p.h
src/server/fs-event.h
Add security-loader trust negotiation and journal-based logging to the index service.
  • Parse injected trust file descriptors and request authorization for the index D-Bus destination before registering services.
  • Read and validate bounded JSON trust responses, closing loader descriptors on completion.
  • Route Qt messages to systemd journal with original source metadata and stderr fallback.
  • Link systemd/GIO dependencies and install the index executable under libexec/deepin.
src/index/main.cpp
src/index/utils/trustclient.cpp
src/index/utils/trustclient.h
src/index/CMakeLists.txt
src/index/deepin-anything-index.service
Revise tests and build integration for the new relay architecture.
  • Add GLib/GIO dependencies and link relay code into index tests.
  • Remove mock Unix-socket reconnect, factory, and throughput tests that depended on the legacy dispatcher socket.
  • Add GLib tests covering relay lifecycle, channel creation and limits, event broadcast, and shutdown behavior.
autotests/index/CMakeLists.txt
autotests/index/test_vfsmonitorfilesystemwatcher.cpp
src/server/tests/CMakeLists.txt
src/server/tests/test_event_relay_dispatcher.c
Update service and logging deployment metadata for the new runtime layout.
  • Install and configure the D-Bus policy, service units, and logger changes for the relay-based server/index processes.
src/logger/deepin-anything-logger.service
src/server/deepin-anything-server.service
debian/deepin-anything-index.install
debian/deepin-anything-server.install

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 94 分 (通过阈值: 70分)

Fail


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全漏洞,代码结构清晰,D-Bus事件中继架构设计合理,信任协商和fd传递机制安全可靠

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['vfsmonitorwatcher.cpp 中 constexpr size_t kPathLen = sizeof(fs_event().path) 使用临时对象获取成员大小,虽然合法但可读性不如直接使用 kDispatchMaxPathLen']


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['可考虑将 startup 同步模式抽取为通用宏或辅助函数以减少重复']


3. 代码性能 ✅

评价: 良好 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['drainSocket 可考虑使用 recvmmsg 替代单次 recv 以恢复批量接收能力,或使用 MSG_WAITFORONE 批量读取', 'read_balanced_json 可使用缓冲区读取(如4096字节)替代逐字节读取']


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: ['D-Bus 策略文件 org.deepin.Anything.conf 正确限制了服务所有权和 SetAllowCaller 方法访问', 'GetEventChannel 通过 allow_callers 白名单进行应用层鉴权,实现了纵深防御', 'trustclient.cpp 中 strtol 正确验证了 end 指针和值范围,防止了整数溢出', 'read_balanced_json 正确跟踪 JSON 字符串和转义状态,防止了括号误匹配', 'fd 传递通过 GUnixFDList 正确管理所有权,dup 后关闭原始 fd 防止泄漏']


💡 改进建议代码示例

// 暂无代码示例

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, wangrong1069

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

@wangrong1069

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot

deepin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

This pr cannot be merged! (status: unstable)

@wangrong1069

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit 0634c8a into linuxdeepin:develop/snipe Oct 12, 2026
16 of 17 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.

3 participants