[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r17619 - in trunk: subversion/include subversion/libsvn_subr

From: Daniel Rall <dlr_at_collab.net>
Date: 2005-12-07 01:48:16 CET

On Sat, 03 Dec 2005, mbk@tigris.org wrote:
...
> On Mac OS, use KeyChain services to store password (Issue 2339).

Very cool!

> Note: SecKeychainSetUserInteractionAllowed (FALSE) does not appear to
> actually prevent all user interaction. Specifically, if the executable
> changes (for example, if it is rebuilt), the system prompts the user
> to okay the use of the new executable.

Perhaps this gotcha should be documented in-line as well?

...
> --- trunk/subversion/libsvn_subr/simple_providers.c (original)
> +++ trunk/subversion/libsvn_subr/simple_providers.c Sat Dec 3 20:16:04 2005
...
> +static svn_boolean_t
> +keychain_password_set (apr_hash_t *creds,
> + const char *realmstring,
> + const char *username,
> + const char *password,
> + svn_boolean_t non_interactive,
> + apr_pool_t *pool)
> +{
> + OSStatus status;
> + SecKeychainItemRef item;
> +
> + if (non_interactive)
> + SecKeychainSetUserInteractionAllowed (FALSE);
> +
> + status = SecKeychainFindGenericPassword (NULL, strlen (realmstring),
> + realmstring, strlen (username),
> + username, 0, NULL, &item);
> + if (status)
> + {
> + if (status == errSecItemNotFound)
> + status = SecKeychainAddGenericPassword (NULL, strlen(realmstring),
> + realmstring, strlen (username),
> + username, strlen (password),
> + password, NULL);
> + }
> + else
> + {
> + status = SecKeychainItemModifyAttributesAndData (item, NULL,
> + strlen (password),
> + password);
> + CFRelease (item);
> + }
> +
> + if (non_interactive)
> + SecKeychainSetUserInteractionAllowed (TRUE);
> +
> + return status == 0;
> +}
...

Are these calls to SecKeychainSetUserInteractionAllowed() thread-local
or something? If not, it seems like there is a race here where
another simultaneously executing application could have its
"interaction allowed" flag toggled. Does the KeyChain API supply some
sort of mutex or sychronization API which can be used in conjunction
with this setting? (I looked around for some documentation on that,
but didn't find much other than other code doing the same thing.)

This possible race is in keychain_password_get() as well.

-- 
Daniel Rall

  • application/pgp-signature attachment: stored
Received on Wed Dec 7 01:46:46 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.