Re: Stealing settings from Mail.app
Re: Stealing settings from Mail.app
- Subject: Re: Stealing settings from Mail.app
- From: Chris <email@hidden>
- Date: Mon, 31 May 2010 18:35:05 -0700 (PDT)
Thanks, it was the iTools bit I needed. But looks like there is a bug in this code it won't notice me.com and could wrongly think say macdonald.com is mobile me. But thanks, it gives me what I needed.
--
Chris
On 31/05/2010, at 8:11 PM, Dante Palacios <email@hidden> wrote:
NSString *GetPassword(NSString *userName, NSString *hostName) {
if (!hostName.length || !userName.length) return nil;
const char *serviceName = [hostName UTF8String];
const char *serviceUserName = [userName UTF8String];
const char *path = "";
UInt32 passwordLength = 0;
char *pass = nil;
OSStatus status = noErr;
SecKeychainItemRef itemRef;
if ([hostName rangeOfString:@"mac"].location != NSNotFound) {
serviceName = "iTools"; //<= note this
status = SecKeychainFindGenericPassword(NULL,
(UInt32)strlen(serviceName),
serviceName,
(UInt32)strlen(serviceUserName),
serviceUserName,
&passwordLength,
(void **)&pass,
&itemRef);
}else {
status = SecKeychainFindInternetPassword(NULL,
(UInt32)strlen(serviceName),
serviceName,
0,
NULL,
(UInt32)strlen(serviceUserName),
serviceUserName,
(UInt32)strlen(path),
path,
0,
kSecAuthenticationTypeAny,
kSecAuthenticationTypeAny,
&passwordLength,
(void **)&pass,
&itemRef);
}
if (status != noErr) {
CFStringRef errMess = SecCopyErrorMessageString(status, NULL);
NSLog(@"%@", (NSString *)errMess);
CFRelease(errMess);
return nil;
}
return [[[NSString alloc] initWithBytes:pass length:passwordLength encoding:NSUTF8StringEncoding] autorelease];
}
On May 31, 2010, at 12:11 AM, Jn wrote:
Would you have the API code to retrieve it? Not sure what to pass to get the mobile me password.
--
Chris
On 31/05/2010, at 2:43 AM, Jens Alfke <email@hidden> wrote:
On May 30, 2010, at 12:55 AM, Chris Idou wrote:
OK, I see. So is Mobile-Me the only special case, or is there a more general rule about other places to find smtp server passwords?
AFAIK it’s the only special case. In general, an SMTP server’s password is stored under that server name in the keychain, as you’d expect.
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
All the best,
Dante.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden