]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
WireGuardApp: restore old keychain consistency behavior
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 23 Sep 2021 03:39:47 +0000 (05:39 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 23 Sep 2021 03:40:10 +0000 (05:40 +0200)
This reverts commit adcbd17ebeedaf6fa8106c8835ebf43667170878.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Sources/WireGuardApp/Tunnel/TunnelsManager.swift

index 152d26ed5b48db6555c1ce4be924e04c09769bac..83c48c9bd2bf726b651d19f7d90daf270ea4a7b3 100644 (file)
@@ -56,19 +56,21 @@ class TunnelsManager {
                     tunnelManager.saveToPreferences { _ in }
                 }
                 #if os(iOS)
-                let verify = true
+                let passwordRef = proto.verifyConfigurationReference() ? proto.passwordReference : nil
                 #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
                 #error("Unimplemented")
                 #endif
-                if verify && !proto.verifyConfigurationReference() {
-                    wg_log(.error, message: "Unable to verify keychain entry of tunnel: \(tunnelManager.localizedDescription ?? "<unknown>")")
-                }
-                if let ref = proto.passwordReference {
+                if let ref = passwordRef {
                     refs.insert(ref)
                 } 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 }
                     tunnelManagers.remove(at: index)
                 }