]> granicus.if.org Git - php/commitdiff
Add syslog.filter=raw
authorErik Lundin <erik@coretech.se>
Sat, 15 Jun 2019 07:31:16 +0000 (09:31 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 17 Jun 2019 11:13:25 +0000 (13:13 +0200)
This passes through syslog message unchanged, without splitting
messages at newlines.

NEWS
main/main.c
main/php_syslog.c
main/php_syslog.h
php.ini-development
php.ini-production

diff --git a/NEWS b/NEWS
index 2fe64f4ad351d59423ea132966b64b82b6e7992e..ecd81b0c5ed05c9045c16f4f8868c34f9e59f0f4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? ????, PHP 7.3.8
 
+- Core:
+  . Added syslog.filter=raw option. (Erik Lundin)
+
 - Opcache:
   . Fixed bug #78106 (Path resolution fails if opcache disabled during request).
     (Nikita)
index ee422db52f7d4e857fab8b69e20fe694fea04032..98c0a26f43b34a8847457b1865cefe864abc7024 100644 (file)
@@ -346,6 +346,10 @@ static PHP_INI_MH(OnSetLogFilter)
                PG(syslog_filter) = PHP_SYSLOG_FILTER_ASCII;
                return SUCCESS;
        }
+       if (!strcmp(filter, "raw")) {
+               PG(syslog_filter) = PHP_SYSLOG_FILTER_RAW;
+               return SUCCESS;
+       }
 
        return FAILURE;
 }
index dd16f05217c1f0d4ce143d105319a1a2acb22cc2..561a63cf00c1e246c0c51648a848eb751ca18852 100644 (file)
@@ -77,6 +77,13 @@ PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
        smart_string_0(&fbuf);
        va_end(args);
 
+       if (PG(syslog_filter) == PHP_SYSLOG_FILTER_RAW) {
+               /* Just send it directly to the syslog */
+               syslog(priority, "%.*s", (int)fbuf.len, fbuf.c);
+               smart_string_free(&fbuf);
+               return;
+       }
+
        for (ptr = fbuf.c; ; ++ptr) {
                c = *ptr;
                if (c == '\0') {
index dee0e5aaa37805a38c6c41988a6e40bef6b27f00..401f498194b78ab4bba5a27e2cdd2ae80144e11a 100644 (file)
@@ -34,6 +34,7 @@
 #define PHP_SYSLOG_FILTER_ALL          0
 #define PHP_SYSLOG_FILTER_NO_CTRL      1
 #define PHP_SYSLOG_FILTER_ASCII                2
+#define PHP_SYSLOG_FILTER_RAW          3
 
 BEGIN_EXTERN_C()
 PHPAPI void php_syslog(int, const char *format, ...);
index 320cf170a3bab2996d32ba640bc9999ceb5074c0..97e1657a7c57e292fcc71550c083f14db982a6e6 100644 (file)
@@ -596,6 +596,7 @@ html_errors = On
 ;   ascii (all printable ASCII characters and NL)
 ;   no-ctrl (all characters except control characters)
 ;   all (all characters)
+;   raw (like "all", but messages are not split at newlines)
 ; http://php.net/syslog.filter
 ;syslog.filter = ascii
 
index 656ae6730213c86ec615a85a76490a7a0811d792..a44fe0fa99ba49b23270c67f5a0e93091c36dfed 100644 (file)
@@ -603,6 +603,7 @@ html_errors = On
 ;   ascii (all printable ASCII characters and NL)
 ;   no-ctrl (all characters except control characters)
 ;   all (all characters)
+;   raw (like "all", but messages are not split at newlines)
 ; http://php.net/syslog.filter
 ;syslog.filter = ascii