2008-11-10 18:14:30 Greg Stein napisaĆ(a):
> Ugh. A global variable?!
>
> Isn't there a way to put the wallet into some auth provider specific
> memory? Having a global variable means that the library cannot open
> two wallets now. Some third-party client may want to do that!
Fixed in r34219.
> On Mon, Nov 10, 2008 at 8:39 AM, <arfrever_at_tigris.org> wrote:
> > Author: arfrever
> > Date: Mon Nov 10 08:39:54 2008
> > New Revision: 34130
> >
> > Log:
> > Don't reopen already opened wallet.
> >
> > * subversion/libsvn_auth_kwallet/kwallet.cpp
> > (wallet): New.
> > (kwallet_password_get, kwallet_password_set): Open wallet only when wallet
> > wasn't opened earlier.
> > (kwallet_disconnect): New.
> >
> > Modified:
> > trunk/subversion/libsvn_auth_kwallet/kwallet.cpp
> >
> > Modified: trunk/subversion/libsvn_auth_kwallet/kwallet.cpp
> > URL: http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_auth_kwallet/kwallet.cpp?pathrev=34130&r1=34129&r2=34130
> > ==============================================================================
> > --- trunk/subversion/libsvn_auth_kwallet/kwallet.cpp Mon Nov 10 08:31:15 2008 (r34129)
> > +++ trunk/subversion/libsvn_auth_kwallet/kwallet.cpp Mon Nov 10 08:39:54 2008 (r34130)
> > @@ -48,6 +48,9 @@
> > /* KWallet simple provider, puts passwords in KWallet */
> > /*-----------------------------------------------------------------------*/
> >
> > +
> > +static KWallet::Wallet *wallet;
> > +
> > static QString
> > get_wallet_name(apr_hash_t *parameters)
> > {
> > @@ -108,10 +111,10 @@ kwallet_password_get(const char **passwo
> > QString::fromUtf8(username) + "@" + QString::fromUtf8(realmstring);
> > if (! KWallet::Wallet::keyDoesNotExist(wallet_name, folder, key))
> > {
> > - KWallet::Wallet *wallet =
> > - KWallet::Wallet::openWallet(wallet_name,
> > - -1,
> > - KWallet::Wallet::Synchronous);
> > + if (! wallet)
> > + wallet = KWallet::Wallet::openWallet(wallet_name,
> > + -1,
> > + KWallet::Wallet::Synchronous);
> > if (wallet && wallet->setFolder(folder))
> > {
> > QString q_password;
> > @@ -123,7 +126,6 @@ kwallet_password_get(const char **passwo
> > ret = TRUE;
> > }
> > }
> > - delete wallet;
> > }
> >
> > // This function currently closes the wallet if no other application
> > @@ -168,10 +170,10 @@ kwallet_password_set(apr_hash_t *creds,
> > QString q_password = QString::fromUtf8(password);
> > QString wallet_name = get_wallet_name(parameters);
> > QString folder = QString::fromUtf8("Subversion");
> > - KWallet::Wallet *wallet =
> > - KWallet::Wallet::openWallet(wallet_name,
> > - -1,
> > - KWallet::Wallet::Synchronous);
> > + if (! wallet)
> > + wallet = KWallet::Wallet::openWallet(wallet_name,
> > + -1,
> > + KWallet::Wallet::Synchronous);
> > if (wallet)
> > {
> > if (! wallet->hasFolder(folder))
> > @@ -188,7 +190,6 @@ kwallet_password_set(apr_hash_t *creds,
> > }
> > }
> > }
> > - delete wallet;
> >
> > // This function currently closes the wallet if no other application
> > // is connected to the wallet. We're waiting for this to be fixed
> > @@ -198,6 +199,12 @@ kwallet_password_set(apr_hash_t *creds,
> > return ret;
> > }
> >
> > +__attribute__((destructor))
> > +void kwallet_disconnect()
> > +{
> > + delete wallet;
> > +}
> > +
> > /* Get cached encrypted credentials from the simple provider's cache. */
> > static svn_error_t *
> > kwallet_simple_first_creds(void **credentials,
> >
--
Arfrever Frehtes Taifersar Arahesis
Received on 2008-11-16 20:49:22 CET