]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Fixed the problem on NetWare when accessing an empty directory which
authorBradley Nicholes <bnicholes@apache.org>
Wed, 2 Jan 2002 22:47:13 +0000 (22:47 +0000)
committerBradley Nicholes <bnicholes@apache.org>
Wed, 2 Jan 2002 22:47:13 +0000 (22:47 +0000)
has option indexes specified produces an access forbidden message.
Submitted by: Charles Goldman, Guenter Knauf

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@92708 13f79535-47bb-0310-9956-ffa450edef68

src/os/netware/ApacheCore.imp
src/os/netware/os.c
src/os/netware/os.h

index 4be4ced5f0420e1380c606cd4e64f726b3abafa0..9fbbb9b01bc6c4185040390f19bb30d2346fb288 100644 (file)
  ap_os_http_method,
  os_readdir,
  os_opendir,
+ os_closedir,
  ap_update_vhost_from_headers,
  ap_update_vhost_given_ip,
  ap_set_name_virtual_host,
index 54043fa8051e54926ba58237be0431a2e7146196..d5d8ed7b7fc228511059f90455454be67b49c563 100644 (file)
@@ -180,7 +180,8 @@ char *ap_os_canonical_filename(pool *pPool, const char *szFile)
             _splitpath (ap_server_root, vol, NULL, NULL, NULL);
             pNewName = ap_pstrcat (pPool, vol, pNewName, NULL);
         }
-        if ((slash_test = strchr(pNewName, ':')) && (*(slash_test+1) != '/'))
+        if ((slash_test = strchr(pNewName, ':')) && (*(slash_test+1) != '/') 
+            && (*(slash_test+1) != '\0'))
         {
             char vol[_MAX_VOLUME+1];
         
@@ -261,7 +262,8 @@ int ap_os_is_filename_valid(const char *file)
        pos = ++colonpos;
        if (!*pos) {
                /* No path information */
-               return 0;
+               /* Same as specifying volume:\ */
+               return 1;
     }
 
     while (*pos) {
@@ -292,6 +294,14 @@ int ap_os_is_filename_valid(const char *file)
                }
                }
 
+               /* Test 2.5 */
+               if (seglength == 2) {
+                       if ( (segstart[0] == '.') && (segstart[1] == '.') ) {
+                                       return 1;
+                       }
+               
+               }
+
                /* Test 3 */
                if (segstart[seglength-1] == '.') {
                    return 0;
@@ -323,18 +333,66 @@ int ap_os_is_filename_valid(const char *file)
 #undef opendir_411
 DIR *os_opendir (const char *pathname)
 {
-    DIR *d = opendir_411 (pathname);
+       struct stat s;
+       DIR *d = opendir_411 (pathname);
 
     if (d) {
         strcpy (d->d_name, "<<**");
     }
+
+       if (!d) {
+               /* Let's check if this is an empty directory */
+               if (stat(pathname, &s) != 0)
+                       return NULL;
+               if (!(S_ISDIR(s.st_mode)))
+                       return NULL; 
+               
+               /* If we are here, then this appears to be a directory */
+               /* We allocate a name */
+               d = NULL;
+        d = (DIR *)malloc(sizeof(DIR));
+        if (d) {
+            memset(d, 0, sizeof(DIR));
+            strcpy(d->d_name, "**<<");
+                       d->d_cdatetime = 50;
+
+        }    
+
+       }
+
     return d;
+
 }
 
 #undef readdir_411
 DIR *os_readdir (DIR *dirP)
 {
-    if ((dirP->d_name[0] == '<') && (dirP->d_name[2] == '*')) {
+
+/*
+ * First three if statements added for empty directory support.
+ *
+ */
+    if (  (dirP->d_cdatetime == 50) && (dirP->d_name[0] == '*') &&
+                 (dirP->d_name[2] == '<') )
+    {
+        strcpy (dirP->d_name, ".");
+        strcpy (dirP->d_nameDOS, ".");
+        return (dirP);
+    }
+    else if ((dirP->d_cdatetime == 50) &&
+             (dirP->d_name[0] == '.') &&
+             (dirP->d_name[1] == '\0')) {
+        strcpy (dirP->d_name, "..");
+        strcpy (dirP->d_nameDOS, "..");
+        return (dirP);
+    }
+    else if ( (dirP->d_cdatetime == 50) &&
+             (dirP->d_name[0] == '.') &&
+             (dirP->d_name[1] == '.') &&
+             (dirP->d_name[2] == '\0') ) {
+        return (NULL);
+    }
+    else if ((dirP->d_name[0] == '<') && (dirP->d_name[2] == '*')) {
         strcpy (dirP->d_name, ".");
         strcpy (dirP->d_nameDOS, ".");
         return (dirP);
@@ -348,6 +406,42 @@ DIR *os_readdir (DIR *dirP)
         return readdir_411 (dirP);
 }
 
+
+#undef closedir_510
+int os_closedir (DIR *dirP)
+{
+/*
+ * Modified to handle empty directories.
+ *
+ */
+
+       if (dirP == NULL) {
+               return 0;
+       }
+
+    if (  (  (dirP->d_cdatetime == 50) && (dirP->d_name[0] == '*') &&
+                        (dirP->d_name[2] == '<') 
+                 ) ||
+                 (      (dirP->d_cdatetime == 50) && (dirP->d_name[0] == '.') &&
+                    (dirP->d_name[1] == '\0')
+                 ) ||
+                 (      (dirP->d_cdatetime == 50) && (dirP->d_name[0] == '.') &&
+                    (dirP->d_name[1] == '.') && (dirP->d_name[2] == '\0')
+                 )
+       )
+       {
+
+              free(dirP); 
+              dirP = NULL;
+              return 0;
+       }
+       else {
+              return closedir_510(dirP);
+       }
+               
+
+}
+
 char *ap_os_http_method(void *r)
 {
     int s = ((request_rec*)r)->connection->client->fd;
index 39ab02f95bbc70b4f75d190eaa2aae90e41ac231..85021a9f4f6393911f11b85930dfd293548c0134 100644 (file)
@@ -134,6 +134,10 @@ DIR *os_opendir (const char *pathname);
 #define readdir(p) os_readdir(p)
 DIR *os_readdir (DIR *dirP);
 
+#define closedir_510(p) os_closedir(p)
+#define closedir(p) os_closedir(p)
+int os_closedir (DIR *dirP);
+
 /* Prototypes */
 void AMCSocketCleanup(void);
 void clean_parent_exit(int code);