Repository navigation
fix(mkfifo/mknod + chgrp/chown/chcon): fold POSIX drive-dialect operands before any Win32 call (#1235, #1241) - #1249
Conversation
Independent code review — verdict: REQUEST-CHANGES (1 blocker; everything else verified green)Reviewed independently from a fresh detached worktree at bf08199 (base 6e8ea19; 3 commits, 11 files — no piggyback, clang-format clean on all 10 C++ files). PR build + separate baseline (6e8ea19) build, PS native argv throughout, MSYS oracle from BLOCKER — preserve-root failsafe bypass via multi-slash spellings (
|
…-root failsafe The #1241 failsafe kept all-separator operands verbatim while the operand layer collapses them onto '/' (ls -id / // reports one inode): a verbatim GetFullPathNameW('//') answers for an UNC-ish name, so the volume-root comparison missed and 'chown -R --preserve-root X //' really walked the shell root, changing group ownership under WINUXSH_ROOT without the privilege (CR on #1249; the base binary benignly answered 'cannot access //'). All-separator spellings now hit the root match directly, printing the operand spelling alone (MSYS: "on '/'", "on '//'"; MSYS collapses '///' in its own argv layer, ours prints it as received). A spelling that lexically collapses onto the root ('/e/..', '/tmp/..') fires with the '(same as '/')' suffix MSYS prints for those; '//e/..' keeps the POSIX two-slash rule and resolves against '//e' like MSYS ('cannot access'). Regressions pin //, ///, //e/.. and /e/.. across chgrp and chown -R --preserve-root, plus the literal '/' rejection.
|
BLOCKER 修复已推:新 head 修法
CR repro 复测(非提权,PR head 二进制)
补齐
|
…ion (#1235) mkfifo/mknod handed the raw operand ('/e/n', '/cygdrive/e/n', '/mnt/e/n') to the existence probe and create_winux_fifo_w, and Win32 resolves a leading '/e' against the CURRENT drive: from a C: cwd 'mkfifo /e/n' probed '<cwd>:\e\n' and reported ENOENT for a real E:\n, and 'mkfifo /e' from a D: cwd really wrote the fifo marker to D:\e (probe-verified). Operands now fold once through the shared make_api_path_operand boundary before any filesystem call; bare '/e' reports 'File exists' like MSYS instead of touching '<cwd>:\e', and messages keep printing the operand spelling as typed. Regressions synthesize the dialect spelling from the TempDir's own drive (land-on-operand-drive, cwd-on-other-drive shadow negatives, bare-drive root, cygdrive/mnt prefixes, message-spelling pin) and pass on any host.
…Win32 call (#1241) The chown/chgrp family resolved '--reference' and target file operands raw: an unfolded '/e/...' spelling makes GetFileAttributesW / GetNamedSecurityInfoW / the WRITE_OWNER open / FindFirstFileW answer for '<cwd>:\e\...', so existing E: files were reported as missing from any other cwd, and 'chgrp/chown -R --preserve-root /e' missed the failsafe (the volume-root comparison saw '<cwd>:\e') and descended into the shadow tree. chown/chcon globs enumerated the wrong drive. Security lookups, attribute probes, the recursive walks and the glob pattern now fold through the shared boundary first; recursive children re-fold from their display spelling (chmod -R precedent) and error text keeps the user's spelling. An all-separator operand ('/') stays verbatim in the preserve-root failsafe: normalize_api_operand resolves it through the shell tree, and that native root is not the volume root the failsafe has to match (regression-caught). Regressions use the --reference retained form as the parse-layer probe (no security state is modified, per the ticket's no-fake-success rule) with cwd-on-other-drive, recursive-walk, missing-file spelling pins and chcon resolve-then-report-unsupported shapes.
…-root failsafe The #1241 failsafe kept all-separator operands verbatim while the operand layer collapses them onto '/' (ls -id / // reports one inode): a verbatim GetFullPathNameW('//') answers for an UNC-ish name, so the volume-root comparison missed and 'chown -R --preserve-root X //' really walked the shell root, changing group ownership under WINUXSH_ROOT without the privilege (CR on #1249; the base binary benignly answered 'cannot access //'). All-separator spellings now hit the root match directly, printing the operand spelling alone (MSYS: "on '/'", "on '//'"; MSYS collapses '///' in its own argv layer, ours prints it as received). A spelling that lexically collapses onto the root ('/e/..', '/tmp/..') fires with the '(same as '/')' suffix MSYS prints for those; '//e/..' keeps the POSIX two-slash rule and resolves against '//e' like MSYS ('cannot access'). Regressions pin //, ///, //e/.. and /e/.. across chgrp and chown -R --preserve-root, plus the literal '/' rejection.
24a7ef4 to
fd1ea28
Compare
|
rebase 到 v1.1.17 main(a6e4990,解 CHANGELOG Unreleased/1.1.17 冲突,shred #1240 条目保留),最终 head |
Independent code review — BLOCKER-fix round — verdict: APPROVE-WITH-NITSOriginal REQUEST-CHANGES blocker ( BLOCKER closure — reproduced, then verified fixedThree-point chain, all self-run on this rebase:
Fix audit (three segments, oracle-verified)
Bypass hunt: 17 adversarial spellings + multi-operand row ( Rebase integrity, regressions, hygiene
Nits (non-blocking)
Merge is safe from my side: the blocker that caused REQUEST-CHANGES is fixed with oracle-aligned texts, regression-pinned for both commands, and nothing else in the 4-commit stack moved. |
…grp failures (#1262) Three non-blocking items from the #1249 CR sweep: - 'chown Users //e/..' printed the Win32 path-syntax text where chgrp and the MSYS oracle print ENOENT: POSIX keeps "//e/.." rooted at '//e' (the two-slash rule), and Win32 rejects the UNC-ish folded name with ERROR_BAD_PATHNAME / ERROR_INVALID_NAME. Both now map onto 'No such file or directory' in format_chown_error (chmod's format_access_error precedent), so all three print "cannot access '//e/..': No such file or directory". - chgrp's process_directory dropped a directory child's change_group result and the recursive call's return, so a failing descendant still exited 0; both now fold into success like chown's process_recursive. - The '///' display convention is now documented in DOCS/gnu-coreutils/{chgrp,chown}.md: diagnostics quote the operand as typed, so '///' prints verbatim where MSYS shows '/' after its own argv-layer collapse - same refusal, display-only divergence. Tests: pin the ENOENT reason text in both commands' //e/.. refusal rows and add chgrp_recursive_descendant_failure_reaches_exit_code, which makes a descendant's named security call fail deterministically via a DENY GENERIC_ALL self-ACE (no privileges needed) and asserts rc 1 plus the per-descendant diagnostics. 87/87 across the chgrp/chown/mkfifo/mknod/chcon suites; no i18n catalog delta (no extracted literal changed).
…grp failures (#1262) (#1268) Three non-blocking items from the #1249 CR sweep: - 'chown Users //e/..' printed the Win32 path-syntax text where chgrp and the MSYS oracle print ENOENT: POSIX keeps "//e/.." rooted at '//e' (the two-slash rule), and Win32 rejects the UNC-ish folded name with ERROR_BAD_PATHNAME / ERROR_INVALID_NAME. Both now map onto 'No such file or directory' in format_chown_error (chmod's format_access_error precedent), so all three print "cannot access '//e/..': No such file or directory". - chgrp's process_directory dropped a directory child's change_group result and the recursive call's return, so a failing descendant still exited 0; both now fold into success like chown's process_recursive. - The '///' display convention is now documented in DOCS/gnu-coreutils/{chgrp,chown}.md: diagnostics quote the operand as typed, so '///' prints verbatim where MSYS shows '/' after its own argv-layer collapse - same refusal, display-only divergence. Tests: pin the ENOENT reason text in both commands' //e/.. refusal rows and add chgrp_recursive_descendant_failure_reaches_exit_code, which makes a descendant's named security call fail deterministically via a DENY GENERIC_ALL self-ACE (no privileges needed) and asserts rc 1 plus the per-descendant diagnostics. 87/87 across the chgrp/chown/mkfifo/mknod/chcon suites; no i18n catalog delta (no extracted literal changed). Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Fix mkfifo/mknod + chgrp/chown/chcon POSIX drive-dialect misparse (#1235, #1241)
第二波路径方言修复(#1230 审计 15 命令;第一波 #1243 mkdir/ln、#1245 canonicalize 已合并)。
问题
Win32 把前导
/e解析到当前驱动器。五个命令把用户原文直接交给 Win32:std::filesystem::exists)与create_winux_fifo_w收到裸拼写。C: cwd 下mkfifo /e/p探测<cwd>:\e\p报 ENOENT(真实 E:\p 存在也如此);D: cwd 下mkfifo /e真的把 7 字节 fifo 标记写到了 D:\e(基线探针实证,见矩阵)。--reference探测、目标属性探测、GetNamedSecurityInfoW、WRITE_OWNER打开、递归枚举、glob 模式全部收到裸拼写——真实 E: 文件在其它 cwd 下一律误报 "No such file or directory";chgrp/chown -R --preserve-root /e因 failsafe 比较<cwd>:\evs 卷根而失守,递归进入<cwd>:\e。修法(沿用 #1243/#1245 先例)
make_api_path_operand/normalize_api_operand(chown 的CreateFileW用operand.extended,安全 API 用operand.normalized;递归子项从显示拼写逐层重 fold,chmod -R 先例)。X:\折叠形。/)原样透传——normalize_api_operand会把/经 shell-tree 映射到 shell 根,破坏卷根比较(回归捕获,已修)。矩阵(PS/cmd 原生 argv;Git Bash 通道 MSYS 预转参数会假绿,#1230 教训;oracle=D:\Git\usr\bin 同名.exe + PowerShell 三方)
形 = {/e/...(dia)、/cygdrive/e/...(cyg)、/mnt/e/...(mnt)、裸根 /e(root)、Windows 形(win,控制组)} × cwd = {C:\Windows, D:}(E 盘自建 E:\probe-wa\,用后清)。
chgrp/chown 本机无组变更权限:一律走 --reference retained 形或 rc/错误消息与 oracle 对齐判定解析层,不冒充成功(票面要求)。
影子见证与清理
CLEAN|pr|probe dir removed=True|witnesses C:\e=False C:\d=False D:\e=False;探针产物自管自清。测试
红线自查