Skip to content

Commit e193271

Browse files
author
Mikhail Galanin
committed
Add "error_log_mode" setting
1 parent 74f7f2c commit e193271

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

main/main.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,8 @@ PHP_INI_BEGIN()
712712
STD_PHP_INI_ENTRY("internal_encoding", NULL, PHP_INI_ALL, OnUpdateInternalEncoding, internal_encoding, php_core_globals, core_globals)
713713
STD_PHP_INI_ENTRY("input_encoding", NULL, PHP_INI_ALL, OnUpdateInputEncoding, input_encoding, php_core_globals, core_globals)
714714
STD_PHP_INI_ENTRY("output_encoding", NULL, PHP_INI_ALL, OnUpdateOutputEncoding, output_encoding, php_core_globals, core_globals)
715-
STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateErrorLog, error_log, php_core_globals, core_globals)
715+
STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateErrorLog, error_log, php_core_globals, core_globals)
716+
STD_PHP_INI_ENTRY("error_log_mode", "0644", PHP_INI_ALL, OnUpdateLong, error_log_mode, php_core_globals, core_globals)
716717
STD_PHP_INI_ENTRY("extension_dir", PHP_EXTENSION_DIR, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals)
717718
STD_PHP_INI_ENTRY("sys_temp_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, sys_temp_dir, php_core_globals, core_globals)
718719
STD_PHP_INI_ENTRY("include_path", PHP_INCLUDE_PATH, PHP_INI_ALL, OnUpdateStringUnempty, include_path, php_core_globals, core_globals)
@@ -807,14 +808,23 @@ PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int sys
807808

808809
/* Try to use the specified logging location. */
809810
if (PG(error_log) != NULL) {
811+
int error_log_mode;
812+
810813
#ifdef HAVE_SYSLOG_H
811814
if (!strcmp(PG(error_log), "syslog")) {
812815
php_syslog(syslog_type_int, "%s", log_message);
813816
PG(in_error_log) = 0;
814817
return;
815818
}
816819
#endif
817-
fd = VCWD_OPEN_MODE(PG(error_log), O_CREAT | O_APPEND | O_WRONLY, 0644);
820+
821+
error_log_mode = 0644;
822+
823+
if (PG(error_log_mode) > 0 && PG(error_log_mode) <= 0777) {
824+
error_log_mode = PG(error_log_mode);
825+
}
826+
827+
fd = VCWD_OPEN_MODE(PG(error_log), O_CREAT | O_APPEND | O_WRONLY, error_log_mode);
818828
if (fd != -1) {
819829
char *tmp;
820830
size_t len;

main/php_globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ struct _php_core_globals {
165165
char *syslog_ident;
166166
bool have_called_openlog;
167167
zend_long syslog_filter;
168+
zend_long error_log_mode;
168169
};
169170

170171

0 commit comments

Comments
 (0)