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

Re: svn commit: r38004 - in trunk/subversion: libsvn_auth_kwallet svn svnsync

From: Arfrever Frehtes Taifersar Arahesis <Arfrever.FTA_at_GMail.Com>
Date: Sun, 14 Jun 2009 08:50:48 +0200

2009-06-12 09:33:14 Bert Huijben napisaƂ(a):
> > -----Original Message-----
> > From: Arfrever Frehtes Taifersar Arahesis [mailto:Arfrever.FTA_at_GMail.Com]
> > Sent: donderdag 11 juni 2009 22:51
> > To: svn_at_subversion.tigris.org
> > Subject: svn commit: r38004 - in trunk/subversion: libsvn_auth_kwallet svn
> > svnsync
> >
> > Author: arfrever
> > Date: Thu Jun 11 13:50:42 2009
> > New Revision: 38004
> >
> > Log:
> > Make KWallet window attached to terminal window.
> > (Currently implemented only on Linux.)
> >
> > * subversion/libsvn_auth_kwallet/kwallet.cpp
> > (INITIALIZE_APPLICATION): New macro.
> > (get_application_name): Simplify.
> > (get_parent_pid, get_wid): New function.
> > (get_wallet): Add 'pool' argument. Use WId retrieved by get_wid().
> > (kwallet_terminate): Update call to get_wallet().
> > (kwallet_password_get, kwallet_password_set): Use INITIALIZE_APPLICATION.
> > Update calls to get_wallet().
> >
> > * subversion/svn/main.c
> > (main):
> > * subversion/svnsync/main.c
> > (main): Set SVN_QAPPLICATION_SAFE environment variable.
>
> Why do you use a new environment variable to talk with a library, while you could just use the configuration passed to the kwallet provider?

I changed it to parameter of authentication baton in r38028.

> libsvn_auth_kwallet is part of a library used by several clients, not just a part of svn and svnsync, ..., ...
>
> Maybe --non-interactive or revving the api would be a better check for this behavior?

--non-interactive completely disables using of KWallet.

> > Modified:
> > trunk/subversion/libsvn_auth_kwallet/kwallet.cpp
> > trunk/subversion/svn/main.c
> > trunk/subversion/svnsync/main.c
> >
> > Modified: trunk/subversion/libsvn_auth_kwallet/kwallet.cpp
> > URL:
> > http://svn.collab.net/viewvc/svn/trunk/subversion/libsvn_auth_kwallet/kwallet.
> > cpp?pathrev=38004&r1=38003&r2=38004
> > ==============================================================================
> > --- trunk/subversion/libsvn_auth_kwallet/kwallet.cpp Thu Jun 11 13:50:03
> > 2009 (r38003)
> > +++ trunk/subversion/libsvn_auth_kwallet/kwallet.cpp Thu Jun 11 13:50:42
> > 2009 (r38004)
> > @@ -22,6 +22,7 @@
> >
>
> > /*** Includes. ***/
> >
> > +#include <stdlib.h>
> > #include <string.h>
> > #include <unistd.h>
> >
> > @@ -30,6 +31,9 @@
> > #include "svn_auth.h"
> > #include "svn_config.h"
> > #include "svn_error.h"
> > +#include "svn_io.h"
> > +#include "svn_pools.h"
> > +#include "svn_string.h"
> > #include "svn_version.h"
> >
> > #include "private/svn_auth_private.h"
> > @@ -38,13 +42,20 @@
> >
> > #include <dbus/dbus.h>
> > #include <QtCore/QCoreApplication>
> > +#include <QtCore/QList>
> > +#include <QtCore/QMap>
> > #include <QtCore/QString>
> > +#include <QtGui/QApplication>
> > +#include <QtGui/QX11Info>
> >
> > #include <kaboutdata.h>
> > #include <kcmdlineargs.h>
> > #include <kcomponentdata.h>
> > #include <klocalizedstring.h>
> > #include <kwallet.h>
> > +#include <kwindowsystem.h>
> > +#include <netwm.h>
> > +#include <netwm_def.h>
> >
> >
>
> > /*-----------------------------------------------------------------------*/
> > @@ -52,6 +63,26 @@
> > /*-----------------------------------------------------------------------*/
> >
> >
> > +#define INITIALIZE_APPLICATION \
> > + if (getenv("SVN_QAPPLICATION_SAFE")) \
> > + { \
> > + QApplication *app; \
> > + if (! qApp) \
> > + { \
> > + int argc = 1; \
> > + app = new QApplication(argc, (char *[1]) {(char *) "svn"}); \
> > + } \
> > + } \
> > + else \
> > + { \
> > + QCoreApplication *app; \
> > + if (! qApp) \
> > + { \
> > + int argc = 1; \
> > + app = new QCoreApplication(argc, (char *[1]) {(char *) "svn"}); \
> > + } \
> > + }
> > +
> > static const char *
> > get_application_name(apr_hash_t *parameters,
> > apr_pool_t *pool)
> > @@ -69,8 +100,7 @@ get_application_name(apr_hash_t *paramet
> > const char *svn_application_name;
> > if (svn_application_name_with_pid)
> > {
> > - long pid = getpid();
> > - svn_application_name = apr_psprintf(pool, "Subversion [%ld]", pid);
> > + svn_application_name = apr_psprintf(pool, "Subversion [%ld]",
> > long(getpid()));
> > }
> > else
> > {
> > @@ -102,9 +132,93 @@ get_wallet_name(apr_hash_t *parameters)
> > }
> > }
> >
> > +static pid_t
> > +get_parent_pid(pid_t pid, apr_pool_t *pool)
> > +{
> > + pid_t parent_pid = 0;
> > +
> > +#ifdef __linux__
> > + svn_error_t *err;
> > + const char *path;
> > + svn_stream_t *stream;
> > + svn_string_t *string;
> > + const char *preceeding_space, *following_space, *parent_pid_string;
> > +
> > + path = apr_psprintf(pool, "/proc/%ld/stat", long(pid));
> > + err = svn_stream_open_readonly(&stream, path, pool, pool);
> > + if (err == SVN_NO_ERROR)
> > + {
> > + err = svn_string_from_stream(&string, stream, pool, pool);
> > + if (err == SVN_NO_ERROR)
> > + {
> > + if ((preceeding_space = strchr(string->data, ' ' )))
> > + {
> > + if ((preceeding_space = strchr(preceeding_space + 1, ' ')))
> > + {
> > + if ((preceeding_space = strchr(preceeding_space + 1, ' ')))
> > + {
> > + if ((following_space = strchr(preceeding_space + 1, '
> > ')))
> > + {
> > + parent_pid_string = apr_pstrndup(pool,
> > + preceeding_space +
> > 1,
> > + following_space -
> > preceeding_space);
> > + parent_pid = atol(parent_pid_string);
> > + }
> > + }
> > + }
> > + }
> > + }
> > + }
> > +
> > + if (err)
> > + {
> > + svn_error_clear(err);
> > + }
> > +#endif
> > +
> > + return parent_pid;
> > +}
> > +
> > +static WId
> > +get_wid(apr_pool_t *pool)
> > +{
> > + WId wid = -1;
> > +
> > + if (getenv("SVN_QAPPLICATION_SAFE"))
> > + {
> > + QMap<pid_t, WId> process_info_list;
> > + QList<WId> windows(KWindowSystem::windows());
> > + QList<WId>::const_iterator i;
> > + for (i = windows.begin(); i != windows.end(); i++)
> > + {
> > + process_info_list[NETWinInfo(QX11Info::display(),
> > + *i,
> > + QX11Info::appRootWindow(),
> > + NET::WMPid).pid()] = *i;
> > + }
> > +
> > + apr_pool_t *subpool = svn_pool_create(pool);
> > + pid_t pid = getpid();
> > + while (pid != 0)
> > + {
> > + svn_pool_clear(subpool);
> > + if (process_info_list.contains(pid))
> > + {
> > + wid = process_info_list[pid];
> > + break;
> > + }
> > + pid = get_parent_pid(pid, pool);
> > + }
> > + svn_pool_destroy(subpool);
> > + }
> > +
> > + return wid;
> > +}
> > +
> > static KWallet::Wallet *
> > get_wallet(QString wallet_name,
> > - apr_hash_t *parameters)
> > + apr_hash_t *parameters,
> > + apr_pool_t *pool)
> > {
> > KWallet::Wallet *wallet =
> > static_cast<KWallet::Wallet *> (apr_hash_get(parameters,
> > @@ -115,7 +229,7 @@ get_wallet(QString wallet_name,
> > APR_HASH_KEY_STRING))
> > {
> > wallet = KWallet::Wallet::openWallet(wallet_name,
> > - -1,
> > + pool ? get_wid(pool) : -1,
> > KWallet::Wallet::Synchronous);
> > }
> > if (wallet)
> > @@ -141,7 +255,7 @@ kwallet_terminate(void *data)
> > apr_hash_t *parameters = static_cast<apr_hash_t *> (data);
> > if (apr_hash_get(parameters, "kwallet-initialized", APR_HASH_KEY_STRING))
> > {
> > - KWallet::Wallet *wallet = get_wallet(NULL, parameters);
> > + KWallet::Wallet *wallet = get_wallet(NULL, parameters, NULL);
> > delete wallet;
> > apr_hash_set(parameters,
> > "kwallet-initialized",
> > @@ -172,12 +286,7 @@ kwallet_password_get(const char **passwo
> > return FALSE;
> > }
> >
> > - QCoreApplication *app;
> > - if (! qApp)
> > - {
> > - int argc = 1;
> > - app = new QCoreApplication(argc, (char *[1]) {(char *) "svn"});
> > - }
> > + INITIALIZE_APPLICATION
> >
> > KCmdLineArgs::init(1,
> > (char *[1]) {(char *) "svn"},
> > @@ -195,7 +304,7 @@ kwallet_password_get(const char **passwo
> > QString::fromUtf8(username) + "@" + QString::fromUtf8(realmstring);
> > if (! KWallet::Wallet::keyDoesNotExist(wallet_name, folder, key))
> > {
> > - KWallet::Wallet *wallet = get_wallet(wallet_name, parameters);
> > + KWallet::Wallet *wallet = get_wallet(wallet_name, parameters, pool);
> > if (wallet)
> > {
> > apr_hash_set(parameters,
> > @@ -242,12 +351,7 @@ kwallet_password_set(apr_hash_t *creds,
> > return FALSE;
> > }
> >
> > - QCoreApplication *app;
> > - if (! qApp)
> > - {
> > - int argc = 1;
> > - app = new QCoreApplication(argc, (char *[1]) {(char *) "svn"});
> > - }
> > + INITIALIZE_APPLICATION
> >
> > KCmdLineArgs::init(1,
> > (char *[1]) {(char *) "svn"},
> > @@ -262,7 +366,7 @@ 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 = get_wallet(wallet_name, parameters);
> > + KWallet::Wallet *wallet = get_wallet(wallet_name, parameters, pool);
> > if (wallet)
> > {
> > apr_hash_set(parameters,
> >
> > Modified: trunk/subversion/svn/main.c
> > URL:
> > http://svn.collab.net/viewvc/svn/trunk/subversion/svn/main.c?pathrev=38004&r1=
> > 38003&r2=38004
> > ==============================================================================
> > --- trunk/subversion/svn/main.c Thu Jun 11 13:50:03 2009 (r38003)
> > +++ trunk/subversion/svn/main.c Thu Jun 11 13:50:42 2009 (r38004)
> > @@ -1133,6 +1133,10 @@ main(int argc, const char *argv[])
> > }
> > #endif
> >
> > +#ifdef __USE_BSD
> > + setenv("SVN_QAPPLICATION_SAFE", "1", 1);
> > +#endif
> > +
> > /* Initialize the RA library. */
> > err = svn_ra_initialize(pool);
> > if (err)
> >
> > Modified: trunk/subversion/svnsync/main.c
> > URL:
> > http://svn.collab.net/viewvc/svn/trunk/subversion/svnsync/main.c?pathrev=38004
> > &r1=38003&r2=38004
> > ==============================================================================
> > --- trunk/subversion/svnsync/main.c Thu Jun 11 13:50:03 2009 (r38003)
> > +++ trunk/subversion/svnsync/main.c Thu Jun 11 13:50:42 2009 (r38004)
> > @@ -2108,6 +2108,10 @@ main(int argc, const char *argv[])
> >
> > pool = svn_pool_create(NULL);
> >
> > +#ifdef __USE_BSD
> > + setenv("SVN_QAPPLICATION_SAFE", "1", 1);
> > +#endif
> > +
> > err = svn_ra_initialize(pool);
> > if (err)
> > return svn_cmdline_handle_exit_error(err, pool, "svnsync: ");
> >

-- 
Arfrever Frehtes Taifersar Arahesis

Received on 2009-06-14 08:50:48 CEST

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.