Return-Path: Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 30241 invoked by uid 500); 2 Jan 2002 22:47:14 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 30230 invoked by uid 500); 2 Jan 2002 22:47:14 -0000 Delivered-To: apmail-apache-1.3-cvs@apache.org Date: 2 Jan 2002 22:47:13 -0000 Message-ID: <20020102224713.14907.qmail@icarus.apache.org> From: bnicholes@apache.org To: apache-1.3-cvs@apache.org Subject: cvs commit: apache-1.3/src/os/netware os.h os.c ApacheCore.imp X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N bnicholes 02/01/02 14:47:13 Modified: src/os/netware os.h os.c ApacheCore.imp Log: Fixed the problem on NetWare when accessing an empty directory which has option indexes specified produces an access forbidden message. Submitted by: Charles Goldman, Guenter Knauf Revision Changes Path 1.23 +4 -0 apache-1.3/src/os/netware/os.h Index: os.h =================================================================== RCS file: /home/cvs/apache-1.3/src/os/netware/os.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- os.h 1 Oct 2001 20:43:24 -0000 1.22 +++ os.h 2 Jan 2002 22:47:13 -0000 1.23 @@ -134,6 +134,10 @@ #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); 1.21 +98 -4 apache-1.3/src/os/netware/os.c Index: os.c =================================================================== RCS file: /home/cvs/apache-1.3/src/os/netware/os.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- os.c 30 Nov 2001 17:24:31 -0000 1.20 +++ os.c 2 Jan 2002 22:47:13 -0000 1.21 @@ -180,7 +180,8 @@ _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 @@ pos = ++colonpos; if (!*pos) { /* No path information */ - return 0; + /* Same as specifying volume:\ */ + return 1; } while (*pos) { @@ -292,6 +294,14 @@ } } + /* 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 @@ #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); @@ -346,6 +404,42 @@ } else 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) 1.11 +1 -0 apache-1.3/src/os/netware/ApacheCore.imp Index: ApacheCore.imp =================================================================== RCS file: /home/cvs/apache-1.3/src/os/netware/ApacheCore.imp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ApacheCore.imp 28 Dec 2001 05:03:08 -0000 1.10 +++ ApacheCore.imp 2 Jan 2002 22:47:13 -0000 1.11 @@ -363,6 +363,7 @@ 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,