Skip to content

Commit 0d9c061

Browse files
author
Sascha Schumann
committed
Use php_syslog() for system call. On OpenServer 5, syslog is defined to
var_syslog/sys_syslog which causes various problems. Submitted by: Paul Gardiner <I.T.Manager@barleychalu.co.uk>
1 parent 9cd4929 commit 0d9c061

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

ext/standard/syslog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ PHP_FUNCTION(syslog)
252252
* this will cause problems.
253253
*/
254254

255-
syslog((*priority)->value.lval, (*message)->value.str.val);
255+
php_syslog((*priority)->value.lval, (*message)->value.str.val);
256256
RETURN_TRUE;
257257
}
258258
/* }}} */

main/main.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@
5353
#ifdef PHP_WIN32
5454
#include <io.h>
5555
#include <fcntl.h>
56-
#include "win32/syslog.h"
5756
#include "win32/php_registry.h"
58-
#else
59-
#include <syslog.h>
6057
#endif
58+
#include "php_syslog.h"
6159

6260
#if PHP_SIGCHILD
6361
#include <sys/types.h>
@@ -251,9 +249,9 @@ void php_log_err(char *log_message)
251249

252250
/* Try to use the specified logging location. */
253251
if (PG(error_log) != NULL) {
254-
#if HAVE_SYSLOG_H
252+
#ifdef HAVE_SYSLOG_H
255253
if (!strcmp(PG(error_log), "syslog")) {
256-
syslog(LOG_NOTICE, log_message);
254+
php_syslog(LOG_NOTICE, log_message);
257255
return;
258256
}
259257
#endif

main/php_syslog.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#ifndef PHP_SYSLOG_H
2+
#define PHP_SYSLOG_H
3+
4+
#ifdef PHP_WIN32
5+
#include "win32/syslog.h"
6+
#include "win32/php_registry.h"
7+
#else
8+
#include <syslog.h>
9+
#endif
10+
11+
/*
12+
* SCO OpenServer 5 defines syslog to var_syslog/sys_syslog which
13+
* causes trouble with our use of syslog. We define php_syslog
14+
* to be the system function syslog.
15+
*/
16+
17+
#ifdef syslog
18+
19+
#if defined(var_syslog) && var_syslog == syslog
20+
#define php_syslog var_syslog
21+
#elif defined(sys_syslog) && sys_syslog == syslog
22+
#define php_syslog sys_syslog
23+
#endif
24+
25+
#endif
26+
27+
#ifndef php_syslog
28+
#define php_syslog syslog
29+
#undef syslog
30+
#endif
31+
32+
33+
#endif

0 commit comments

Comments
 (0)