Commit 077d41a
committed
fix(remove-system.map): continue past undeletable files
The deletion loop called `exit 0` on the first System.map that `[ -w ]`
rejected, so copies in later locations were never shredded. Where
`[ -w ]` passed but shred failed anyway, shred ran as a bare command and
tripped the ERR trap that pre.bsh installs, aborting with a "## Please
report this bug!" banner and exit 1.
Branch on shred's exit status instead of `[ -w ]`, which does not
predict removability. Unlinking depends on write permission on the
parent directory rather than on the file itself, and an append-only file
passes the test yet cannot be unlinked at all. For a full-capability
root process the check is also true on a mode 444 file, so it only ever
failed on read-only file systems and on files carrying the immutable
attribute.
Clear the immutable and append-only attributes before each attempt. Per
review, a System.map should never be immutable and `chattr +i` would
possibly complicate kernel package removal; append-only is cleared on
the same grounds, since it blocks removal without affecting `[ -w ]`.
Report the files that remain once at the end, under a single wiki link
rather than repeating it on every line, and withhold "Done. Success."
when anything failed. A file reachable under two names, such as
/lib/modules/<version>/build and the source symlink beside it, is listed
under each, since both matched and both failed.
Iterate an array rather than word-splitting a string with IFS, which a
/etc/remove-system.map_pre.d drop-in can set; under `IFS=:` the globs
matched nothing, so the script deleted nothing and still exited 0.
The removal loop no longer exits early on failure and the script ends in
an explicit `exit 0`; a non-zero status would fail the kernel package's
postinst hook and the oneshot unit on every boot.1 parent 7f55b21 commit 077d41a
1 file changed
Lines changed: 31 additions & 18 deletions
File tree
- usr/libexec/security-misc
Lines changed: 31 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
| 17 | + | |
23 | 18 | | |
24 | 19 | | |
25 | 20 | | |
| 21 | + | |
| 22 | + | |
26 | 23 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
37 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
41 | 50 | | |
42 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
0 commit comments