You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Ben Collins-Sussman <su...@collab.net> on 2001/09/13 17:16:00 UTC
[Dale Thatcher ] Posting to the list
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 <su...@dalethatcher.com>
To: Ben Collins-Sussman <su...@collab.net>
Subject: Posting to the list
Message-ID: <20...@grim.ws>
References: <20...@bayarea.net> <86...@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 <su...@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
Re: [Dale Thatcher ] Posting to the list
Posted by Joe Orton <jo...@manyfish.co.uk>.
On Thu, Sep 13, 2001 at 07:27:46PM +0200, Sander Striker wrote:
> 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.
neon doesn't use pools so there are a couple of places where you have to
use malloc/free memory management to be able to use the neon API. (it's
pretty rare though)
joe
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: http proxy support
Posted by Dale Thatcher <su...@dalethatcher.com>.
Hi,
Thanks for the feedback on the patch. According to ne_auth.h the use of
malloc is required. It's already used in the request_auth function in
session.c and gets freed almost immediately by the neon library.
I'll make the changes so that you can pass in a proxy URI with --http-proxy=
and resubmit the patch. Is the URI format ok?
thanks,
- Dale Thatcher
On Thu, Sep 13, 2001 at 11:21:55PM +0200, Branko Cibej wrote:
> Sander Striker wrote:
>
> >Quick review of the patch:
> >
> >The mallocs have got to go.
> >
> Yes.
>
> And so do the getenvs. Use a comand-line option instead.
>
> -1 (veto) on having Subversion's behaviour depend on environment variables.
>
>
> --
> Brane Cibej <br...@xbc.nu> http://www.xbc.nu/brane/
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Http proxy patch [Was: Re: [Dale Thatcher ] Posting to the list]
Posted by Joe Orton <jo...@manyfish.co.uk>.
On Fri, Sep 14, 2001 at 03:06:56PM +0000, Dale Thatcher wrote:
> Hi,
>
> Thanks for the feedback on the patch. According to ne_auth.h the use of
> malloc is required. It's already used in the request_auth function in
> session.c and get's freed almost immediately by the neon library.
>
> I'll make the changes so that you can pass in a proxy URI with --http-proxy=
> and resubmit the patch. Is the URI format ok?
It's bad practice putting the username+password in the URI. I think
these should be dealt with via the same authentication mechanism as
server auth stuff. Otherwise - looks good, thanks!
joe
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: Http proxy patch [Was: Re: [Dale Thatcher ] Posting to the list]
Posted by Branko Čibej <br...@xbc.nu>.
Dale Thatcher wrote:
>Hi,
>
>Thanks for the feedback on the patch. According to ne_auth.h the use of
>malloc is required. It's already used in the request_auth function in
>session.c and get's freed almost immediately by the neon library.
>
Point. I think this particular malloc (in request_proxy_auth) can stay.
But *please* don't use "l" for variable names. "len" or some such would
be better.
And you should use apr_pstrdup where appropriate, instead of using
apr_pcallod&memcpy. There's also an apr_pstrndup, if you have to extract
a substring.
>I'll make the changes so that you can pass in a proxy URI with --http-proxy=
>and resubmit the patch. Is the URI format ok?
>
Someone else will have to answer that one. Greg? Joe?
--
Brane �ibej <br...@xbc.nu> http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Http proxy patch [Was: Re: [Dale Thatcher ] Posting to the list]
Posted by Dale Thatcher <su...@dalethatcher.com>.
Hi,
Thanks for the feedback on the patch. According to ne_auth.h the use of
malloc is required. It's already used in the request_auth function in
session.c and get's freed almost immediately by the neon library.
I'll make the changes so that you can pass in a proxy URI with --http-proxy=
and resubmit the patch. Is the URI format ok?
thanks,
- Dale Thatcher
On Thu, Sep 13, 2001 at 11:21:55PM +0200, Branko Cibej wrote:
> Sander Striker wrote:
>
> >Quick review of the patch:
> >
> >The mallocs have got to go.
> >
> Yes.
>
> And so do the getenvs. Use a comand-line option instead.
>
> -1 (veto) on having Subversion's behaviour depend on environment variables.
>
>
> --
> Brane Cibej <br...@xbc.nu> http://www.xbc.nu/brane/
>
>
>
> ---------------------------------------------------------------------
> 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
Re: [Dale Thatcher ] Posting to the list
Posted by Branko Čibej <br...@xbc.nu>.
Sander Striker wrote:
>Quick review of the patch:
>
>The mallocs have got to go.
>
Yes.
And so do the getenvs. Use a comand-line option instead.
-1 (veto) on having Subversion's behaviour depend on environment variables.
--
Brane �ibej <br...@xbc.nu> http://www.xbc.nu/brane/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
RE: [Dale Thatcher ] Posting to the list
Posted by Sander Striker <st...@apache.org>.
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 <su...@dalethatcher.com>
> To: Ben Collins-Sussman <su...@collab.net>
> Subject: Posting to the list
> Message-ID: <20...@grim.ws>
> References: <20...@bayarea.net>
> <86...@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 <su...@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