Commit a203c65
committed
chmod: re-check --preserve-root during the recursive descent
--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 #10033
fixed only the operand-level "resolves to /" case.1 parent 0e791b1 commit a203c65
4 files changed
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| |||
424 | 426 | | |
425 | 427 | | |
426 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
427 | 440 | | |
428 | 441 | | |
429 | 442 | | |
| |||
432 | 445 | | |
433 | 446 | | |
434 | 447 | | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
435 | 454 | | |
436 | 455 | | |
437 | 456 | | |
| |||
503 | 522 | | |
504 | 523 | | |
505 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
506 | 531 | | |
507 | 532 | | |
508 | 533 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
550 | 550 | | |
551 | 551 | | |
552 | 552 | | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
553 | 573 | | |
554 | 574 | | |
555 | 575 | | |
| |||
0 commit comments