Ticket #173: eaccelerator-0.9.5.2-filtercheck.patch

File eaccelerator-0.9.5.2-filtercheck.patch, 2.4 kB (added by norganna, 5 months ago)

I've just had to fix this for my company's website, and thought I'd just provide the patch here for you guys who use linux and want it working on a non-development version. The attached patch may work on other versions of unix, probably not on windows however. YMMV, Use at your own risk, etc.

  • eaccelerator-0.9.5.2/eaccelerator.c

    old new  
    5858#  include <utime.h> 
    5959#endif 
    6060#include <fcntl.h> 
     61#include <fnmatch.h> 
    6162 
    6263#ifndef O_BINARY 
    6364#  define O_BINARY 0 
     
    10331034    return 1; 
    10341035  } 
    10351036 
     1037  ea_debug_log("\t[%d] Checking cachability: %s\n", getpid(), realname); 
     1038 
    10361039  /* if "realname" matches to any pattern started with "!" then ignore it */ 
    10371040  for (p = EAG(cond_list); p != NULL; p = p->next) { 
    1038     if (p->not && match(realname, p->str)) { 
     1041    if (p->not && fnmatch(p->str, realname, FNM_CASEFOLD | FNM_NOESCAPE | FNM_LEADING_DIR) == 0) { 
     1042      ea_debug_log("\t[%d] Uncachable: %s (matches !%s)\n", getpid(), realname, p->str); 
    10391043      return 0; 
    10401044    } 
    10411045  } 
     
    10451049  for (p = EAG(cond_list); p != NULL; p = p->next) { 
    10461050    if (!p->not) { 
    10471051      ok = 0; 
    1048       if (match(realname, p->str)) { 
     1052      if (fnmatch(p->str, realname, FNM_CASEFOLD | FNM_NOESCAPE | FNM_LEADING_DIR) == 0) { 
     1053        ea_debug_log("\t[%d] Cachable: %s (matches %s)\n", getpid(), realname, p->str); 
    10491054        return 1; 
    10501055      } 
    10511056    } 
    10521057  } 
     1058 
     1059  if (ok == 1) 
     1060    ea_debug_log("\t[%d] Cachable: %s (no inclusions)\n", getpid(), realname); 
     1061  else 
     1062    ea_debug_log("\t[%d] Uncachable: %s (fails inclusions)\n", getpid(), realname); 
    10531063  return ok; 
    10541064} 
    10551065 
     
    12451255  zend_op_array *t; 
    12461256  struct stat buf; 
    12471257  char  realname[MAXPATHLEN]; 
     1258  char  actualpath[MAXPATHLEN]; 
     1259  char *rpath; 
    12481260  int   nreloads; 
    12491261  time_t compile_time; 
    12501262  int stat_result = 0; 
     
    12691281        ea_debug_log("EACCELERATOR: Warning: \"%s\" is cached but it's mtime is in the future.\n", file_handle->filename); 
    12701282  } 
    12711283 
    1272   ok_to_cache = eaccelerator_ok_to_cache(file_handle->filename TSRMLS_CC); 
     1284  rpath = realpath(file_handle->filename, NULL); 
     1285  if (!rpath) { 
     1286    strncpy(actualpath, file_handle->filename, MAXPATHLEN); 
     1287    actualpath[MAXPATHLEN-1] = '\0'; 
     1288    ea_debug_log("[%d] Using supplied path: \"%s\"\n", getpid(), file_handle->filename); 
     1289  } 
     1290  else { 
     1291    strncpy(actualpath, rpath, MAXPATHLEN); 
     1292    actualpath[MAXPATHLEN-1] = '\0'; 
     1293    free(rpath); 
     1294    ea_debug_log("[%d] Using realpath of %s: \"%s\"\n", getpid(), file_handle->filename, actualpath); 
     1295  } 
     1296  ok_to_cache = eaccelerator_ok_to_cache(actualpath TSRMLS_CC); 
    12731297  
    12741298  // eAccelerator isn't working, so just compile the file 
    12751299  if (!EAG(enabled) || (eaccelerator_mm_instance == NULL) ||