Skip to content

fix(service): pass ISO file descriptor instead of path over D-Bus - #133

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wangrong1069:pr0903
Sep 14, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
wangrong1069:pr0903

Conversation

@wangrong1069

@wangrong1069 wangrong1069 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

The bootmaker service runs with ProtectHome=true and PrivateTmp=true, so it cannot reach /home or /tmp by path. Open the ISO in the front-end and pass only the descriptor over D-Bus; the service reopens it via /proc/self/fd.

启用ProtectHome和PrivateTmp加固服务,D-Bus接口改为传递文件描述符而非
路径,服务通过/proc/self/fd访问ISO文件。

Log: 加固bootmaker服务,使用文件描述符替代路径传递
PMS: BUG-376053
Influence: Install和CheckFile接口参数从路径改为文件描述符,需配合前端同步更新调用方式。

Summary by Sourcery

Replace path-based ISO transfer with file-descriptor passing across the bootmaker D-Bus interface.

Bug Fixes:

  • Pass ISO files as D-Bus file descriptors so the bootmaker service can access them despite its protected home and temporary filesystem namespaces.

Enhancements:

  • Update Install and CheckFile APIs to accept Unix file descriptors and access the files through /proc/self/fd.
  • Retain forwarded descriptors for installation subprocesses and reject requests without valid descriptors.

Deployment:

  • Align the bootmaker D-Bus service definition with the descriptor-based Install and CheckFile interfaces.

Tests:

  • Update service tests to cover valid and invalid file descriptor requests.

@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR hardens ISO access under ProtectHome=true and PrivateTmp=true by opening files in the front end, passing Unix file descriptors over D-Bus, and resolving them through /proc/self/fd in the service. It updates the D-Bus contract, service implementation, ownership/inheritance handling, deployment configuration, and tests.

Sequence diagram for D-Bus ISO file descriptor transfer

sequenceDiagram
    participant Frontend
    participant Dbus as D-Bus
    participant Service as BootMakerService
    participant Worker as BootMaker
    participant Child as 7z_or_isoinfo

    Frontend->>Frontend: openReadOnlyFd(image)
    Frontend->>Dbus: Install(device, partition, formatDevice, fd)
    Dbus->>Service: Install(..., QDBusUnixFileDescriptor)
    Service->>Service: fcntl(fd, F_SETFD, 0)
    Service->>Service: imageFd = fd
    Service->>Worker: startInstall(/proc/self/fd/n, device, partition, formatDevice)
    Worker->>Child: Open /proc/self/fd/n
    Child-->>Worker: Read ISO through inherited descriptor
Loading

Sequence diagram for D-Bus file validation

sequenceDiagram
    participant Frontend
    participant Dbus as D-Bus
    participant Service as BootMakerService
    participant Worker as BootMaker

    Frontend->>Frontend: openReadOnlyFd(filepath)
    Frontend->>Dbus: CheckFile(fd)
    Dbus->>Service: CheckFile(QDBusUnixFileDescriptor)
    Service->>Service: fcntl(fd, F_SETFD, 0)
    Service->>Worker: checkfile(/proc/self/fd/n)
    Worker-->>Service: Validation result
    Service-->>Frontend: bool
Loading

File-Level Changes

Change Details Files
Replace ISO path arguments with Unix file descriptors at the D-Bus boundary.
  • Open input files read-only in the client and transfer owned descriptors via QDBusUnixFileDescriptor.
  • Reorder Install arguments and update CheckFile to accept descriptor type h.
  • Reject empty or invalid descriptors before invoking service operations.
src/libdbm/backend/bmdbusinterface.h
src/service/bootmakerservice.h
src/service/data/com.deepin.bootmaker.xml
Make the service consume transferred descriptors through /proc/self/fd.
  • Reconstruct a procfs path from the received descriptor and pass it to installation and file-checking logic.
  • Retain the Install descriptor for the operation and clear close-on-exec so spawned tools can inherit it.
  • Remove image paths from service logging and validate descriptor validity.
src/service/bootmakerservice.cpp
src/service/bootmakerservice_p.h
Update service tests for descriptor-based calls and invalid-input handling.
  • Create and duplicate a temporary file descriptor for Install and CheckFile tests.
  • Add assertions that calls with invalid descriptors are rejected.
src/tests/bootmakerservicetest.cpp
Adjust the service integration configuration for the hardened deployment.
  • Update the systemd service configuration alongside the ProtectHome/PrivateTmp-related behavior.
src/service/data/deepin-boot-maker.service

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 2 issues

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

## Individual Comments

### Comment 1
<location path="src/libdbm/backend/bmdbusinterface.h" line_range="49-51" />
<code_context>
+        // paths. Open the ISO here (in the caller's process, which can) and
+        // pass only the descriptor over D-Bus; the service reopens it via
+        // /proc/self/fd/<n>. The path itself never crosses the bus.
+        QDBusUnixFileDescriptor fd = openReadOnlyFd(image);
         QList<QVariant> argumentList;
-        argumentList << QVariant::fromValue(image) << QVariant::fromValue(device) << QVariant::fromValue(partition) << QVariant::fromValue(formatDevice);
+        argumentList << QVariant::fromValue(device) << QVariant::fromValue(partition) << QVariant::fromValue(formatDevice) << QVariant::fromValue(fd);
         return asyncCallWithArgumentList(QStringLiteral("Install"), argumentList);
     }
</code_context>
<issue_to_address>
**issue (bug_risk):** The D-Bus proxy changes `Install` and `CheckFile` to require file descriptors, but `BMDbusHandler::install` and `BMDbusHandler::checkfile` still pass the old path-based arguments. These callers no longer match the proxy signatures, so the Linux frontend fails to compile.

**Triggers:** When building the Linux frontend.

**Suggested fix:** Update `BMDbusHandler` and the higher-level frontend APIs to open the image path and pass a `QDBusUnixFileDescriptor`, or provide a complete path-to-descriptor conversion before calling the proxy.
</issue_to_address>

### Comment 2
<location path="src/libdbm/backend/bmdbusinterface.h" line_range="49-51" />
<code_context>
+        // paths. Open the ISO here (in the caller's process, which can) and
+        // pass only the descriptor over D-Bus; the service reopens it via
+        // /proc/self/fd/<n>. The path itself never crosses the bus.
+        QDBusUnixFileDescriptor fd = openReadOnlyFd(image);
         QList<QVariant> argumentList;
-        argumentList << QVariant::fromValue(image) << QVariant::fromValue(device) << QVariant::fromValue(partition) << QVariant::fromValue(formatDevice);
+        argumentList << QVariant::fromValue(device) << QVariant::fromValue(partition) << QVariant::fromValue(formatDevice) << QVariant::fromValue(fd);
         return asyncCallWithArgumentList(QStringLiteral("Install"), argumentList);
     }
</code_context>
<issue_to_address>
**issue (bug_risk):** The proxy silently converts any failed path open into an invalid descriptor, and the asynchronous D-Bus call is still sent. The service then rejects the request as a generic invalid-descriptor failure, so callers lose the original open error and receive no immediate indication that the ISO path was unreadable.

**Triggers:** When the frontend cannot open the ISO, including a nonexistent path, permission denial, or an empty path.

**Suggested fix:** Check `fd.isValid()` in the proxy or caller before sending the request and propagate a specific local error instead of issuing a doomed D-Bus call.
</issue_to_address>

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

Comment thread src/libdbm/backend/bmdbusinterface.h
Comment thread src/libdbm/backend/bmdbusinterface.h
The bootmaker service runs with ProtectHome=true and PrivateTmp=true, so it
cannot reach /home or /tmp by path. Open the ISO in the front-end and pass
only the descriptor over D-Bus; the service reopens it via /proc/self/fd.

启用ProtectHome和PrivateTmp加固服务,D-Bus接口改为传递文件描述符而非
路径,服务通过/proc/self/fd访问ISO文件。

Log: 加固bootmaker服务,使用文件描述符替代路径传递
PMS: BUG-376053
Influence: Install和CheckFile接口参数从路径改为文件描述符,需配合前端同步更新调用方式。
@wangrong1069

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot
deepin-bot Bot merged commit 527b11e into linuxdeepin:master Sep 14, 2026
16 checks passed
@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

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