fix(virusforget): correct --clean abort and --user validation#368
Open
maybebyte wants to merge 2 commits into
Open
fix(virusforget): correct --clean abort and --user validation#368maybebyte wants to merge 2 commits into
maybebyte wants to merge 2 commits into
Conversation
An extraneous file (present in the home directory but absent from the committed backup) is deleted and then unconditionally passed to restore_file, which runs `cp` from a backup path that does not exist. Under `set -e` this aborts the entire `--clean` run on the first such file, leaving the system partially cleaned -- the exact malware-persistence scenario the tool exists to handle. Return early from restore_file when no backup exists. Deleting the extraneous file is the correct action and is already done by the caller (which keeps a forensic copy under the dangerous/ folder). The guard is transparent to the missing-file and modified-file callers, which always have a backup present.
The nonexistent-user branch printed a warning but, unlike every sibling validation branch, neither exited nor wrote to stderr, so a mistyped --user proceeded to operate on a bogus /home/<user> path. Send the error to stderr and exit 1.
Contributor
Author
|
Used Claude Code to find this and assist, but manually reviewed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
virusforget --cleanaborts partway through on exactly the input it existsto remove, and an invalid
--useris detected but not acted on. These aretwo small, independent error-handling fixes to
usr/libexec/security-misc/virusforget.Changes
restore_fileagainst a missing backup. Root cause: anextraneous file (present in
$HOME, absent from the committed backup) isdeleted and then unconditionally passed to
restore_file, which runscpfrom a backup path that does not exist. Under
set -ethis aborts theentire
--cleanrun on the first such file, leaving the system partiallycleaned. The fix returns early when no backup exists — deleting the
extraneous file is the correct action and is already done by the caller,
which keeps a forensic copy under
dangerous/.--userdoes not exist. The nonexistent-user branch printeda warning to stdout but, unlike every sibling validation branch, neither
wrote to stderr nor exited, so a mistyped
--userproceeded against abogus
/home/<user>. It now writes to stderr andexit 1.Testing
bash -n usr/libexec/security-misc/virusforget— no syntax errors.process_filescall chain andthe
process_foldersfind | whilesubshell). Because the script usesset -ewithouterrtrace, the subshell path aborts viaset -epropagation on the failed pipe rather than the
ERRtrap, but both pathsstop on the first extraneous file pre-fix and complete after the guard.
Notes for reviewers
restore_fileguard is transparent to its other two callers(missing-file and modified-file), which always have a backup present.