-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathphp_nrini.c
3478 lines (3059 loc) · 99 KB
/
php_nrini.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include "php_agent.h"
#include "php_execute.h"
#include "php_globals.h"
#include "php_hash.h"
#include "php_internal_instrument.h"
#include "php_user_instrument.h"
#include "nr_commands.h"
#include "nr_configstrings.h"
#include "nr_limits.h"
#include "nr_version.h"
#include "nr_log_level.h"
#include "util_buffer.h"
#include "util_json.h"
#include "util_logging.h"
#include "util_memory.h"
#include "util_strings.h"
#include "util_url.h"
/*
* This file deals with INI variables.
*
* This file deals with the relatively complex task of initializing, modifying
* and tracking INI variables. To the greatest extent possible this file uses
* standard PHP macros for doing all its work, in order to reduce porting
* complexities for future versions of PHP.
*
* This file is complex because:
*
* - It acts as a cross bar switch, moving data from PHPs realm into the agent's
* realm in various ways, although not necessarily the other direction.
*
* - It implements visibility and modifiability semantics for various ini
* settings, depending on the minit/rinit cycle.
*
* - It implements display semantics, as needed for php -i or phpinfo(),
* generating straight text or html, as appropriate.
*/
/*
* The cross bar and visibility semantics are implemented by calls to PHP
* standard macros. PHP_INI_ENTRY_EX has no mechanisms to route data structure
* pointers into modify handlers, STD_PHP_INI_ENTRY_EX has mechanisms to
* route data structure pointers into modify handlers. Use of these macros are
* wrapped between PHP_INI_BEGIN and PHP_INI_END.
*
* At some point in the cycle, the static const array data structure of type
* zend_ini_entry[] which is implicit between PHP_INI_BEGIN and PHP_INI_END is
* copied into a hash table indexed by the ini entry name, such as
* "newrelic.license". This hash table contains one entry for all ini entries,
* across all module names.
*
* When the PHP engine processes an ini setting, it is working entirely
* with strings. The engine first modifies the string value held
* in the zend_ini_entry data structure, and arranges to call the
* modify handler to disseminate the value. It's up to the modify
* handler to convert the string value held by PHP into an appropriate
* implementation type (such as int), and disseminate the value as it
* sees fit. The modify handler can call whatever it wants, to change
* whatever far and wide data structure it chooses.
*
* When the PHP engine regurgitates an ini setting, as for example from
* a call to PHP ini_get() function, or in the course of evaluating
* phpinfo(), it consults the string value held in the hash table
* wrapping over the zend_ini_data structures. For the case of ini_get,
* the string value is just returned back through ini_get. For the case
* of phpinfo() (or php -i), the value is given to a display handler.
* The default display handler merely prints the string in one of
* several formats, although we use several custom display handlers to
* slightly customize the formatting, as for example to obscure the
* middle of the license key string.
*
* IMPORTANT:
*
* Recall that our discipline of using the modify handler is very lax:
* it can call anything it wants, to modify other data structures. These
* other data structures contain the agent's version of truth. These
* data structures can be modified by calls to the Agent API (such as
* a call to newrelic_set_appname), or in the course of the agent's
* execution. NONE of the display handlers (or ini_get, for that matter)
* chase down these "other" data structures, so what's regurgitated this
* way may not reflect what's really happening.
*
* Fortunately, most of the ini settings are bound into the
* newrelic_globals data structure, which represents the agent's version
* of truth.
*
* Copies are problematic, but that's what we have: PHP's string copy of the
* value at one time, and the agent's actual value, which depending on
* the particular init setting, can live "anywhere".
*
* Note that the API also provides a limited number of getter functions.
*/
/*
* For Zend/PHP5, the various sources of ini settings' values are
* processed in the order shown in the following case analysis table.
* This table was made by tracking the calls to nr_license_mh with
* specific values originating in specific places.
*
* Case 1: php invoked with -dvar=value
* 1: -dvar=value from the command line (stage == ZEND_INI_STAGE_STARTUP)
* 2: the value comes from the table between PHP_INI_BEGIN and PHP_INI_END
* (stage == ZEND_INI_STAGE_STARTUP)
*
* Case 2: php not invoked with -dvar=value
* 1: the value comes from the newrelic.ini file (stage ==
* ZEND_INI_STAGE_STARTUP) (minit time)
*
* Case 3: newrelic.ini file present, but the value is commented out
* 1: the value comes from the table between PHP_INI_BEGIN and PHP_INI_END
* (stage == ZEND_INI_STAGE_STARTUP)
*
* Then, the value given in the .htaccess file, if any, would be acted on
* through the sapi. An example .htaccess file might contain: php_value
* newrelic.appname "special app name"
*
* Then, calls to PHP ini_set() would be acted on, assuming that the
* individual ini setting has allowed this PHP_INI_USER semantics.
* Since this is disallowed for all of our ini settings, this situation
* doesn't come up.
*
* Note that the modify handler would be called again with the original value
* to restore the previous settings.
*/
/*
* This is what happens when running as a threaded PHP as a worker MPM
* with ZTS. This mode is not officially supported by New Relic.
*
* 0a: zm_startup_newrelic is called for module initialization
*
* 1. The modify handler is called* from zm_startup_newrelic (module
* init time), to consume the value held in the newrelic.ini file
*
* 2. The modify handler is called* again from
* zend_new_thread_end_handler called* from allocate_new_resource.
*
* Important: This is acting on work done by end_copy_ini_directives,
* which copies ini entries from the static hashtable
* registered_zend_ini_directives into a freshly allocated per-thread
* hash table EG(ini_directives).
*
* 2a: zm_activate_newrelic is called for request initialization.
*
* 3: The modify handler is called* from a call to PHP ini_set(),
* assuming that PHP_INI_USER semantics are in force.
* By now, the ini_entry has a copy of the original value.
*
* 4: The modify handler is called* from php_request_shutdown calls*
* zend_ini_deactivate calls* zend_restore_ini_entry_cb
*/
/*
* The names of the custom modify functions (aka update handlers) all
* end with the sub string "_mh". These are called when a given value is
* modified.
*
* The modify handlers must do sanity checks on the values they are given,
* and do whatever translation from a string that is necessary.
*
* The modify handlers may disseminate their values as they see fit.
* There are several common patterns for dissemination:
*
* Pattern A:
* The modify handler may call some agent- or axiom-specific function
* to receive the value immediately. An example is the modifiy handler
* nr_logfile_mh which is called when the ini setting "newrelic.logfile" is
* changed. tHe handler disseminates its value immediately by calling the
* function nrl_set_log_file.
*
* Pattern B:
* The modify handler assigns to per-process globals through the macro
* NR_PHP_PROCESS_GLOBALS
*
* Pattern C:
* The modify handle assigns to per request globals using the macro NRPRG
* An example of this is the modify handler nr_tt_threshold_mh.
*
* Pattern D:
* The modify handler assign through a pointer to a data structure
* that PHP presents in arguments to the modify handler. Our use of
* the macro STD_PHP_INI_ENTRY_EX has arranged to have this pointer
* argument to the modify handler point to the like-named slot in the
* "newrelic_globals" variable, which is of type zend_newrelic_globals.
* This variable is either process global or thread global, depending
* on the zts semantics. Like pattern C, above, this variable is normally
* accessed through NRPRG.
*/
/*
* The names of the handful of custom display handlers all
* end with the sub string "_dh". These are called with the string value
* of the ini setting, as maintained by PHP.
*/
/*
* Here's one additional thing to note when reading or extending this code:
*
* The PHP INI parser will turn things like:
* option = no
* option = off
* option = false
* into an empty(!) string. It will turn things like:
* option = on
* option = yes
* option = true
* into a string with the contents "1".
* Thus any code which expects to take a boolean
* argument must interpret an empty string (for new_value) as boolean false.
*/
#define NR_PHP_INI_DEFAULT_DAEMON_LOCATION "/usr/bin/newrelic-daemon"
#define NR_PHP_INI_DEFAULT_LOG_FILE "/var/log/newrelic/php_agent.log"
#define NR_PHP_INI_DEFAULT_LOG_LEVEL "info"
ZEND_DECLARE_MODULE_GLOBALS(newrelic)
typedef void (*foreach_fn_t)(const char* name, int namelen TSRMLS_DC);
static void foreach_list(const char* str, foreach_fn_t f_eachname TSRMLS_DC) {
nrobj_t* rs;
int ns = 0;
int i;
if ((0 == str) || (0 == str[0])) {
return;
}
rs = nr_strsplit(str, ",", 0);
ns = nro_getsize(rs);
for (i = 0; i < ns; i++) {
const char* s = nro_get_array_string(rs, i + 1, NULL);
f_eachname(s, nr_strlen(s) TSRMLS_CC);
}
nro_delete(rs);
}
static nrtime_t nr_parse_time_from_config(const char* str) {
return nr_parse_time(str);
}
static void check_ini_int_min_max(int* var, int minval, int maxval) {
if (*var < minval) {
*var = minval;
} else if ((*var > maxval) && (maxval > 0)) {
*var = maxval;
}
}
/*
* @brief error handling for strtoimax() functionality
*
* @param val_p pointer to store the parsed value; remains undefined when
* function returns NR_FAILURE
* @param str string to parse
* @param base base to be used for number conversion
* @return nr_status_t NR_SUCCESS || NR_FAILURE
*/
static nr_status_t nr_strtoi(int* val_p, const char* str, int base) {
int val;
char* endptr_p;
errno = 0;
val = strtoimax(str, &endptr_p, base);
if (0 != errno || '\0' != *endptr_p) {
return NR_FAILURE;
}
*val_p = val;
return NR_SUCCESS;
}
#ifdef PHP7
#define PHP_INI_ENTRY_NAME(ie) (ie)->name->val
#define PHP_INI_ENTRY_NAME_LEN(ie) (ie)->name->len + 1
#define PHP_INI_ENTRY_ORIG_VALUE(ie) (ie)->orig_value->val
#define PHP_INI_ENTRY_ORIG_VALUE_LEN(ie) (ie)->orig_value->len
#define PHP_INI_ENTRY_VALUE(ie) (ie)->value->val
#define PHP_INI_ENTRY_VALUE_LEN(ie) (ie)->value->len
#else
#define PHP_INI_ENTRY_NAME(ie) (ie)->name
#define PHP_INI_ENTRY_NAME_LEN(ie) (ie)->name_length
#define PHP_INI_ENTRY_ORIG_VALUE(ie) (ie)->orig_value
#define PHP_INI_ENTRY_ORIG_VALUE_LEN(ie) (ie)->orig_value_length
#define PHP_INI_ENTRY_VALUE(ie) (ie)->value
#define PHP_INI_ENTRY_VALUE_LEN(ie) (ie)->value_length
#endif
/*
* Next we declare some custom display functions for producing more neatly
* formatted phpinfo() output. Most are pretty simple, a few slightly less so.
*/
static int nr_bool_val(php_ini_entry* ini_entry, int type) {
const char* value = PHP_INI_ENTRY_VALUE(ini_entry);
int ret;
if ((PHP_INI_DISPLAY_ORIG == type) && (0 != ini_entry->modified)) {
value = PHP_INI_ENTRY_ORIG_VALUE(ini_entry);
}
ret = nr_bool_from_str(value);
return (1 == ret);
}
/*
* This displayer produces the word "enabled" or "disabled".
*/
static PHP_INI_DISP(nr_enabled_disabled_dh) {
int val = nr_bool_val(ini_entry, type);
if (val) {
php_printf("%s", "enabled");
} else {
php_printf("%s", "disabled");
}
}
/*
* This displayer produces the word "on" or "off".
*/
static PHP_INI_DISP(nr_on_off_dh) {
int val = nr_bool_val(ini_entry, type);
if (val) {
php_printf("%s", "on");
} else {
php_printf("%s", "off");
}
}
/*
* This displayer produces the word "yes" or "no".
*/
static PHP_INI_DISP(nr_yes_no_dh) {
int val = nr_bool_val(ini_entry, type);
if (val) {
php_printf("%s", "yes");
} else {
php_printf("%s", "no");
}
}
static PHP_INI_DISP(nr_daemon_proxy_dh) {
const char* value = PHP_INI_ENTRY_VALUE(ini_entry);
char* printable_proxy = NULL;
if ((PHP_INI_DISPLAY_ORIG == type) && (0 != ini_entry->modified)) {
value = PHP_INI_ENTRY_ORIG_VALUE(ini_entry);
}
printable_proxy = nr_url_proxy_clean(value);
if (printable_proxy) {
php_printf("%s", printable_proxy);
} else if (sapi_module.phpinfo_as_text) {
php_printf("%s", "no value");
} else {
php_printf("<i>no value</i>");
}
nr_free(printable_proxy);
}
/*
* This displayer is used to display the New Relic license. For obvious
* reasons we do not want to display the full license. Therefore, we trim the
* display of the license to include only the first and last few characters of
* the license. We make a very weak attempt to ensure the license is valid,
* solely by checking its length.
*/
static PHP_INI_DISP(nr_license_dh) {
const char* value = PHP_INI_ENTRY_VALUE(ini_entry);
char* printable_license = NULL;
if ((PHP_INI_DISPLAY_ORIG == type) && (0 != ini_entry->modified)) {
value = PHP_INI_ENTRY_ORIG_VALUE(ini_entry);
}
printable_license = nr_app_create_printable_license(value);
if (printable_license) {
php_printf("%s", printable_license);
} else if (sapi_module.phpinfo_as_text) {
php_printf("%s", "***INVALID FORMAT***");
} else {
php_printf("<b>%s</b>", "***INVALID FORMAT***");
}
nr_free(printable_license);
}
static PHP_INI_DISP(nr_framework_dh) {
const char* value = PHP_INI_ENTRY_VALUE(ini_entry);
if ((PHP_INI_DISPLAY_ORIG == type) && (0 != ini_entry->modified)) {
value = PHP_INI_ENTRY_ORIG_VALUE(ini_entry);
}
if (value && value[0]) {
php_printf("%s", value);
} else {
php_printf("%s", "auto-detect");
}
}
/*
* Now begin the modify handlers. Firstly, we shall define some compatibility
* macros.
*/
#ifdef PHP7
#define NEW_VALUE new_value->val
#define NEW_VALUE_LEN new_value->len
#else
#define NEW_VALUE new_value
#define NEW_VALUE_LEN new_value_length
#endif /* PHP7 */
/*
* On PHP 5, the arguments to the modify handlers are:
* zend_ini_entry *entry
* char *new_value
* uint new_value_length
* void *mh_arg1 the offset into the blob of data holding all ini
* values
* void *mh_arg2 the blob of data holding all ini values
* void *mh_arg3 unused for our purposes int stage taken from the set
* shown below
* TSRMLS_DC
*
* On PHP 7, the arguments are similar, but with PHP 7 appropriate changes for
* the string and thread safety:
* zend_ini_entry *entry
* zend_string *new_value
* void *mh_arg1 the offset into the blob of data holding all ini
* values
* void *mh_arg2 the blob of data holding all ini values
* void *mh_arg3 unused for our purposes int stage taken from the set
* shown below
*
* The "stage" argument is a bitset formed from these symbols
* (it is likely that the given set is a singleton):
* ZEND_INI_STAGE_STARTUP
* ZEND_INI_STAGE_SHUTDOWN
* ZEND_INI_STAGE_ACTIVATE
* ZEND_INI_STAGE_DEACTIVATE
* ZEND_INI_STAGE_RUNTIME
* ZEND_INI_STAGE_HTACCESS
*/
static PHP_INI_MH(nr_logfile_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
if (0 != NEW_VALUE_LEN) {
nrl_set_log_file(NEW_VALUE);
} else {
nrl_set_log_file(NR_PHP_INI_DEFAULT_LOG_FILE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_auditlog_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(daemon_auditlog));
if (0 != NEW_VALUE_LEN) {
NR_PHP_PROCESS_GLOBALS(daemon_auditlog) = nr_strdup(NEW_VALUE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_high_security_mh) {
int val;
(void)entry;
(void)NEW_VALUE_LEN;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
val = nr_bool_from_str(NEW_VALUE);
if (-1 == val) {
return FAILURE;
}
if (val) {
NR_PHP_PROCESS_GLOBALS(high_security) = 1;
} else {
NR_PHP_PROCESS_GLOBALS(high_security) = 0;
}
return SUCCESS;
}
static PHP_INI_MH(nr_preload_framework_library_detection_mh) {
int val;
(void)entry;
(void)NEW_VALUE_LEN;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
val = nr_bool_from_str(NEW_VALUE);
if (-1 == val) {
return FAILURE;
}
NR_PHP_PROCESS_GLOBALS(preload_framework_library_detection) = val ? 1 : 0;
return SUCCESS;
}
static PHP_INI_MH(nr_loglevel_mh) {
nr_status_t rv;
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
if (0 != NEW_VALUE_LEN) {
rv = nrl_set_log_level(NEW_VALUE);
if (NR_FAILURE == rv) {
/*
* There's a bit of a chicken and egg problem here.
* A bogus loglevel will have the effect of "info",
* so calling nrl_debug will successfully log the fault.
*/
nrl_warning(NRL_INIT, "unknown loglevel \"%.8s\"; using \"info\" instead",
NEW_VALUE);
}
} else {
rv = nrl_set_log_level(NR_PHP_INI_DEFAULT_LOG_LEVEL);
}
if (NR_SUCCESS == rv) {
return SUCCESS;
} else {
return FAILURE;
}
}
static PHP_INI_MH(nr_daemon_logfile_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(daemon_logfile));
if (0 != NEW_VALUE_LEN) {
NR_PHP_PROCESS_GLOBALS(daemon_logfile) = nr_strdup(NEW_VALUE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_loglevel_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(daemon_loglevel));
if (0 != NEW_VALUE_LEN) {
NR_PHP_PROCESS_GLOBALS(daemon_loglevel) = nr_strdup(NEW_VALUE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_port_mh) {
const char* local_new_value = NULL;
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(udspath));
if (NEW_VALUE_LEN > 0) {
local_new_value = NEW_VALUE;
}
NR_PHP_PROCESS_GLOBALS(udspath) = nr_strdup(local_new_value);
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_address_mh) {
const char* local_new_value = NULL;
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(address_path));
if (NEW_VALUE_LEN > 0) {
local_new_value = NEW_VALUE;
}
NR_PHP_PROCESS_GLOBALS(address_path) = nr_strdup(local_new_value);
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_ssl_cafile_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(ssl_cafile));
if (NEW_VALUE_LEN > 0) {
NR_PHP_PROCESS_GLOBALS(ssl_cafile) = nr_strdup(NEW_VALUE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_ssl_capath_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(ssl_capath));
if (NEW_VALUE_LEN > 0) {
NR_PHP_PROCESS_GLOBALS(ssl_capath) = nr_strdup(NEW_VALUE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_collector_host_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(collector));
if (NEW_VALUE_LEN > 0) {
NR_PHP_PROCESS_GLOBALS(collector) = nr_strdup(NEW_VALUE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_proxy_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(proxy));
if (NEW_VALUE_LEN > 0) {
NR_PHP_PROCESS_GLOBALS(proxy) = nr_strdup(NEW_VALUE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_location_mh) {
const char* local_new_value = NULL;
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(daemon));
if (NEW_VALUE_LEN > 0) {
local_new_value = NEW_VALUE;
}
NR_PHP_PROCESS_GLOBALS(daemon) = nr_strdup(local_new_value);
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_pidfile_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(pidfile));
if (NEW_VALUE_LEN > 0) {
NR_PHP_PROCESS_GLOBALS(pidfile) = nr_strdup(NEW_VALUE);
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_app_timeout_mh) {
const char* local_new_value = NULL;
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(daemon_app_timeout));
if (NEW_VALUE_LEN > 0) {
local_new_value = NEW_VALUE;
}
NR_PHP_PROCESS_GLOBALS(daemon_app_timeout) = nr_strdup(local_new_value);
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_app_connect_timeout_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
if (0 != NEW_VALUE_LEN) {
NR_PHP_PROCESS_GLOBALS(daemon_app_connect_timeout)
= nr_parse_time_from_config(NEW_VALUE);
} else {
NR_PHP_PROCESS_GLOBALS(daemon_app_connect_timeout) = 0;
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_start_timeout_mh) {
const char* local_new_value = NULL;
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
nr_free(NR_PHP_PROCESS_GLOBALS(daemon_start_timeout));
if (NEW_VALUE_LEN > 0) {
local_new_value = NEW_VALUE;
}
NR_PHP_PROCESS_GLOBALS(daemon_start_timeout) = nr_strdup(local_new_value);
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_dont_launch_mh) {
int val;
(void)entry;
(void)NEW_VALUE_LEN;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
if (NEW_VALUE_LEN > 0) {
val = (int)strtol(NEW_VALUE, 0, 10);
if (val < 0) {
val = 0;
} else if (val > 3) {
val = 3;
}
NR_PHP_PROCESS_GLOBALS(no_daemon_launch) = val;
}
return SUCCESS;
}
#define NR_PHP_UTILIZATION_MH_NAME(name) nr_daemon_utilization_##name##_mh
#define NR_PHP_UTILIZATION_MH(name) \
static PHP_INI_MH(NR_PHP_UTILIZATION_MH_NAME(name)) { \
int val; \
\
(void)entry; \
(void)NEW_VALUE_LEN; \
(void)mh_arg1; \
(void)mh_arg2; \
(void)mh_arg3; \
(void)stage; \
NR_UNUSED_TSRMLS; \
\
val = nr_bool_from_str(NEW_VALUE); \
if (-1 == val) { \
return FAILURE; \
} \
\
NR_PHP_PROCESS_GLOBALS(utilization).name = val; \
\
return SUCCESS; \
}
NR_PHP_UTILIZATION_MH(aws)
NR_PHP_UTILIZATION_MH(azure)
NR_PHP_UTILIZATION_MH(gcp)
NR_PHP_UTILIZATION_MH(pcf)
NR_PHP_UTILIZATION_MH(docker)
NR_PHP_UTILIZATION_MH(kubernetes)
static PHP_INI_MH(nr_daemon_special_curl_verbose_mh) {
int val;
(void)entry;
(void)NEW_VALUE_LEN;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
if (NEW_VALUE_LEN > 0) {
val = (int)strtol(NEW_VALUE, 0, 10);
NR_PHP_PROCESS_GLOBALS(daemon_special_curl_verbose) = val;
}
return SUCCESS;
}
static PHP_INI_MH(nr_daemon_special_integration_mh) {
int val;
(void)entry;
(void)NEW_VALUE_LEN;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_UNUSED_TSRMLS;
if (NEW_VALUE_LEN > 0) {
val = (int)strtol(NEW_VALUE, 0, 10);
NR_PHP_PROCESS_GLOBALS(daemon_special_integration) = val;
}
return SUCCESS;
}
static void foreach_special_control_flag(const char* str,
int str_len TSRMLS_DC) {
NR_UNUSED_TSRMLS;
if (str_len <= 0) {
return;
}
if (0 == nr_strcmp(str, "no_sql_parsing")) {
NR_PHP_PROCESS_GLOBALS(special_flags).no_sql_parsing = 1;
return;
}
if (0 == nr_strcmp(str, "show_sql_parsing")) {
NR_PHP_PROCESS_GLOBALS(special_flags).show_sql_parsing = 1;
return;
}
if (0 == nr_strcmp(str, "enable_path_translated")) {
NR_PHP_PROCESS_GLOBALS(special_flags).enable_path_translated = 1;
return;
}
if (0 == nr_strcmp(str, "no_background_jobs")) {
NR_PHP_PROCESS_GLOBALS(special_flags).no_background_jobs = 1;
return;
}
if (0 == nr_strcmp(str, "show_executes")) {
NR_PHP_PROCESS_GLOBALS(special_flags).show_executes = 1;
return;
}
if (0 == nr_strcmp(str, "show_execute_params")) {
NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_params = 1;
return;
}
if (0 == nr_strcmp(str, "show_execute_stack")) {
NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_stack = 1;
return;
}
if (0 == nr_strcmp(str, "show_execute_returns")) {
NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_returns = 1;
return;
}
if (0 == nr_strcmp(str, "show_executes_untrimmed")) {
NR_PHP_PROCESS_GLOBALS(special_flags).show_executes_untrimmed = 1;
return;
}
if (0 == nr_strcmp(str, "no_exception_handler")) {
NR_PHP_PROCESS_GLOBALS(special_flags).no_exception_handler = 1;
return;
}
if (0 == nr_strcmp(str, "no_signal_handler")) {
NR_PHP_PROCESS_GLOBALS(special_flags).no_signal_handler = 1;
return;
}
if (0 == nr_strcmp(str, "debug_autorum")) {
NR_PHP_PROCESS_GLOBALS(special_flags).debug_autorum = 1;
return;
}
if (0 == nr_strcmp(str, "show_loaded_files")) {
NR_PHP_PROCESS_GLOBALS(special_flags).show_loaded_files = 1;
return;
}
if (0 == nr_strcmp(str, "debug_cat")) {
NR_PHP_PROCESS_GLOBALS(special_flags).debug_cat = 1;
return;
}
if (0 == nr_strcmp(str, "debug_dt")) {
NR_PHP_PROCESS_GLOBALS(special_flags).debug_dt = 1;
return;
}
if (0 == nr_strcmp(str, "disable_laravel_queue")) {
NR_PHP_PROCESS_GLOBALS(special_flags).disable_laravel_queue = 1;
return;
}
}
static PHP_INI_MH(nr_special_mh) {
(void)entry;
(void)mh_arg1;
(void)mh_arg2;
(void)mh_arg3;
(void)stage;
NR_PHP_PROCESS_GLOBALS(special_flags).no_sql_parsing = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).show_sql_parsing = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).enable_path_translated = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).no_background_jobs = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).show_executes = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_params = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_stack = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).show_execute_returns = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).show_executes_untrimmed = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).no_exception_handler = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).no_signal_handler = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).debug_autorum = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).show_loaded_files = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).debug_cat = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).debug_dt = 0;
NR_PHP_PROCESS_GLOBALS(special_flags).disable_laravel_queue = 0;
if (0 != NEW_VALUE_LEN) {
foreach_list(NEW_VALUE, foreach_special_control_flag TSRMLS_CC);
}
return SUCCESS;
}
#define CHECK_FEATURE_FLAG(flag) \
if (0 == nr_strcmp(str, #flag)) { \
NR_PHP_PROCESS_GLOBALS(feature_flags).flag = 1; \
return; \
}
static void foreach_feature_flag(const char* str NRUNUSED,