com php-src: add error_log_mode INI option to contr ol initial error log permissions: main/main.c m ain/php_globals.h
| From: | Antony Dovgal | Date: | Thu, 12 Dec 2013 08:47:40 +0000 |
| Subject: | com php-src: add error_log_mode INI option to contr ol initial error log permissions: main/main.c m ain/php_globals.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76655@lists.php.net to get a copy of this message | ||
Commit: 652597fcff361cc9be02a641632f801257e58316
Author: Antony Dovgal <tony@daylessday.org> Fri, 30 Dec 2011 13:40:44 +0400
Committer: Antony Dovgal <tony2001@php.net> Thu, 12 Dec 2013 12:47:40 +0400
Parents: d7a45a67be2b82272a908cff54cc4d78a3c6e206
Branches: badoo-5..5_mysqlnd
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=652597fcff361cc9be02a641632f801257e58316
Log:
add error_log_mode INI option to control initial error log permissions
Changed paths:
M main/main.c
M main/php_globals.h
Diff:
diff --git a/main/main.c b/main/main.c
index ce31cae..8e3f164 100644
--- a/main/main.c
+++ b/main/main.c
@@ -525,6 +525,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, default_charset, sapi_globals_struct,sapi_globals)
STD_PHP_INI_ENTRY("default_mimetype", SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct,sapi_globals)
STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateErrorLog, error_log, php_core_globals, core_globals)
+ STD_PHP_INI_ENTRY("error_log_mode", "0644", PHP_INI_ALL, OnUpdateLong, error_log_mode, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("extension_dir", PHP_EXTENSION_DIR, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("sys_temp_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, sys_temp_dir, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("include_path", PHP_INCLUDE_PATH, PHP_INI_ALL, OnUpdateStringUnempty, include_path, php_core_globals, core_globals)
@@ -619,6 +620,9 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
/* Try to use the specified logging location. */
if (PG(error_log) != NULL) {
+ int error_log_mode;
+ mode_t old_umask;
+
#ifdef HAVE_SYSLOG_H
if (!strcmp(PG(error_log), "syslog")) {
php_syslog(LOG_NOTICE, "%s", log_message);
@@ -626,7 +630,16 @@ PHPAPI void php_log_err(char *log_message TSRMLS_DC)
return;
}
#endif
- fd = VCWD_OPEN_MODE(PG(error_log), O_CREAT | O_APPEND | O_WRONLY, 0644);
+
+ error_log_mode = 0644;
+
+ if (PG(error_log_mode) > 0 && PG(error_log_mode) <= 0777) {
+ error_log_mode = PG(error_log_mode);
+ }
+
+ old_umask = umask(0);
+ fd = VCWD_OPEN_MODE(PG(error_log), O_CREAT | O_APPEND | O_WRONLY, error_log_mode);
+ umask(old_umask);
if (fd != -1) {
char *tmp;
int len;
diff --git a/main/php_globals.h b/main/php_globals.h
index 256765d..a317da4 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -163,6 +163,7 @@ struct _php_core_globals {
#ifdef PHP_WIN32
zend_bool windows_show_crt_warning;
#endif
+ long error_log_mode;
};