fix: include share name in SMB keyring credentials - #386
Conversation
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
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe 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 storagesequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| 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())); |
There was a problem hiding this comment.
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.
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
cdd7e9f
into
linuxdeepin:develop/meagle-20260526
Log: fix SMB share only authenticating once across different users
Influence:
fix: SMB共享凭证加入share name属性隔离
Log: 修复访问不同用户不同密码的SMB共享时仅鉴权一次的问题
Influence:
PMS: BUG-375257
Summary by Sourcery
Fix SMB credential matching so authentication is handled independently for each share.
Bug Fixes:
Enhancements: