Commit 5de47e7
Tighten BestEffortLchown to only swallow permission errors
Previously, any non-permission error from os.Lchown was logged
at warn level and then silently dropped — a failure mode where
the file's owner silently ended up wrong while the caller saw
no error. Tighten the contract so only permission-denied errors
(the expected non-root case) are absorbed; everything else
(ENOENT, EROFS, EIO, ...) propagates to the caller.
Tests cover both paths: a non-existent path returning ENOENT
surfaces an error; a non-root chown to a foreign UID returning
EPERM returns nil. The EPERM test is skipped when running as
root since root can chown to any UID.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7783f0c commit 5de47e7
2 files changed
Lines changed: 37 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
211 | 211 | | |
212 | 212 | | |
213 | 213 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
223 | | - | |
| 224 | + | |
224 | 225 | | |
| 226 | + | |
| 227 | + | |
225 | 228 | | |
226 | | - | |
227 | | - | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
661 | 689 | | |
662 | 690 | | |
663 | 691 | | |
| |||
0 commit comments