Skip to content

fix: include share name in SMB keyring credentials - #386

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/meagle-20260526from
GongHeng2017:202606022023-dev-meagle-fix
Aug 28, 2026
Merged

fix: include share name in SMB keyring credentials#386
deepin-bot[bot] merged 1 commit into
linuxdeepin:develop/meagle-20260526from
GongHeng2017:202606022023-dev-meagle-fix

Conversation

@GongHeng2017

@GongHeng2017 GongHeng2017 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor
  1. Root cause: DNetworkMounter's keyring credential management (savePasswd/loginPasswd/smbSchema) did not include share name, so loginPasswd searched by {server, protocol} only and returned all saved credentials for the same server regardless of share
  2. Fix: add "object" attribute to smbSchema for share name, extract share from URL path in savePasswd and loginPasswd, include it in both store and search operations to isolate credentials per share
  3. Impact: credentials are now stored and searched per-share; old credentials without "object" attribute won't be matched, users need to re-enter password once per share after upgrade
  4. 方案层级: 根因层修复(5-Why 在 Why 4 收敛,根因层与症状层一致)

Log: fix SMB share only authenticating once across different users

Influence:

  1. Test accessing non-anonymous shares of different users on the same server, second share should prompt for authentication
  2. Test re-accessing a saved share, credential should auto-fill
  3. Test anonymous share access is unaffected
  4. Test FTP/WebDAV mounting is unaffected

fix: SMB共享凭证加入share name属性隔离

  1. 根因:DNetworkMounter 的 keyring 凭证管理(savePasswd/loginPasswd/ smbSchema)未包含 share name 属性,loginPasswd 仅按 {server, protocol} 搜索,返回同一服务器所有共享的已保存凭证
  2. 方案:在 smbSchema 中新增 "object" 属性用于 share name, savePasswd 和 loginPasswd 从 URL 提取 share name 并在存储和 查询时附带,实现凭证按共享级别隔离
  3. 影响:凭证按共享级别存储和搜索,旧凭证不含 "object" 属性 无法命中,升级后用户需对每个已保存共享重新输入一次密码
  4. 方案层级:根因层修复(5-Why 在 Why 4 收敛,根因层与症状层一致)

Log: 修复访问不同用户不同密码的SMB共享时仅鉴权一次的问题

Influence:

  1. 测试同一服务器不同用户的非匿名共享,访问第二个共享应弹出鉴权窗口
  2. 测试重复访问已保存的共享,凭证应自动填充无需再次输入
  3. 测试匿名共享访问不受影响
  4. 测试 FTP/WebDAV 挂载不受影响

PMS: BUG-375257

Summary by Sourcery

Fix SMB credential matching so authentication is handled independently for each share.

Bug Fixes:

  • Isolate SMB keyring credentials by share name so different shares on the same server no longer reuse the wrong saved credentials.

Enhancements:

  • Scope SMB credential storage and lookup to the server, protocol, and share, while leaving FTP, WebDAV, and anonymous access behavior unchanged.

1. Root cause: DNetworkMounter's keyring credential management
   (savePasswd/loginPasswd/smbSchema) did not include share name,
   so loginPasswd searched by {server, protocol} only and returned
   all saved credentials for the same server regardless of share
2. Fix: add "object" attribute to smbSchema for share name, extract
   share from URL path in savePasswd and loginPasswd, include it in
   both store and search operations to isolate credentials per share
3. Impact: credentials are now stored and searched per-share; old
   credentials without "object" attribute won't be matched, users
   need to re-enter password once per share after upgrade
4. 方案层级: 根因层修复(5-Why 在 Why 4 收敛,根因层与症状层一致)

Log: fix SMB share only authenticating once across different users

Influence:
1. Test accessing non-anonymous shares of different users on the
   same server, second share should prompt for authentication
2. Test re-accessing a saved share, credential should auto-fill
3. Test anonymous share access is unaffected
4. Test FTP/WebDAV mounting is unaffected

fix: SMB共享凭证加入share name属性隔离

1. 根因:DNetworkMounter 的 keyring 凭证管理(savePasswd/loginPasswd/
   smbSchema)未包含 share name 属性,loginPasswd 仅按
   {server, protocol} 搜索,返回同一服务器所有共享的已保存凭证
2. 方案:在 smbSchema 中新增 "object" 属性用于 share name,
   savePasswd 和 loginPasswd 从 URL 提取 share name 并在存储和
   查询时附带,实现凭证按共享级别隔离
3. 影响:凭证按共享级别存储和搜索,旧凭证不含 "object" 属性
   无法命中,升级后用户需对每个已保存共享重新输入一次密码
4. 方案层级:根因层修复(5-Why 在 Why 4 收敛,根因层与症状层一致)

Log: 修复访问不同用户不同密码的SMB共享时仅鉴权一次的问题

Influence:
1. 测试同一服务器不同用户的非匿名共享,访问第二个共享应弹出鉴权窗口
2. 测试重复访问已保存的共享,凭证应自动填充无需再次输入
3. 测试匿名共享访问不受影响
4. 测试 FTP/WebDAV 挂载不受影响

PMS: BUG-375257
@sourcery-ai

sourcery-ai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The fix adds the SMB share name as a Secret Service keyring attribute and consistently derives and uses it during credential lookup and storage, preventing credentials for different shares on the same server from being reused interchangeably. Existing credentials without the new attribute will not match and must be re-entered once per share; non-SMB protocols remain unaffected.

Sequence diagram for per-share SMB credential lookup and storage

sequenceDiagram
    participant Mounter as DNetworkMounter
    participant Keyring as SecretServiceKeyring
    participant User

    Mounter->>Mounter: loginPasswd(address)
    Mounter->>Mounter: QUrl::path()
    Mounter->>Keyring: secret_password_lookup_sync(server, protocol, object)
    alt matching share credential found
        Keyring-->>Mounter: saved credential
        Mounter-->>User: auto-fill credential
    else no matching share credential
        Mounter-->>User: prompt for password
        User->>Mounter: password
        Mounter->>Keyring: secret_password_store_sync(server, protocol, user, object)
    end
Loading

File-Level Changes

Change Details Files
Scopes SMB keyring credentials by share name in addition to server, protocol, user, and domain.
  • Adds the object schema attribute for the share name.
  • Extracts the share from the SMB URL path during credential lookup and storage.
  • Includes the share attribute in Secret Service queries and saved credential records.
src/dfm-mount/private/dnetworkmounter.cpp

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 1 issue

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

## Individual Comments

### Comment 1
<location path="src/dfm-mount/private/dnetworkmounter.cpp" line_range="118-123" />
<code_context>
     QUrl u(address);
     QString protocol = u.scheme();
     QString host = u.host();
+    QString share = u.path().remove("/");

     GHashTable_autoptr query = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
     g_hash_table_insert(query, strdup(kSchemaServer), strdup(host.toStdString().c_str()));
     g_hash_table_insert(query, strdup(kSchemaProtocol), strdup(protocol.toStdString().c_str()));
+    g_hash_table_insert(query, strdup(kSchemaObject), strdup(share.toStdString().c_str()));

     QList<QVariantMap> passwds;
</code_context>
<issue_to_address>
**issue (bug_risk):** The share key is derived by removing every `/` from the complete URL path instead of extracting only the first path component. For an SMB URL such as `smb://server/share/subdirectory`, the credential is stored/searched under `sharesubdirectory` rather than the actual share `share`, so a credential saved for the share root is not found when the same share is accessed through a nested path.

**Triggers:** When network addresses contain a path below the SMB share root.

**Suggested fix:** Extract the first decoded path component after the leading slash, for example with `u.path().section('/', 1, 1)`, and use that value for the keyring object attribute.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +118 to +123
QString share = u.path().remove("/");

GHashTable_autoptr query = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
g_hash_table_insert(query, strdup(kSchemaServer), strdup(host.toStdString().c_str()));
g_hash_table_insert(query, strdup(kSchemaProtocol), strdup(protocol.toStdString().c_str()));
g_hash_table_insert(query, strdup(kSchemaObject), strdup(share.toStdString().c_str()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): The share key is derived by removing every / from the complete URL path instead of extracting only the first path component. For an SMB URL such as smb://server/share/subdirectory, the credential is stored/searched under sharesubdirectory rather than the actual share share, so a credential saved for the share root is not found when the same share is accessed through a nested path.

Triggers: When network addresses contain a path below the SMB share root.

Suggested fix: Extract the first decoded path component after the leading slash, for example with u.path().section('/', 1, 1), and use that value for the keyring object attribute.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: GongHeng2017, max-lvs

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

@GongHeng2017

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit cdd7e9f into linuxdeepin:develop/meagle-20260526 Aug 28, 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