Skip to content

Commit

Permalink
lint nits
Browse files Browse the repository at this point in the history
  • Loading branch information
mlink committed Jan 5, 2024
1 parent 5858581 commit a7f3e4d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Sources/Haversack/Security/KeychainFile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ public class KeychainFile {
let status = withUnsafeMutablePointer(to: &searchList) {
SecKeychainCopyDomainSearchList(.system, UnsafeMutablePointer($0))
}

guard status == errSecSuccess else {
// attempt to use traditional path, may fail later
return KeychainFile(at: legacySystemKeychainPath)
}

guard let searchList = searchList as? [SecKeychain], let systemKeychain = searchList.first else {
return KeychainFile(at: legacySystemKeychainPath)
}

return KeychainFile(reference: systemKeychain)
}()

Expand All @@ -71,27 +71,27 @@ public class KeychainFile {
self.path = (filePath as NSString).standardizingPath
self.passwordProvider = passwordProvider
}

/// Create an instance from an existing keychain reference
/// - Parameters:
/// - reference: A reference to a `SecKeychain`.
init(reference: SecKeychain) {
passwordProvider = nil
self.reference = reference

var pathLength = UInt32(PATH_MAX)
let pathName = UnsafeMutablePointer<CChar>.allocate(capacity: Int(pathLength))
let status = withUnsafeMutablePointer(to: &pathLength) { pathLength in
SecKeychainGetPath(reference, pathLength, pathName)
}

if status == errSecSuccess {
path = FileManager().string(withFileSystemRepresentation: pathName, length: Int(pathLength))
} else {
// should never happen
path = ""
}

pathName.deallocate()
}

Expand Down

0 comments on commit a7f3e4d

Please sign in to comment.