SHARE
TWEET

Untitled

a guest Aug 11th, 2012 273 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- fpm_main.c.orig     2012-08-11 17:38:39.000000000 +0700
  2. +++ fpm_main.c  2012-08-11 20:20:03.000000000 +0700
  3. @@ -162,6 +162,7 @@
  4.         zend_bool rfc2616_headers;
  5.         zend_bool nph;
  6.         zend_bool fix_pathinfo;
  7. +       char *fix_chrootpath;
  8.         zend_bool force_redirect;
  9.         zend_bool discard_path;
  10.         zend_bool fcgi_logging;
  11. @@ -1053,6 +1054,27 @@
  12.         char *ini;
  13.         int apache_was_here = 0;
  14.  
  15. +       if (CGIG(fix_chrootpath)) {
  16. +               size_t chroot_len = strlen(CGIG(fix_chrootpath));
  17. +               /* remove trail slash */
  18. +               while (chroot_len > 0 && CGIG(fix_chrootpath)[chroot_len-1] == '/') {
  19. +                       chroot_len--;
  20. +               }
  21. +               if (chroot_len > 0) {
  22. +                       char *env_document_root = sapi_cgibin_getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT") - 1 TSRMLS_CC);
  23. +
  24. +                       if (strncmp(env_path_translated, CGIG(fix_chrootpath), chroot_len) == 0) {
  25. +                               env_path_translated += chroot_len;
  26. +                               env_path_translated = _sapi_cgibin_putenv("PATH_TRANSLATED", env_path_translated TSRMLS_CC);
  27. +                       }
  28. +
  29. +                       if (strncmp(env_document_root, CGIG(fix_chrootpath), chroot_len) == 0) {
  30. +                               env_document_root += chroot_len;
  31. +                               env_document_root = _sapi_cgibin_putenv("DOCUMENT_ROOT", env_document_root TSRMLS_CC);
  32. +                       }
  33. +               }
  34. +       }
  35. +
  36.         /* some broken servers do not have script_filename or argv0
  37.          * an example, IIS configured in some ways.  then they do more
  38.          * broken stuff and set path_translated to the cgi script location */
  39. @@ -1437,6 +1459,7 @@
  40.         STD_PHP_INI_ENTRY("cgi.force_redirect",      "1",  PHP_INI_SYSTEM, OnUpdateBool,   force_redirect, php_cgi_globals_struct, php_cgi_globals)
  41.         STD_PHP_INI_ENTRY("cgi.redirect_status_env", NULL, PHP_INI_SYSTEM, OnUpdateString, redirect_status_env, php_cgi_globals_struct, php_cgi_globals)
  42.         STD_PHP_INI_ENTRY("cgi.fix_pathinfo",        "1",  PHP_INI_SYSTEM, OnUpdateBool,   fix_pathinfo, php_cgi_globals_struct, php_cgi_globals)
  43. +       STD_PHP_INI_ENTRY("cgi.fix_chrootpath",      NULL, PHP_INI_SYSTEM, OnUpdateString, fix_chrootpath, php_cgi_globals_struct, php_cgi_globals)
  44.         STD_PHP_INI_ENTRY("cgi.discard_path",        "0",  PHP_INI_SYSTEM, OnUpdateBool,   discard_path, php_cgi_globals_struct, php_cgi_globals)
  45.         STD_PHP_INI_ENTRY("fastcgi.logging",         "1",  PHP_INI_SYSTEM, OnUpdateBool,   fcgi_logging, php_cgi_globals_struct, php_cgi_globals)
  46.         STD_PHP_INI_ENTRY("fastcgi.error_header",    NULL, PHP_INI_SYSTEM, OnUpdateString, error_header, php_cgi_globals_struct, php_cgi_globals)
  47. @@ -1452,6 +1475,7 @@
  48.         php_cgi_globals->force_redirect = 1;
  49.         php_cgi_globals->redirect_status_env = NULL;
  50.         php_cgi_globals->fix_pathinfo = 1;
  51. +       php_cgi_globals->fix_chrootpath = NULL;
  52.         php_cgi_globals->discard_path = 0;
  53.         php_cgi_globals->fcgi_logging = 1;
  54.         zend_hash_init(&php_cgi_globals->user_config_cache, 0, NULL, (dtor_func_t) user_config_cache_entry_dtor, 1);
RAW Paste Data
Top