Skip to content

Commit 44d80f5

Browse files
committed
Open syslog with PHP settings when syslog() is called before openlog()
1 parent f0ed6aa commit 44d80f5

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎ext/standard/syslog.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include "basic_functions.h"
3333
#include "php_ext_syslog.h"
3434

35-
ZEND_TLS bool syslog_called;
36-
3735
/* {{{ PHP_MINIT_FUNCTION */
3836
PHP_MINIT_FUNCTION(syslog)
3937
{
@@ -43,9 +41,8 @@ PHP_MINIT_FUNCTION(syslog)
4341

4442
PHP_RSHUTDOWN_FUNCTION(syslog)
4543
{
46-
if (PG(have_called_openlog) || syslog_called) {
44+
if (PG(have_called_openlog)) {
4745
php_closelog();
48-
syslog_called = false;
4946
}
5047
if (BG(syslog_device)) {
5148
free(BG(syslog_device));
@@ -107,7 +104,9 @@ PHP_FUNCTION(syslog)
107104
Z_PARAM_STR(message)
108105
ZEND_PARSE_PARAMETERS_END();
109106

110-
syslog_called = true;
107+
if (!PG(have_called_openlog)) {
108+
php_openlog(PG(syslog_ident), 0, PG(syslog_facility));
109+
}
111110
php_syslog_str(priority, message);
112111
RETURN_TRUE;
113112
}

0 commit comments

Comments
 (0)