summaryrefslogtreecommitdiff
path: root/main/main.c
diff options
context:
space:
mode:
authorSammy Kaye Powers <sammyk@php.net>2020-07-16 16:31:10 -0700
committerSammy Kaye Powers <sammyk@php.net>2020-09-18 14:26:44 -0700
commit12306728c5f37dc371bc39f5fe2bf8e928368235 (patch)
treeeed1bf4671bc1c46e6a8e7a30b07bd4e9a7bc1d2 /main/main.c
parent30bb15b24a266eae1577b68cd980241b1a5adf40 (diff)
downloadphp-git-12306728c5f37dc371bc39f5fe2bf8e928368235.tar.gz
Add system ID entropy API
The `zend_system_id` is a (true global) system ID that fingerprints a process state. When extensions add engine hooks during MINIT/startup, entropy is added the system ID for each hook. This allows extensions to identify that changes have been made to the engine since the last PHP process restart. Closes GH-5871
Diffstat (limited to 'main/main.c')
-rw-r--r--main/main.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/main/main.c b/main/main.c
index 103c10a06b..3667432f94 100644
--- a/main/main.c
+++ b/main/main.c
@@ -72,6 +72,7 @@
#include "zend_ini.h"
#include "zend_dtrace.h"
#include "zend_observer.h"
+#include "zend_system_id.h"
#include "php_content_types.h"
#include "php_ticks.h"
@@ -2194,6 +2195,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zend_set_utility_values(&zuv);
php_startup_sapi_content_types();
+ /* Begin to fingerprint the process state */
+ zend_startup_system_id();
+
/* startup extensions statically compiled in */
if (php_register_internal_extensions_func() == FAILURE) {
php_printf("Unable to start builtin modules\n");
@@ -2237,6 +2241,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
module->info_func = PHP_MINFO(php_core);
}
+ /* Extensions that add engine hooks after this point do so at their own peril */
+ zend_finalize_system_id();
+
module_initialized = 1;
if (zend_post_startup() != SUCCESS) {