Skip to content

chmod: re-check --preserve-root during the recursive descent - #13621

Open
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:chmod-preserve-root-recursion
Open

chmod: re-check --preserve-root during the recursive descent#13621
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:chmod-preserve-root-recursion

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

--preserve-root was only enforced for the paths named on the command line (the operand loop in Chmoder::chmod). With -R -L, a symlink encountered inside the tree that resolves to / was followed, and the recursion walked into the real root, defeating the failsafe.

--preserve-root was only enforced for the paths named on the command line
(the operand loop in Chmoder::chmod). With -R -L, a symlink encountered
*inside* the tree that resolves to / was followed, and the recursion walked
into the real root, defeating the failsafe.

Reproduced in a sandboxed root: a tree containing `link -> /` with
`chmod -R -L --preserve-root 777 tree` took an unrelated 0700 directory to
0777. GNU coreutils 9.10 refuses the same case.

Re-check the guard at every descent, in both walk_dir_with_context variants
so unix, non-unix and redox are all covered. Only symlinks are canonicalized,
so ordinary recursive trees are unaffected.

Behaviour now matches GNU: diagnose with the "(same as '/')" wording, skip the
subtree, continue, and exit 1 -- rather than aborting the whole run.

chown/chgrp already did this in 5c2c38c; chmod was the outlier. PR uutils#10033
fixed only the operand-level "resolves to /" case.
@github-actions

Copy link
Copy Markdown

GNU testsuite comparison:

Skip an intermittent issue tests/date/date-locale-hour (fails in this run but passes in the 'main' branch)
Skip an intermittent issue tests/tail/tail-n0f (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/tail/retry (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/printf/printf-surprise is now being skipped but was previously passing.

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.

1 participant