Skip to content

fix(chown,chgrp): align //e/.. ENOENT text and propagate recursive chgrp failures (#1262) - #1268

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/1262
Oct 20, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/1262

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

  • chown/chgrp now print cannot access '//e/..': No such file or directory for //e/..-class operands — chown previously emitted the Win32 path-syntax text (ERROR_BAD_PATHNAME/ERROR_INVALID_NAME mapped to ENOENT in format_chown_error, matching chmod's format_access_error precedent and the MSYS oracle byte-for-byte).
  • chgrp -R propagates a failing descendant through process_directory (the directory child's own change_group result and the nested call's return were both dropped, so a failed descendant still exited 0), matching chown's process_recursive semantics.
  • The /// display convention is documented in DOCS/gnu-coreutils/{chgrp,chown}.md: diagnostics quote the operand verbatim (on '///'), where MSYS prints on '/' because its own argv layer collapses /// before the binary runs — same refusal, display-only divergence. Item 4 of the issue (. at the shell root) is already tracked by preserve-root 边角: 在 shell root 处仍走树(GNU dev+ino 会拒)——#1249 CR nits #1259 and out of scope here.

Test plan

  • winuxcmd-tests --gtest_filter='chgrp.*:chown.*' → 56/56 (incl. new chgrp_recursive_descendant_failure_reaches_exit_code, which forces deterministic descendant failures via a DENY GENERIC_ALL self-ACE — no privileges needed — and asserts rc 1 + both per-descendant diagnostics; on the unfixed code this returns rc 0)
  • mkfifo.*:mknod.*:chcon.* → 31/31 (fix(mkfifo/mknod + chgrp/chown/chcon): fold POSIX drive-dialect operands before any Win32 call (#1235, #1241) #1249 family no regression)
  • Manual oracle check: chown/chgrp Users //e/.. → cannot access '//e/..': No such file or directory rc 1; -R --preserve-root Users /// → it is dangerous ... '///' rc 1
  • clang-format --dry-run --Werror clean on all touched C++ files
  • No i18n catalog delta — no extracted literal (safeErrorPrint/unexpected/OPTION/help) changed, so no winuxcmd-i18n sync is required for this patch

Fixes #1262

Generated with Devin

caomengxuan666 added a commit that referenced this pull request Oct 20, 2026
…1259) (#1266)

fix(chgrp,chown): refuse "." spellings resolved onto the shell root (#1259)

CR verified (local Release MSVC build @ 0334c5f):
- Targeted chgrp.*:chown.* 61/61 green, incl. the three new "."-refusal
  regressions per command (".", "./", "././" at the shell root refused
  with the "(same as '/')" suffix; not-refused below the root and with
  no shell root configured).
- Path-identity comparison through the operand layer reproduces GNU's
  dev+ino failsafe shape at the shell root; MSYS display parity kept.
- PR CI green (x64/arm64 build, oracle, compare).

Merged over #1268's tracker: both append tests at EOF of the same files;
#1268 needs a rebase after this lands.
@caomengxuan666

Copy link
Copy Markdown
Member Author

CR 复核(fix/1262 → #1268):本地与 CI 验证全绿,但当前不可合并 —— 与 #1266(fix/1259)在同一组测试文件末尾形成 add/add 冲突,#1266 已先合入 main(150ccde),本 PR 需 rebase 后再合。

验证证据(本地 Release MSVC 构建 @ 2b48488)

冲突与解除方式

git merge-tree origin/fix/1259 origin/fix/1262(合并前预测):
CONFLICT (content): tests/unit/chgrp/chgrp_unit_test.cpp —— 两个 PR 都在
chgrp_unit_test.cpp / chown_unit_test.cpp 文件末尾追加用例,锚定同一上下文。
main 现含 #1266 的 6 个 .-拒绝用例;rebase 时保留它们、继续追加本 PR 用例即可(src 侧 chgrp.cpp/chown.cpp 两 PR 改动在不同区域,无冲突)。

rebase 后我会复核 chgrp.*:chown.* + #1259 回归,然后按同一标准合入。

…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).
@caomengxuan666

Copy link
Copy Markdown
Member Author

Rebased onto origin/main (784cca9) after #1266 landed.

Conflict: add/add at EOF of tests/unit/chgrp/chgrp_unit_test.cpp — both PRs appended test blocks at the same anchor. Resolved by keeping both: #1266's three .-spelling refusal regressions (..._dot_spellings_at_shell_root_are_rejected, ..._dot_below_shell_root_is_not_refused, ..._dot_without_shell_root_is_not_refused) first, then this PR's chgrp_recursive_descendant_failure_reaches_exit_code. tests/unit/chown/chown_unit_test.cpp and the src/commands/{chgrp,chown}.cpp hunks auto-merged cleanly.

Tests (local MSVC Debug build, ctest -R "chgrp|chown"): 62/62 passed, including all three #1266 dot-spelling regressions per command and the new chgrp_recursive_descendant_failure_reaches_exit_code. No pushd/popd suites exist in this repo — the conflict was confined to the chgrp/chown test files.

New HEAD: 1fe37c31db254c6798fdcef7e408c27e7c9fbfd8

@caomengxuan666
caomengxuan666 merged commit c0eda0e into main Oct 20, 2026
4 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/1262 branch October 21, 2026 08:19
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.

pushd/popd 族文案与语义边角://e/../ 拒绝文案三处不一致、chgrp 递归返回值丢弃、/// 展示约定文档化

1 participant