Fix inverted status checks in the SCSI tape backends#610
Open
matejk wants to merge 2 commits into
Open
Conversation
sg_modesense returns the transferred byte count (> 0) on success, but is_ame and sg_set_key compared the result against 0/DEVICE_GOOD. is_ame therefore always reported the drive as non-AME, and sg_set_key bailed out before issuing SECURITY PROTOCOL OUT, so setting a data key always failed on encrypting drives. Compare against < 0 like the other sg_modesense callers, and normalize sg_set_key's success return. Not verified on encrypting tape hardware; the logic follows the documented sg_modesense return convention.
The function collected DEVICE_GOOD in ret when one of the vendor attributes matched, but returned the hardcoded initial error, so every successful set was reported as -LTFS_NO_XATTR. Return ret, matching the sg backend. Found by -Wunused-but-set-variable. Also remove two write-only variables in the same file.
a27de2b to
4224ef2
Compare
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.
Two fixes for inverted result handling:
is_ameandsg_set_keytreated a successful MODE SENSE as a failure, so encryption setup could fail even on drives that pass the capability check.iokit_set_xattr(macOS): reported success as failure.Related to #498: this corrects the MODE SENSE handling on the encryption path, but does not change the drive-capability rejection in
is_encryption_capablethat the issue also discusses, so it is not marked as fixing it.