You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Henning Schmiedehausen <hp...@intermeta.de> on 2001/02/18 16:49:18 UTC

config/7268: Including all files in a directory is not exactly a nice idea.

>Number:         7268
>Category:       config
>Synopsis:       Including all files in a directory is not exactly a nice idea.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   apache
>Arrival-Date:   Sun Feb 18 07:50:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     hps@intermeta.de
>Release:        1.3.17
>Organization:
apache
>Environment:
All OS.	
>Description:
I found it pretty annoyed that the new directory include all files in a directory.
It is useful, that some files are excluded. RCS and CVS for version controlling
and Files ending with "~" (emacs backup files). The following patch generalizes
the checks for "." and ".." into a subroutine and adds checks for these file
names.

>How-To-Repeat:

>Fix:
--- apache_1.3.17/src/main/http_config.c        Sun Feb 18 16:42:01 2001
+++ /tmp/http_config.c  Sun Feb 18 16:41:13 2001
@@ -1256,6 +1256,35 @@
     return strcmp(f1->fname,f2->fname);
 }
 
+static char *excl_names[] = {
+  "..",
+  ".",
+  "CVS",
+  "RCS",
+  NULL,
+};
+
+static int check_names(char *str)
+{
+  int i;
+  int l = strlen(str);
+
+  if(!l)
+       return 0;
+
+  while(excl_names[i])
+  {
+       if(!strcmp(str, excl_names[i]))
+         return 0;
+       i++;
+  }
+
+  if(str[l-1] == '~')
+       return 0;
+
+  return 1;
+}
+
 void ap_process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp)
 {
     const char *errmsg;
@@ -1310,8 +1339,7 @@
        candidates = ap_make_array(p, 1, sizeof(fnames));
        while ((dir_entry = readdir(dirp)) != NULL) {
            /* strip out '.' and '..' */
-           if (strcmp(dir_entry->d_name, ".") &&
-               strcmp(dir_entry->d_name, "..")) {
+         if(check_names(dir_entry->d_name)) {
                fnew = (fnames *) ap_push_array(candidates);
                fnew->fname = ap_make_full_path(p, fname, dir_entry->d_name);
            }
>Release-Note:
>Audit-Trail:
>Unformatted:
 [In order for any reply to be added to the PR database, you need]
 [to include <ap...@Apache.Org> in the Cc line and make sure the]
 [subject line starts with the report component and number, with ]
 [or without any 'Re:' prefixes (such as "general/1098:" or      ]
 ["Re: general/1098:").  If the subject doesn't match this       ]
 [pattern, your message will be misfiled and ignored.  The       ]
 ["apbugs" address is not added to the Cc line of messages from  ]
 [the database automatically because of the potential for mail   ]
 [loops.  If you do not include this Cc, your reply may be ig-   ]
 [nored unless you are responding to an explicit request from a  ]
 [developer.  Reply only with text; DO NOT SEND ATTACHMENTS!     ]