KeyError with non-existent repositories (hgwebdir.cgi)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

KeyError with non-existent repositories (hgwebdir.cgi)

Maxim Khitrov
Hello,

I'm trying to configure hgwebdir.cgi script to serve a few of my
repositories via Lighttpd. I'm using rewrite rules to send all
requests to the cgi script, and the whole thing works great for the
repositories that are there.

My question is about requests for non-existent directories. If I try
to access some random path that does not point to a valid repository,
I get a KeyError message with a ton of output containing the call
trace. My problem with this is that it exposes all the relevant paths
on the server. Where hgwebdir.cgi is running from, where python is
installed, and so on. I'm curious to know if there is some way to
suppress this output? For example, just send a 404 error instead.

If nothing like that exists right now, perhaps it is something worth
adding as a configuration option to hgweb.config?

Would appreciate any help on this.
Thanks.
_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: KeyError with non-existent repositories (hgwebdir.cgi)

Matt Mackall
On Sat, Jul 14, 2007 at 03:27:30PM -0400, Maxim Khitrov wrote:

> Hello,
>
> I'm trying to configure hgwebdir.cgi script to serve a few of my
> repositories via Lighttpd. I'm using rewrite rules to send all
> requests to the cgi script, and the whole thing works great for the
> repositories that are there.
>
> My question is about requests for non-existent directories. If I try
> to access some random path that does not point to a valid repository,
> I get a KeyError message with a ton of output containing the call
> trace. My problem with this is that it exposes all the relevant paths
> on the server. Where hgwebdir.cgi is running from, where python is
> installed, and so on. I'm curious to know if there is some way to
> suppress this output? For example, just send a 404 error instead.
>
> If nothing like that exists right now, perhaps it is something worth
> adding as a configuration option to hgweb.config?

Comment out cgitb.enable() in your hgwebdir.cgi script.

--
Mathematics is the supreme nostalgia of our time.
_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: KeyError with non-existent repositories (hgwebdir.cgi)

Brendan Cully
In reply to this post by Maxim Khitrov
On Saturday, 14 July 2007 at 15:27, Maxim Khitrov wrote:

> Hello,
>
> I'm trying to configure hgwebdir.cgi script to serve a few of my
> repositories via Lighttpd. I'm using rewrite rules to send all
> requests to the cgi script, and the whole thing works great for the
> repositories that are there.
>
> My question is about requests for non-existent directories. If I try
> to access some random path that does not point to a valid repository,
> I get a KeyError message with a ton of output containing the call
> trace. My problem with this is that it exposes all the relevant paths
> on the server. Where hgwebdir.cgi is running from, where python is
> installed, and so on. I'm curious to know if there is some way to
> suppress this output? For example, just send a 404 error instead.

You are probably running the hgwebdir gitweb style? It was missing the
'notfound' template for a long time. It was fixed about a week ago in
d39776752a1f.

_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: KeyError with non-existent repositories (hgwebdir.cgi)

Maxim Khitrov
On 7/14/07, Brendan Cully <[hidden email]> wrote:

> On Saturday, 14 July 2007 at 15:27, Maxim Khitrov wrote:
> > Hello,
> >
> > I'm trying to configure hgwebdir.cgi script to serve a few of my
> > repositories via Lighttpd. I'm using rewrite rules to send all
> > requests to the cgi script, and the whole thing works great for the
> > repositories that are there.
> >
> > My question is about requests for non-existent directories. If I try
> > to access some random path that does not point to a valid repository,
> > I get a KeyError message with a ton of output containing the call
> > trace. My problem with this is that it exposes all the relevant paths
> > on the server. Where hgwebdir.cgi is running from, where python is
> > installed, and so on. I'm curious to know if there is some way to
> > suppress this output? For example, just send a 404 error instead.
>
> You are probably running the hgwebdir gitweb style? It was missing the
> 'notfound' template for a long time. It was fixed about a week ago in
> d39776752a1f.

Indeed I am. I tried commenting out cgitb.enable() as Matt suggested
before I got your message and that method worked fine.

Following your suggestion, I also downloaded the latest gitweb
template. While the new version does display the 'not found' error, it
has a bit of a problem with css style. The URL it generates for the
not found error css contains the missing repository name. That has to
be removed, otherwise you just get another not found error for the
style sheet. Other than that it works exactly as it should.

I'm going to stick with the cgitb.enable() method, because there are
actually a few more errors that I found. For example, if you create a
brand new repository (hg init) and allow bz2 or zip archives, both of
those operations fail with an IndexError. Minor issue, but should
still probably be fixed (download an empty archive) in the future
release. Until then I'll disable all error reporting.

Thanks for your help guys!
_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial