mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make the keychain interface in MacOSX compile and work.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19182 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
f796e05b2f
commit
3bcf2f9264
@ -230,9 +230,9 @@ gchar *gnc_uri_create_uri (const gchar *protocol,
|
|||||||
*/
|
*/
|
||||||
g_return_val_if_fail( hostname != 0, NULL );
|
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 );
|
userpass = g_strdup_printf ( "%s:%s@", username, password );
|
||||||
else
|
else
|
||||||
userpass = g_strdup_printf ( "%s@", username );
|
userpass = g_strdup_printf ( "%s@", username );
|
||||||
|
@ -147,32 +147,33 @@ gboolean gnc_keyring_get_password ( GtkWidget *parent,
|
|||||||
* So we use the security domain parameter to allow us to
|
* So we use the security domain parameter to allow us to
|
||||||
* distinguish between these two.
|
* distinguish between these two.
|
||||||
*/
|
*/
|
||||||
status = SecKeychainFindInternetPassword( NULL,
|
if (*user != 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 = (gchar*)xmalloc(( password_length + 1 ) * sizeof(char));
|
status = SecKeychainFindInternetPassword( NULL,
|
||||||
strncpy(*password, password_data, (size_t)password_length);
|
strlen(server), server,
|
||||||
(*password)[password_length] = '\0';
|
strlen(access_method), access_method,
|
||||||
password_found = TRUE;
|
strlen(*user), *user,
|
||||||
SecKeychainItemFreeContent(NULL, password_data);
|
strlen(service), service,
|
||||||
}
|
port,
|
||||||
else
|
kSecProtocolTypeAny,
|
||||||
{
|
kSecAuthenticationTypeDefault,
|
||||||
CFStringRef osx_resultstring = SecCopyErrorMessageString( status, NULL );
|
&password_length, &password_data,
|
||||||
const gchar *resultstring = CFStringGetCStringPtr(osx_resultstring,
|
NULL);
|
||||||
GetApplicationTextEncoding());
|
|
||||||
PWARN ( "OS X keychain error: %s", resultstring );
|
if ( status == noErr )
|
||||||
CFRelease ( osx_resultstring );
|
{
|
||||||
|
*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 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_OSX_KEYCHAIN */
|
#endif /* HAVE_OSX_KEYCHAIN */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user