Hello community,
I am facing an issue when adding internet passwords to a keychain by script (example script below); despite the fact that new entries are added flawlessly.
#!/bin/bash LOGINNAME=$1 /usr/bin/security \ -v add-internet-password \ -a "$LOGINNAME" \ -l "www.foo.com ($LOGINNAME)" \ -c "apsr" \ -s "www.foo.com" \ -r "http" \ -j "add-internet-password debugging entry" \ -w "MyPassword" \ -T "/Applications/Utilities/Keychain Access.app" \ -T "/usr/bin/security" \ -T "/Applications/Safari.app" \ -t form \ Internet
When opening the relevant website and selecting the login field, Safari shows the appropriate credentials and process with logging in after choosing it. Perfect at first sight. But under the hood, the previously generated entry gets cloned in the keychain. Furthermore, all further logins fall back on the cloned entry.
The cloned entry has some changed values as shown in the excerpt below.
Initial keychain entry added with "security add-internet-password":
security find-internet-password -l "www.foo.com (XRitter)" -g keychain: "/Users/xritter/Library/Keychains/login.keychain" class: "inet" attributes: 0x00000007 <blob>="www.foo.com (XRitter)" 0x00000008 <blob>=<NULL> "acct"<blob>="XRitter" "atyp"<blob>="mrof" "cdat"<timedate>=0x32303135303932303037313934325A00 "20150920071942Z\000" "crtr"<uint32>="apsr" "cusi"<sint32>=<NULL> "desc"<blob>=<NULL> "icmt"<blob>="add-internet-password debugging entry" "invi"<sint32>=<NULL> "mdat"<timedate>=0x32303135303932303037323035365A00 "20150920072056Z\000" "nega"<sint32>=<NULL> "path"<blob>=<NULL> "port"<uint32>=0x00000000 "prot"<blob>=<NULL> "ptcl"<uint32>="http" "scrp"<sint32>=<NULL> "sdmn"<blob>=<NULL> "srvr"<blob>="www.foo.com" "type"<uint32>=<NULL>
Cloned keychain entry after first "automated" login (credentials have been automatically filled by Safari):
security find-internet-password -l "www.foo.com (XRitter)" -g keychain: "/Users/xritter/Library/Keychains/login.keychain" class: "inet" attributes: 0x00000007 <blob>="www.foo.com (XRitter)" 0x00000008 <blob>=<NULL> "acct"<blob>="XRitter" "atyp"<blob>="form" "cdat"<timedate>=0x32303135303932303037323031355A00 "20150920072015Z\000" "crtr"<uint32>=<NULL> "cusi"<sint32>=<NULL> "desc"<blob>="Webformular-Kennwort" "icmt"<blob>="default" "invi"<sint32>=<NULL> "mdat"<timedate>=0x32303135303932303037323031355A00 "20150920072015Z\000" "nega"<sint32>=<NULL> "path"<blob>=<NULL> "port"<uint32>=0x00000000 "prot"<blob>=<NULL> "ptcl"<uint32>="http" "scrp"<sint32>=<NULL> "sdmn"<blob>=<NULL> "srvr"<blob>="www.foo.com" "type"<uint32>=<NULL>
Furthermore, I noticed that the field kind in "Keychain Access.app" (GUI) contains different values. The initial keychain entry has "Internetpassword" and the cloned one "Webformular-password". My idea was this might be the reason why Safari makes a copy of the inital entry due to a wrong value for the field "kind (meaning Safari takes the initial entry but makes a copy with the "appropriate" value "Webformular-password"). But no matter which "atyp" value I've tried (as described in keychains developer reference), the inital entry gets cloned after first login with Safari. I've tried also -D "form" as well as -c "form".
I am at my wits' end.
Does anybody know what is causing cloned entries and how to avoid them respectively how should entries be added by "security add-internet-password" in order to not induce Safari to create a cloned entry after the first login?
Thanks in advance for any advice.
Regards,
Ritter