Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jan 2006 23:33:32 -0500
From:      Jonathan Noack <noackjr@alumni.rice.edu>
To:        Manuel Lemos <mlemos@acm.org>
Cc:        freebsd-cvsweb@freebsd.org
Subject:   Re: Hiding some directories
Message-ID:  <43C5DC1C.9040209@alumni.rice.edu>
In-Reply-To: <43C5CEBC.6070908@acm.org>
References:  <OF96243472.5A043BB8-ON072570F3.0070D138-072570F3.0071175F@microchip.com> <43C5CEBC.6070908@acm.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040608050106060802090807
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Manuel Lemos wrote:
> on 01/11/2006 06:35 PM Jerry.Nairn@microchip.com said the following:
>  >> Is there a way to hide some directories besides CVSROOT?
>  >
>  > See the @ForbiddenFiles array in cvsweb.conf.
> 
> Thanks, that is what I am looking for.
> 
> BTW, I am not familiar enough with Perl. Although I was able to 
> configure that array to forbid all directories that I did not want, I 
> wonder if is there a way to specify in that array just a few top level 
> directories that I want.

How about an @AllowedFiles list that only displays files and directories 
that match?  See attached patches for cvsweb.cgi and cvsweb.conf.

-Jonathan

--------------040608050106060802090807
Content-Type: text/plain;
 name="cvsweb.cgi.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cvsweb.cgi.diff"

--- cvsweb.cgi.old	Wed Jan 11 22:12:42 2006
+++ cvsweb.cgi	Wed Jan 11 23:15:30 2006
@@ -82,7 +82,7 @@
   $allow_log_extra $allow_dir_extra $allow_source_extra
   $allow_cvsgraph $cvsgraph_config $use_java_script $edit_option_form
   $show_subdir_lastmod $show_log_in_markup $preformat_in_markup
-  $tabstop $state $annTable $sel @ForbiddenFiles
+  $tabstop $state $annTable $sel @ForbiddenFiles @AllowedFiles
   $use_descriptions %descriptions @mytz $dwhere
   $use_moddate $gzip_open $file_list_len
   $allow_tar @tar_options @gzip_options @zip_options @cvs_options
@@ -4339,7 +4339,10 @@
 
 
 #
-# See if a file/dir is listed in the config file's @ForbiddenFiles list.
+# If a file/dir is listed in the config file's @ForbiddenFiles list,
+# forbid access to it.  If the @AllowedFiles list is defined in the config
+# file then a file/dir must be listed for access to be granted.
+# @ForbiddenFiles takes precedence over @AllowedFiles.
 # Takes a full file system path or one relative to $cvsroot, and strips the
 # trailing ",v" if present, then compares.  Returns 1 if forbidden, else 0.
 #
@@ -4349,6 +4352,12 @@
   $path =~ s|^$cvsroot/+||;
   for my $forbidden_re (@ForbiddenFiles) {
     return 1 if ($path =~ $forbidden_re);
+  }
+  if (($cvsroot ne $path) && (defined(@AllowedFiles))) {
+    for my $allowed_re (@AllowedFiles) {
+      return 0 if ($path =~ $allowed_re);
+    }
+    return 1;
   }
   return 0;
 }

--------------040608050106060802090807
Content-Type: text/plain;
 name="cvsweb.conf.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cvsweb.conf.diff"

--- cvsweb.conf.dist	Thu Dec  1 23:10:10 2005
+++ cvsweb.conf	Wed Jan 11 23:24:16 2006
@@ -266,6 +266,17 @@
    #qr|^my/+secret/+dir|o,
 );
 
+# Regular expressions for files and directories which should be shown.
+# Each regexp is compared against a path relative to a CVS root, after
+# stripping the trailing ",v" if present.  Only matching files and
+# directories are displayed.
+# @ForbiddenFiles takes precedence over @AllowedFiles.
+# If @AllowedFiles is not defined, only @ForbiddenFiles is enforced.
+#
+#@AllowedFiles = (
+   #qr|^my/+public/+dir|o,
+#);
+
 # Use CVSROOT/descriptions for describing the directories/modules?
 # See INSTALL, section 9.
 #

--------------040608050106060802090807--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43C5DC1C.9040209>