r19182 - gnucash/trunk/src - Make the keychain interface in MacOSX compile and work.
Mike Alexander
mta at code.gnucash.org
Wed May 19 16:27:12 EDT 2010
Author: mta
Date: 2010-05-19 16:27:12 -0400 (Wed, 19 May 2010)
New Revision: 19182
Trac: http://svn.gnucash.org/trac/changeset/19182
Modified:
gnucash/trunk/src/core-utils/gnc-uri-utils.c
gnucash/trunk/src/gnome-utils/gnc-keyring.c
Log:
Make the keychain interface in MacOSX compile and work.
Modified: gnucash/trunk/src/core-utils/gnc-uri-utils.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-uri-utils.c 2010-05-19 16:21:50 UTC (rev 19181)
+++ gnucash/trunk/src/core-utils/gnc-uri-utils.c 2010-05-19 20:27:12 UTC (rev 19182)
@@ -230,9 +230,9 @@
*/
g_return_val_if_fail( hostname != 0, NULL );
- if ( username != NULL )
+ if ( username != NULL && *username )
{
- if ( password != NULL )
+ if ( password != NULL && *password )
userpass = g_strdup_printf ( "%s:%s@", username, password );
else
userpass = g_strdup_printf ( "%s@", username );
Modified: gnucash/trunk/src/gnome-utils/gnc-keyring.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-keyring.c 2010-05-19 16:21:50 UTC (rev 19181)
+++ gnucash/trunk/src/gnome-utils/gnc-keyring.c 2010-05-19 20:27:12 UTC (rev 19182)
@@ -147,33 +147,34 @@
* So we use the security domain parameter to allow us to
* distinguish between these two.
*/
- status = SecKeychainFindInternetPassword( NULL,
- strlen(server), server,
- strlen(access_method), access_method,
- strlen(*user), *user,
- strlen(service), service,
- port,
- kSecProtocolTypeAny,
- kSecAuthenticationTypeDefault,
- &password_length, &password_data,
- NULL);
-
- if ( status == noErr )
+ if (*user != NULL)
{
- *password = (gchar*)xmalloc(( password_length + 1 ) * sizeof(char));
- strncpy(*password, password_data, (size_t)password_length);
- (*password)[password_length] = '\0';
- password_found = TRUE;
- SecKeychainItemFreeContent(NULL, password_data);
+ status = SecKeychainFindInternetPassword( NULL,
+ strlen(server), server,
+ strlen(access_method), access_method,
+ strlen(*user), *user,
+ strlen(service), service,
+ port,
+ kSecProtocolTypeAny,
+ kSecAuthenticationTypeDefault,
+ &password_length, &password_data,
+ NULL);
+
+ if ( status == noErr )
+ {
+ *password = g_strndup(password_data, password_length);
+ password_found = TRUE;
+ SecKeychainItemFreeContent(NULL, password_data);
+ }
+ else
+ {
+ CFStringRef osx_resultstring = SecCopyErrorMessageString( status, NULL );
+ const gchar *resultstring = CFStringGetCStringPtr(osx_resultstring,
+ GetApplicationTextEncoding());
+ PWARN ( "OS X keychain error: %s", resultstring );
+ CFRelease ( osx_resultstring );
+ }
}
- else
- {
- CFStringRef osx_resultstring = SecCopyErrorMessageString( status, NULL );
- const gchar *resultstring = CFStringGetCStringPtr(osx_resultstring,
- GetApplicationTextEncoding());
- PWARN ( "OS X keychain error: %s", resultstring );
- CFRelease ( osx_resultstring );
- }
#endif /* HAVE_OSX_KEYCHAIN */
if ( !password_found )
More information about the gnucash-changes
mailing list