From e330f443c937c7f45cf9492ddbe0121f88789123 Mon Sep 17 00:00:00 2001 From: Jakub Zelenka Date: Sun, 12 Jun 2022 22:32:48 +0100 Subject: [PATCH] Fix bug #67764: fpm: syslog.ident does not work --- NEWS | 3 +++ ext/standard/syslog.c | 7 +------ main/php_syslog.c | 12 ++++++++++++ main/php_syslog.h | 1 + sapi/fpm/fpm/fpm_stdio.c | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 0339d183112..4325fe3ff47 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,9 @@ PHP NEWS . Fixed bug #78139 (timezone_open accepts invalid timezone string argument). (Derick) +- FPM: + . Fixed bug #67764 (fpm: syslog.ident don't work). (Jakub Zelenka) + - MBString: . Fixed bug GH-8685 (pcre not ready at mbstring startup). (Remi) diff --git a/ext/standard/syslog.c b/ext/standard/syslog.c index 5926abf34ea..866a6a3524a 100644 --- a/ext/standard/syslog.c +++ b/ext/standard/syslog.c @@ -120,11 +120,6 @@ PHP_MSHUTDOWN_FUNCTION(syslog) return SUCCESS; } -void php_openlog(const char *ident, int option, int facility) -{ - openlog(ident, option, facility); - PG(have_called_openlog) = 1; -} /* {{{ Open connection to system logger */ /* @@ -161,7 +156,7 @@ PHP_FUNCTION(closelog) { ZEND_PARSE_PARAMETERS_NONE(); - closelog(); + php_closelog(); if (BG(syslog_device)) { free(BG(syslog_device)); BG(syslog_device)=NULL; diff --git a/main/php_syslog.c b/main/php_syslog.c index 37bf5a7fb61..7538834cc7c 100644 --- a/main/php_syslog.c +++ b/main/php_syslog.c @@ -32,6 +32,18 @@ #define syslog std_syslog #endif +void php_openlog(const char *ident, int option, int facility) +{ + openlog(ident, option, facility); + PG(have_called_openlog) = 1; +} + +void php_closelog() +{ + closelog(); + PG(have_called_openlog) = 0; +} + #ifdef PHP_WIN32 PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */ { diff --git a/main/php_syslog.h b/main/php_syslog.h index 227baa8b162..10c6eb7c8d9 100644 --- a/main/php_syslog.h +++ b/main/php_syslog.h @@ -37,6 +37,7 @@ BEGIN_EXTERN_C() PHPAPI void php_syslog(int, const char *format, ...); PHPAPI void php_openlog(const char *, int, int); +PHPAPI void php_closelog(); END_EXTERN_C() #endif diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c index 1742467b368..9454710e536 100644 --- a/sapi/fpm/fpm/fpm_stdio.c +++ b/sapi/fpm/fpm/fpm_stdio.c @@ -88,7 +88,7 @@ int fpm_stdio_init_child(struct fpm_worker_pool_s *wp) /* {{{ */ { #ifdef HAVE_SYSLOG_H if (fpm_globals.error_log_fd == ZLOG_SYSLOG) { - closelog(); /* ensure to close syslog not to interrupt with PHP syslog code */ + php_closelog(); /* ensure to close syslog not to interrupt with PHP syslog code */ } else #endif