80b8238d0a
### 背景 Windows 下 AGC 读取配置目录、项目文件和本地资源时,可能先于 ACL 校验阶段就因继承权限、错误 owner 或拒绝访问而失败,表现为 `拒绝访问。 (os error 5)`。 此前自定义 `--config-dir` 场景还存在 scope 无法传递到提权子进程的问题;native picker 路径也缺少进程内来源证明,递归索引可能跟随 junction/reparse point,新建文件在权限加固失败时可能留下残留文件。 ### 本次变更 1. 修复自定义 `--config-dir` 的 `managed / user-selected` scope 传递与提权票据校验。 2. 增加 native picker 文件/目录路径的短期 provenance 授权;未经过 picker 授权的任意 IPC 绝对路径不能触发 `user-selected` 自动提权。 3. 项目文件列表和索引递归改用 `symlink_metadata()`,拒绝 symlink、junction 和 Windows reparse point。 4. 统一在 metadata/read/open 前完成 ACL 准备,对 ACL 导致的 metadata 失败执行一次受控修复和重试。 5. 新建 conversation、导出包、Agent DB、资源、字体等文件在 harden 失败时关闭句柄并清理刚创建的文件。 6. 修复 UAC 提权授权票据以 `share_mode(0)` 独占打开后与 `GetNamedSecurityInfoW/SetNamedSecurityInfoW` 产生共享冲突的问题。 7. 同步 AGC Windows ACL 技术方案与安全回归测试。 ### 安全行为 - UAC 取消返回 `1223`,不会被当作成功。 - 提权子进程重新校验目标路径、scope、当前用户 SID、nonce、有效期和票据一次性消费。 - symlink、junction、reparse point 和非普通文件对象保持失败关闭。 - 自定义配置目录可以位于用户 profile 外部,但仍受 owner、DACL 和路径类型校验。 ### 验证结果 已执行并通过: ``` cargo check --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml private_path_elevation_policy_tests -- --nocapture # 10 passed cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml local_project -- --nocapture # 20 passed cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml checkpoint::security_tests -- --nocapture # 10 passed cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml private_file_write_tests -- --nocapture # 2 passed npm run check:encoding # 5554 files passed git diff --check # passed ``` 另外确认: - `origin/master` 是当前分支祖先。 - 交接文档已删除,且原本不在 Git 跟踪列表中。 - 全量 `cargo test` 未作为通过依据;此前存在与 ACL 无关的失败项。 - `cargo fmt --check` 仍受仓库已有格式漂移影响,本次未执行全仓库格式化。 - 真实 Windows UAC 点击“Yes”的手工回归仍需在目标机器上确认。 ### 手工验收 使用: ```powershell & "C:\Users\dongy\workspace\Genarrative\.worktrees\agc-windows-acl-fix\apps\ai-game-creator-shell\src-tauri\target\debug\genarrative-ai-game-creator-shell.exe" ` --config-dir "C:\Users\dongy\AppData\Local\Temp\agc-acl-live-20260830\deny-config-2" ``` 验收标准: 1. 选择“否”:进程返回 `exit code 1223`。 2. 重新启动并选择“Yes”:不再返回 `exit code 1`,ACL 修复完成后继续启动。 3. 再次启动同一配置目录:不应重复弹出修复。 4. 检查目录 owner 和 DACL,确认归当前用户所有且为私有权限。 --------- Co-authored-by: 段舒康 <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/211 Co-authored-by: 董羽秦 <suzmii@qq.com> Co-committed-by: 董羽秦 <suzmii@qq.com>