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

RE: [Dale Thatcher <subversion@dalethatcher.com>] Posting to the list

From: Sander Striker <striker_at_apache.org>
Date: 2001-09-13 19:27:46 CEST

Quick review of the patch:

The mallocs have got to go. apr_pstrdup seems appropiate for
what you are doing. Use the pool that is passed into the
ra_get_authenticator function.

Sander

> From: Ben Collins-Sussman [mailto:sussman@collab.net]
> Sent: 13 September 2001 19:16
>
> Karl Fogel is currently setup as having to "approve" all new posters
> to the dev list. I'll see if I can fix that. I'm forwarding this
> message to the list.
>
> Joe, Greg, you guys wanna review this patch? It looks extremely useful.
>
> ------- Start of forwarded message -------
> Date: Thu, 13 Sep 2001 17:11:41 +0000
> From: Dale Thatcher <subversion@dalethatcher.com>
> To: Ben Collins-Sussman <sussman@collab.net>
> Subject: Posting to the list
> Message-ID: <20010913171140.A310@grim.ws>
> References: <20010912185106.4e6b3279.supermo@bayarea.net>
> <861ylb58w9.fsf@kepler.ch.collab.net>
> Mime-Version: 1.0
> Content-Type: multipart/mixed; boundary="BOKacYhQ+x31HxR3"
>
>
> --BOKacYhQ+x31HxR3
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
>
> Hi,
>
> For some reason the list isn't letting me post at the moment.
> Would you mind
> forwarding this to the list?
>
> thanks,
>
> - Dale Thatcher
>
> --BOKacYhQ+x31HxR3
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: attachment; filename=patch
>
> Hi,
>
> The following is a patch for all those stranded behind http proxies. It
> allows users to set their http_proxy environment variable in the
> same way as a
> few other programs e.g. dselect and wget.
>
> export http_proxy=http://username:password@proxyhost:proxyport/
>
> It's probably not suitable to go in as is. In fact I'm not sure if most
> people will like passing in the settings from the environment.
> But it allows
> me to checkout while at work which is much better than CVS.
>
> thanks,
>
> - Dale Thatcher
>
> 2001-09-12 Dale Thatcher <subversion@dalethatcher.com>
>
> ra_dav.h
> Added new fields to svn_ra_session_t to store the proxy
> uri, username and password.
> session.c
> Added two new routines proxy_auth_authenticate,
> init_http_proxy and modified svn_ra_get_authenticator to
> call out to the neon http proxy support. User can now set
> the http_proxy environment variable to use a proxy.
>
> Index: ./subversion/libsvn_ra_dav/ra_dav.h
> ===================================================================
> --- ./subversion/libsvn_ra_dav/SVN/text-base/ra_dav.h Wed Sep 12
> 18:45:57 2001
> +++ ./subversion/libsvn_ra_dav/ra_dav.h Wed Sep 12 18:45:57 2001
> @@ -42,6 +42,10 @@
> const char *username;
> const char *password;
>
> + struct uri proxyuri;
> + char *proxyusername;
> + char *proxypassword;
> +
> ne_session *sess; /* HTTP session to server */
> ne_session *sess2;
>
> Index: ./subversion/libsvn_ra_dav/session.c
> ===================================================================
> --- ./subversion/libsvn_ra_dav/SVN/text-base/session.c Wed
> Sep 12 18:45:58 2001
> +++ ./subversion/libsvn_ra_dav/session.c Wed Sep 12 18:51:27 2001
> @@ -84,6 +84,31 @@
> return 0;
> }
>
> +static int request_proxy_auth (void *userdata, const char *realm,
> + char **proxyusername, char **proxypassword)
> +{
> + svn_ra_session_t *ras = userdata;
> + apr_size_t l;
> +
> + l = strlen(ras->proxyusername) + 1;
> + *proxyusername = malloc(l);
> + memcpy(*proxyusername, ras->proxyusername, l);
> +
> + if (ras->proxypassword == NULL)
> + {
> + *proxypassword = malloc(1);
> + **proxypassword = '\0';
> + }
> + else
> + {
> + l = strlen(ras->proxypassword) + 1;
> + *proxypassword = malloc(l);
> + memcpy(*proxypassword, ras->proxypassword, l);
> + }
> +
> + return 0;
> +}
> +
> static svn_error_t * auth_authenticate (void **session_baton,
> void *auth_baton)
> {
> svn_ra_session_t *ras = auth_baton;
> @@ -108,6 +133,80 @@
> auth_authenticate
> };
>
> +static svn_error_t * proxy_auth_authenticate (void
> **session_baton, void *auth_baton,
> + char *authinfo)
> +{
> + char *c;
> + char *usernameend = NULL;
> + apr_size_t l;
> + svn_ra_session_t *ras = auth_baton;
> +
> + /* parse out username and password */
> + ras->proxyusername = NULL;
> +
> + for (c = authinfo; *c != '\0'; c++)
> + {
> + if (usernameend == NULL && *c == ':')
> + {
> + usernameend = c;
> + }
> + }
> +
> + if (usernameend == NULL)
> + {
> + usernameend = c;
> + }
> +
> + l = usernameend - authinfo;
> + ras->proxyusername = apr_pcalloc(ras->pool, l + 1);
> + memcpy(ras->proxyusername, authinfo, l);
> + *(ras->proxyusername + l) = '\0';
> +
> + if (usernameend != c)
> + {
> + l = (c - usernameend) - 1;
> + ras->proxypassword = apr_pcalloc(ras->pool, l + 1);
> + memcpy(ras->proxypassword, usernameend + 1, l);
> + *(ras->proxypassword + l) = '\0';
> + }
> +
> + ne_set_proxy_auth(ras->sess, request_proxy_auth, ras);
> + ne_set_proxy_auth(ras->sess2, request_proxy_auth, ras);
> +
> + *session_baton = ras;
> +
> + return SVN_NO_ERROR;
> +}
> +
> +static svn_error_t * init_http_proxy(void **session_baton, void *baton)
> +{
> + svn_ra_session_t *ras = baton;
> + struct uri proxyuri = ras->proxyuri;
> +
> + if (ne_session_proxy(ras->sess, proxyuri.host, proxyuri.port) ||
> + ne_session_proxy(ras->sess2, proxyuri.host, proxyuri.port))
> + {
> + return svn_error_create(SVN_ERR_RA_ILLEGAL_URL, 0, NULL, ras->pool,
> + "illegal URL for proxy");
> + }
> +
> + if (proxyuri.authinfo != NULL)
> + {
> + svn_error_t *err;
> +
> + err = proxy_auth_authenticate((void **)&ras, ras,
> proxyuri.authinfo);
> + if (err != SVN_NO_ERROR)
> + {
> + return err;
> + }
> + }
> +
> + *session_baton = ras;
> +
> + return SVN_NO_ERROR;
> +}
> +
> +
> /* ### need an ne_session_dup to avoid the second gethostbyname
> * call and make this halfway sane. */
>
> @@ -118,6 +217,7 @@
> apr_pool_t *pool)
> {
> const char *repository = repos_URL->data;
> + const char *httpproxy = getenv("http_proxy");
> apr_size_t len;
> ne_session *sess, *sess2;
> struct uri uri = { 0 };
> @@ -162,6 +262,28 @@
> ne_set_useragent(sess, "SVN/" SVN_VERSION);
> ne_set_useragent(sess2, "SVN/" SVN_VERSION);
>
> + ras = apr_pcalloc(pool, sizeof(*ras));
> + ras->pool = pool;
> + ras->root = uri;
> + ras->sess = sess;
> + ras->sess2 = sess2;
> +
> + /* set the proxy up if required */
> + if (httpproxy != NULL)
> + {
> + struct uri proxyuri;
> +
> + if (uri_parse(httpproxy, &proxyuri, NULL))
> + {
> + return svn_error_create(SVN_ERR_RA_ILLEGAL_URL, 0,
> NULL, ras->pool,
> + "illegal URL for http proxy");
> + }
> +
> + ras->proxyuri = proxyuri;
> +
> + init_http_proxy((void **)&ras, ras);
> + }
> +
> /* we want to know if the repository is actually somewhere else */
> /* ### not yet: http_redirect_register(sess, ... ); */
>
> @@ -203,12 +325,6 @@
> len = strlen(uri.path);
> if (len > 1 && uri.path[len - 1] == '/')
> uri.path[len - 1] = '\0';
> -
> - ras = apr_pcalloc(pool, sizeof(*ras));
> - ras->pool = pool;
> - ras->root = uri;
> - ras->sess = sess;
> - ras->sess2 = sess2;
>
> if (method == SVN_RA_AUTH_USERNAME)
> *authenticator = &username_authenticator;
>
> --BOKacYhQ+x31HxR3--
>
>
> ------- End of forwarded message -------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: dev-help@subversion.tigris.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:41 2006

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.