Received: (from majordom@localhost) by hyperreal.org (8.8.5/8.8.5) id FAA08969; Thu, 21 Aug 1997 05:02:46 -0700 (PDT) Received: from DECUS.Org (Topaz.DECUS.Org [192.67.173.1]) by hyperreal.org (8.8.5/8.8.5) with ESMTP id FAA08964 for ; Thu, 21 Aug 1997 05:02:42 -0700 (PDT) Received: from Master.DECUS.Org (master.process.com) by DECUS.Org (PMDF V4.2-13 #18511) id <01IMP090YM2O8WWJ5R@DECUS.Org>; Thu, 21 Aug 1997 08:02:22 EDT Date: Thu, 21 Aug 1997 06:55:16 -0400 From: coar@decus.org (Rodent of Unusual Size) Subject: [PATCH] PR#991 (RewriteMap fails even if RewriteEngine off) To: New-HTTPd@apache.org, Coar@decus.org Message-id: <97082106551632@decus.org> X-VMS-To: NH X-VMS-Cc: COAR Content-transfer-encoding: 7BIT Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org I think the attached patch will address PR#991. It does config-time checking for the RewriteMap file IFF the engine has already been turned on. It also checks the stat() at run-time, rather than blindly assuming it's valid. Ralf, would you double-check this? #ken :-)} Index: mod_rewrite.c =================================================================== RCS file: /export/home/cvs/apachen/src/modules/standard/mod_rewrite.c,v retrieving revision 1.48 diff -u -c -r1.48 mod_rewrite.c /usr/bin/diff: conflicting specifications of output style *** mod_rewrite.c 1997/08/18 13:12:17 1.48 --- mod_rewrite.c 1997/08/21 11:59:45 *************** *** 451,459 **** new->fpin = 0; new->fpout = 0; ! if (new->checkfile) ! if (stat(new->checkfile, &st) == -1) ! return pstrcat(cmd->pool, "RewriteMap: map file or program not found:", new->checkfile, NULL); return NULL; } --- 451,459 ---- new->fpin = 0; new->fpout = 0; ! if (new->checkfile && (sconf->state == ENGINE_ENABLED) ! && (stat(new->checkfile, &st) == -1)) ! return pstrcat(cmd->pool, "RewriteMap: map file or program not found:", new->checkfile, NULL); return NULL; } *************** *** 2181,2187 **** s = &entries[i]; if (strcmp(s->name, name) == 0) { if (s->type == MAPTYPE_TXT) { ! stat(s->checkfile, &st); /* existence was checked at startup! */ value = get_cache_string(cachep, s->name, CACHEMODE_TS, st.st_mtime, key); if (value == NULL) { rewritelog(r, 6, "cache lookup FAILED, forcing new map lookup"); --- 2181,2194 ---- s = &entries[i]; if (strcmp(s->name, name) == 0) { if (s->type == MAPTYPE_TXT) { ! if (stat(s->checkfile, &st) == -1) { ! log_printf(r->server, ! "mod_rewrite: can't access text RewriteMap file %s: %s", ! s->checkfile, strerror(errno)); ! rewritelog(r, 1, ! "can't open RewriteMap file, see error log"); ! return NULL; ! } value = get_cache_string(cachep, s->name, CACHEMODE_TS, st.st_mtime, key); if (value == NULL) { rewritelog(r, 6, "cache lookup FAILED, forcing new map lookup"); *************** *** 2202,2208 **** } else if (s->type == MAPTYPE_DBM) { #if HAS_NDBM_LIB ! stat(s->checkfile, &st); /* existence was checked at startup! */ value = get_cache_string(cachep, s->name, CACHEMODE_TS, st.st_mtime, key); if (value == NULL) { rewritelog(r, 6, "cache lookup FAILED, forcing new map lookup"); --- 2209,2222 ---- } else if (s->type == MAPTYPE_DBM) { #if HAS_NDBM_LIB ! if (stat(s->checkfile, &st) == -1) { ! log_printf(r->server, ! "mod_rewrite: can't access dbm RewriteMap file %s: %s", ! s->checkfile, strerror(errno)); ! rewritelog(r, 1, ! "can't open RewriteMap file, see error log"); ! return NULL; ! } value = get_cache_string(cachep, s->name, CACHEMODE_TS, st.st_mtime, key); if (value == NULL) { rewritelog(r, 6, "cache lookup FAILED, forcing new map lookup");