WireGuardApp: restore old keychain consistency behavior

This reverts commit adcbd17ebe.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2021-09-23 05:39:47 +02:00
parent f3798d0e11
commit dfb685f258
1 changed files with 9 additions and 7 deletions

View File

@ -56,19 +56,21 @@ class TunnelsManager {
tunnelManager.saveToPreferences { _ in } tunnelManager.saveToPreferences { _ in }
} }
#if os(iOS) #if os(iOS)
let verify = true let passwordRef = proto.verifyConfigurationReference() ? proto.passwordReference : nil
#elseif os(macOS) #elseif os(macOS)
let verify = proto.providerConfiguration?["UID"] as? uid_t == getuid() let passwordRef: Data?
if proto.providerConfiguration?["UID"] as? uid_t == getuid() {
passwordRef = proto.verifyConfigurationReference() ? proto.passwordReference : nil
} else {
passwordRef = proto.passwordReference // To handle multiple users in macOS, we skip verifying
}
#else #else
#error("Unimplemented") #error("Unimplemented")
#endif #endif
if verify && !proto.verifyConfigurationReference() { if let ref = passwordRef {
wg_log(.error, message: "Unable to verify keychain entry of tunnel: \(tunnelManager.localizedDescription ?? "<unknown>")")
}
if let ref = proto.passwordReference {
refs.insert(ref) refs.insert(ref)
} else { } else {
wg_log(.error, message: "Removing orphaned tunnel with missing keychain entry: \(tunnelManager.localizedDescription ?? "<unknown>")") wg_log(.info, message: "Removing orphaned tunnel with non-verifying keychain entry: \(tunnelManager.localizedDescription ?? "<unknown>")")
tunnelManager.removeFromPreferences { _ in } tunnelManager.removeFromPreferences { _ in }
tunnelManagers.remove(at: index) tunnelManagers.remove(at: index)
} }