httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Loic Pefferkorn <loic-apa...@frozenbox.com>
Subject [PATCH] ShowForbidden option for mod_autoindex 2.0.x
Date Sat, 28 Apr 2007 21:16:54 GMT
Hello,

I wrote this small patch to backport ShowForbidden option of 
mod_autoindex from apache 2.2.x to 2.0.x

The patch is very simple, mainly stolen from 2.2.x source code.

I originally wrote it for a friend who can't upgrade right now to 2.2.x

I hope this may be of interest to someone :)

Cheers,
Loic

--- modules/generators/mod_autoindex.c  (révision 533057)
+++ modules/generators/mod_autoindex.c  (copie de travail)
@@ -70,6 +70,7 @@
  #define IGNORE_CLIENT       (1 << 15)
  #define IGNORE_CASE         (1 << 16)
  #define EMIT_XHTML          (1 << 17)
+#define SHOW_FORBIDDEN     (1 << 18)

  #define K_NOADJUST 0
  #define K_ADJUST 1
@@ -373,6 +374,9 @@
          else if (!strcasecmp(w, "XHTML")) {
              option = EMIT_XHTML;
          }
+       else if (!strcasecmp(w, "ShowForbidden")) {
+           option = SHOW_FORBIDDEN;
+       }
          else if (!strcasecmp(w, "None")) {
              if (action != '\0') {
                  return "Cannot combine '+' or '-' with 'None' keyword";
@@ -1252,6 +1256,7 @@
  {
      request_rec *rr;
      struct ent *p;
+    int show_forbidden = 0;

      /* Dot is ignored, Parent is handled by make_parent_entry() */
      if ((dirent->name[0] == '.') && (!dirent->name[1]
@@ -1283,10 +1288,16 @@
      if (!(rr = ap_sub_req_lookup_dirent(dirent, r, AP_SUBREQ_NO_ARGS, 
NULL))) {
          return (NULL);
      }
-
+
+    if((autoindex_opts & SHOW_FORBIDDEN)
+       && (rr->status == HTTP_UNAUTHORIZED || rr->status == 
HTTP_FORBIDDEN)) {
+       show_forbidden = 1;
+    }
+
      if ((rr->finfo.filetype != APR_DIR && rr->finfo.filetype != APR_REG)
          || !(rr->status == OK || ap_is_HTTP_SUCCESS(rr->status)
-                              || ap_is_HTTP_REDIRECT(rr->status))) {
+                              || ap_is_HTTP_REDIRECT(rr->status)
+                             || show_forbidden == 1)) {
          ap_destroy_sub_req(rr);
          return (NULL);
      }

Mime
View raw message