From 317b143331118fa0146fce97316476ad6d8141d1 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 22 Aug 2013 17:17:07 -0400 Subject: [MacPlatform] Make Keychain save "Web form password" when the auth type is HTML Form --- main/src/addins/MacPlatform/MacInterop/Keychain.cs | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'main/src') diff --git a/main/src/addins/MacPlatform/MacInterop/Keychain.cs b/main/src/addins/MacPlatform/MacInterop/Keychain.cs index a371610e4c..8bddea0bda 100644 --- a/main/src/addins/MacPlatform/MacInterop/Keychain.cs +++ b/main/src/addins/MacPlatform/MacInterop/Keychain.cs @@ -473,21 +473,26 @@ namespace MonoDevelop.MacInterop // (int) protocol, (int) auth, (uint) passwordBytes.Length, passwordBytes, ref itemRef); var label = Encoding.UTF8.GetBytes (string.Format ("{0} ({1})", uri.Host, Uri.UnescapeDataString (uri.UserInfo))); - fixed (byte* labelPtr = label, userPtr = user, hostPtr = host, pathPtr = path) { - SecKeychainAttribute* attrs = stackalloc SecKeychainAttribute [7]; + var desc = Encoding.UTF8.GetBytes ("Web form password"); + + fixed (byte* labelPtr = label, descPtr = desc, userPtr = user, hostPtr = host, pathPtr = path) { + SecKeychainAttribute* attrs = stackalloc SecKeychainAttribute [8]; int* protoPtr = (int*) &protocol; int* authPtr = (int*) &auth; int* portPtr = &port; - - attrs[0] = new SecKeychainAttribute (SecItemAttr.Label, (uint) label.Length, (IntPtr) labelPtr); - attrs[1] = new SecKeychainAttribute (SecItemAttr.Account, (uint) user.Length, (IntPtr) userPtr); - attrs[2] = new SecKeychainAttribute (SecItemAttr.Protocol, (uint) 4, (IntPtr) protoPtr); - attrs[3] = new SecKeychainAttribute (SecItemAttr.AuthType, (uint) 4, (IntPtr) authPtr); - attrs[4] = new SecKeychainAttribute (SecItemAttr.Server, (uint) host.Length, (IntPtr) hostPtr); - attrs[5] = new SecKeychainAttribute (SecItemAttr.Port, (uint) 4, (IntPtr) portPtr); - attrs[6] = new SecKeychainAttribute (SecItemAttr.Path, (uint) path.Length, (IntPtr) pathPtr); - - SecKeychainAttributeList attrList = new SecKeychainAttributeList (6, (IntPtr) attrs); + int n = 0; + + attrs[n++] = new SecKeychainAttribute (SecItemAttr.Label, (uint) label.Length, (IntPtr) labelPtr); + if (auth == SecAuthenticationType.HTMLForm) + attrs[n++] = new SecKeychainAttribute (SecItemAttr.Description, (uint) desc.Length, (IntPtr) descPtr); + attrs[n++] = new SecKeychainAttribute (SecItemAttr.Account, (uint) user.Length, (IntPtr) userPtr); + attrs[n++] = new SecKeychainAttribute (SecItemAttr.Protocol, (uint) 4, (IntPtr) protoPtr); + attrs[n++] = new SecKeychainAttribute (SecItemAttr.AuthType, (uint) 4, (IntPtr) authPtr); + attrs[n++] = new SecKeychainAttribute (SecItemAttr.Server, (uint) host.Length, (IntPtr) hostPtr); + attrs[n++] = new SecKeychainAttribute (SecItemAttr.Port, (uint) 4, (IntPtr) portPtr); + attrs[n++] = new SecKeychainAttribute (SecItemAttr.Path, (uint) path.Length, (IntPtr) pathPtr); + + SecKeychainAttributeList attrList = new SecKeychainAttributeList (n, (IntPtr) attrs); itemRef = IntPtr.Zero; result = SecKeychainItemCreateFromContent (SecItemClass.InternetPassword, &attrList, (uint) passwd.Length, passwd, IntPtr.Zero, IntPtr.Zero, ref itemRef); -- cgit v1.2.3