From 02fa1c084405fc96ba83a06cd83047ecd8eb22cb Mon Sep 17 00:00:00 2001 From: Ben Fuhrmannek Date: Wed, 12 Jan 2022 19:08:28 +0100 Subject: make session support a runtime check instead of compile time --- src/sp_config_keywords.c | 9 --------- src/sp_session.c | 11 ++--------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index 138da75..3e2b156 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c @@ -39,15 +39,6 @@ SP_PARSE_FN(parse_session) { SP_PROCESS_CONFIG_KEYWORDS_ERR(); -#if (!HAVE_PHP_SESSION || defined(COMPILE_DL_SESSION)) - sp_log_err("config", - "You're trying to use the session cookie encryption feature " - "on line %zu without having session support statically built into PHP. " - "This isn't supported, see " - "https://github.com/jvoisin/snuffleupagus/issues/278 for details.", parsed_rule->lineno); - return SP_PARSER_ERROR; -#endif - if (cfg->encrypt) { if (!SPCFG(cookies_env_var)) { sp_log_err("config", "You're trying to use the session cookie encryption feature " diff --git a/src/sp_session.c b/src/sp_session.c index 214aa85..6335838 100644 --- a/src/sp_session.c +++ b/src/sp_session.c @@ -1,7 +1,5 @@ #include "php_snuffleupagus.h" -#if (HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)) - #ifdef ZTS static ts_rsrc_id session_globals_id = 0; #define SESSION_G(v) ZEND_TSRMG(session_globals_id, php_ps_globals *, v) @@ -10,7 +8,7 @@ ZEND_TSRMLS_CACHE_EXTERN(); #endif #else static php_ps_globals *session_globals = NULL; -#define SESSION_G(v) (ps_globals.v) +#define SESSION_G(v) (session_globals->v) #endif static ps_module *s_module; @@ -138,6 +136,7 @@ void hook_session() { zend_module_entry *module; if ((module = zend_hash_str_find_ptr(&module_registry, ZEND_STRL("session"))) == NULL) { + sp_log_err("session", "You are trying to use session encryption or session ID restrictions, but your PHP installation has no session support. Please install the PHP session module or recompile PHP with session support."); return; // LCOV_EXCL_LINE } @@ -166,9 +165,3 @@ void hook_session() { sp_hook_session_module(); } - -#else - -void hook_session() {} - -#endif // HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION) -- cgit v1.3