This patch can be applied to Apache 1.3.2 to fix a problem with htaccess checks. The fix is valid for all systems, but the bug is only visible while using PHP 3.04 on Linux. ....Roy Fielding Index: http_config.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/http_config.c,v retrieving revision 1.127 retrieving revision 1.134 diff -u -r1.127 -r1.134 --- http_config.c 1998/09/19 21:54:57 1.127 +++ http_config.c 1998/09/26 00:07:08 1.134 @@ -1206,7 +1206,7 @@ char *filename = NULL; const struct htaccess_result *cache; struct htaccess_result *new; - void *dc; + void *dc = NULL; /* firstly, search cache */ for (cache = r->htaccess; cache != NULL; cache = cache->next) @@ -1224,41 +1224,39 @@ parms.path = ap_pstrdup(r->pool, d); /* loop through the access names and find the first one */ - while (!f && access_name[0]) { - char *w = ap_getword_conf(r->pool, &access_name); - filename = ap_make_full_path(r->pool, d, w); - f = ap_pcfg_openfile(r->pool, filename); - } - if (f) { - dc = ap_create_per_dir_config(r->pool); - - parms.config_file = f; - - errmsg = ap_srm_command_loop(&parms, dc); - - ap_cfg_closefile(f); - - if (errmsg) { - ap_log_rerror(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, r, "%s: %s", - filename, errmsg); - ap_table_setn(r->notes, "error-notes", errmsg); - return HTTP_INTERNAL_SERVER_ERROR; - } - *result = dc; - } - else { - if (errno == ENOENT || errno == ENOTDIR) - dc = NULL; - else { - ap_log_rerror(APLOG_MARK, APLOG_CRIT, r, - "%s pcfg_openfile: unable to check htaccess file, ensure it is readable", - filename); - ap_table_setn(r->notes, "error-notes", - "Server unable to read htaccess file, denying " - "access to be safe"); - return HTTP_FORBIDDEN; - } + while (access_name[0]) { + filename = ap_make_full_path(r->pool, d, + ap_getword_conf(r->pool, &access_name)); + + if ((f = ap_pcfg_openfile(r->pool, filename)) != NULL) { + + dc = ap_create_per_dir_config(r->pool); + + parms.config_file = f; + + errmsg = ap_srm_command_loop(&parms, dc); + + ap_cfg_closefile(f); + + if (errmsg) { + ap_log_rerror(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, r, + "%s: %s", filename, errmsg); + return HTTP_INTERNAL_SERVER_ERROR; + } + *result = dc; + break; + } + else if (errno != ENOENT && errno != ENOTDIR) { + ap_log_rerror(APLOG_MARK, APLOG_CRIT, r, + "%s pcfg_openfile: unable to check htaccess file, " + "ensure it is readable", + filename); + ap_table_setn(r->notes, "error-notes", + "Server unable to read htaccess file, denying " + "access to be safe"); + return HTTP_FORBIDDEN; + } } /* cache it */ Index: alloc.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/alloc.c,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- alloc.c 1998/08/14 02:49:47 1.99 +++ alloc.c 1998/09/25 23:01:49 1.100 @@ -1744,6 +1744,7 @@ FILE *fd = NULL; int baseFlag, desc; int modeFlags = 0; + int saved_errno; #ifdef WIN32 modeFlags = _S_IREAD | _S_IWRITE; @@ -1766,22 +1767,26 @@ else { fd = fopen(name, mode); } - + saved_errno = errno; if (fd != NULL) ap_note_cleanups_for_file(a, fd); ap_unblock_alarms(); + errno = saved_errno; return fd; } API_EXPORT(FILE *) ap_pfdopen(pool *a, int fd, const char *mode) { FILE *f; + int saved_errno; ap_block_alarms(); f = ap_fdopen(fd, mode); + saved_errno = errno; if (f != NULL) ap_note_cleanups_for_file(a, f); ap_unblock_alarms(); + errno = saved_errno; return f; } Index: util.c =================================================================== RCS file: /home/cvs/apache-1.3/src/main/util.c,v retrieving revision 1.133 retrieving revision 1.134 diff -u -r1.133 -r1.134 --- util.c 1998/09/17 15:56:08 1.133 +++ util.c 1998/09/25 23:01:49 1.134 @@ -738,6 +738,7 @@ poolfile_t *new_pfile; FILE *file; struct stat stbuf; + int saved_errno; if (name == NULL) { ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, NULL, @@ -747,9 +748,11 @@ file = ap_pfopen(p, name, "r"); #ifdef DEBUG + saved_errno = errno; ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, NULL, "Opening config file %s (%s)", name, (file == NULL) ? strerror(errno) : "successful"); + errno = saved_errno; #endif if (file == NULL) return NULL; @@ -761,10 +764,12 @@ #else strcmp(name, "/dev/null") != 0) { #endif + saved_errno = errno; ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, NULL, "Access to file %s denied by server: not a regular file", name); ap_pfclose(p, file); + errno = saved_errno; return NULL; }