Re: [viewvc-users] forbiddenre not quite working

Dave Holland <[email protected]>
Newsgroups gmane.comp.version-control.cvs.viewcvs.user
Message-ID <20100526122224.GA2089__40990.4493870728$1274876556$gmane$org@sanger.ac.uk>
On Tue, May 25, 2010 at 02:19:13PM -0400, C. Michael Pilato wrote:
> I hate to ask, but it's already bitten me with another debugging situation
> today, so here goes:  is the browser cache getting in the way?  Try setting
> http_expiration_time=0 and generate_etags=0 in viewvc.conf, clearing your
> browser cache, and re-hitting the root listing page.

Fair point - I'd disabled use of the web proxy but not thought about
etags etc, thanks. Unfortunately setting those variables didn't help.

I'm not fluent in Python. However, it appears that is_forbidden isn't
being called anywhere in the view_roots code path. Here's a pretty
crude hack that that calls is_forbidden in load_config, which is
probably the wrong place to do it, and (I think) isn't sensible if you
use forbidden rather than forbiddenre. I think it would be better to
put the check in view_roots but I don't know enough Python to unpick
the data structures there. Help, please?

Cheers,
Dave
-- 
** Dave Holland ** Systems Support -- Infrastructure Management **
** 01223 496923 ** The Sanger Institute, Hinxton, Cambridge, UK **
"For every action, there is an equal and opposite malfunction."



-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE.
viewvc-forbiddenre-patch (text/plain, 1.8 KB)
--- /root/viewvc-1.0.9-lenny-build/viewvc-1.0.9/lib/viewvc.py	2010-05-25 16:21:30.000000000 +0100
+++ viewvc.py	2010-05-26 11:33:57.000000000 +0100
@@ -3708,10 +3708,12 @@
         if (repo_type == 'cvs'
             and (os.path.exists(os.path.join(pp, subpath, "CVSROOT", "config"))
                  or (cvsroot and (subpath != 'CVSROOT'
-                                  or not cfg.options.hide_cvsroot)))):
+                                  or not cfg.options.hide_cvsroot))) and \
+		(cfg.is_forbidden(subpath,"",vclib.FILE) == 0)):
           cfg.general.cvs_roots[subpath] = os.path.join(pp, subpath)
-        elif repo_type == 'svn' and \
-             os.path.exists(os.path.join(pp, subpath, "format")):
+        elif (repo_type == 'svn' and \
+             os.path.exists(os.path.join(pp, subpath, "format")) and \
+		(cfg.is_forbidden(subpath,"",vclib.FILE) == 0)):
           cfg.general.svn_roots[subpath] = os.path.join(pp, subpath)
 
   debug.t_end('load-config')
--- /root/viewvc-1.0.9-lenny-build/viewvc-1.0.9/lib/config.py	2008-02-28 15:18:12.000000000 +0000
+++ config.py	2010-05-26 11:43:33.000000000 +0100
@@ -227,14 +227,18 @@
 
   def is_forbidden(self, root, path_parts, pathtype):
     # If we don't have a root and path to check, get outta here.
-    if not (root and path_parts):
+    #if not (root and path_parts):
+    if not (root):
       return 0
 
     # Give precedence to the new 'forbiddenre' stuff first.
     if self.general.forbiddenre:
 
       # Join the root and path-parts together into one path-like thing.
-      root_and_path = string.join([root] + path_parts, "/")
+      if(root and path_parts):
+        root_and_path = string.join([root] + path_parts, "/")
+      else:
+        root_and_path = root
       if pathtype == vclib.DIR:
         root_and_path = root_and_path + '/'
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.