{"id":502,"date":"2010-03-19T15:04:30","date_gmt":"2010-03-19T13:04:30","guid":{"rendered":"https:\/\/mschuette.name\/wp\/?p=502"},"modified":"2010-03-19T15:04:30","modified_gmt":"2010-03-19T13:04:30","slug":"php-syslog-patch","status":"publish","type":"post","link":"https:\/\/mschuette.name\/wp\/2010\/03\/php-syslog-patch\/","title":{"rendered":"PHP syslog patch"},"content":{"rendered":"<p>Given a multiuser webserver with PHP and error logging to syslog. Problem: how do you correlate error messages with users? This patch lets PHP call <code>openlog()<\/code> with a configurable program name.<!--more--><\/p>\n<p>My first approach was to filter by file and path names, but not every message includes a filename, so I was left with some lines like these:<\/p>\n<blockquote><p><code>2010-03-15T00:00:15.00+01:00 server php-cgi: Undeclared entity warning at line 54, column 8<\/code><\/p><\/blockquote>\n<p>To overcome the problem I introduce two new php.ini variables: <code>syslog.program<\/code>, to give the program name, and the boolean <code>syslog.pid<\/code>, to enable logging the PID. Default values are <code>\"\"<\/code> and <code>Off<\/code>, resulting in the previous behaviour (using the executable name as program name without PID). I use <a href=\"http:\/\/www.suphp.org\/\">suphp<\/a>, so every user has an own php.ini with <code>syslog.program<\/code> set to &#8220;php\/username&#8221;, thus writing log lines like:<\/p>\n<blockquote><p><code>2010-03-19T09:00:14.00+01:00 server php\/mschuett[87777]: Undeclared entity warning at line 54, column 8<\/code><\/p><\/blockquote>\n<p>With mod_php the variables can also be set per directory with <code>php_admin_value<\/code>. Changing them with <code>ini_set()<\/code> is not supported (not necessary because a new call to <code>openlog()<\/code> has the same effect). For enhanced security one could\/should also use the php.ini setting <code>disable_functions=openlog<\/code> to prevent users from overriding these settings.<\/p>\n<p>Because the source file is also affected by the <a href=\"http:\/\/www.hardened-php.net\/suhosin\/\">Suhosin<\/a> patch, I prepared two diffs:<\/p>\n<ul>\n<li>PHP 5.2.12:<a href=\"\/files\/patch-php5.2.12.ext_standard_syslog.diff\">patch-php5.2.12.ext_standard_syslog.diff<\/a><\/li>\n<li>PHP  5.2.12 with Suhosin: <a href=\"\/files\/patch-php5.2.12.suhosin.ext_standard_syslog.diff\">patch-php5.2.12.suhosin.ext_standard_syslog.diff<\/a><\/li>\n<\/ul>\n<p>[<strong>Update:<\/strong> the patches still work for PHP 5.3.6]<br \/>\n[<strong>Update2:<\/strong> finally got around to write a <a href=\"http:\/\/bugs.php.net\/bug.php?id=54144\">Feature Request #54144<\/a>] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Given a multiuser webserver with PHP and error logging to syslog. Problem: how do you correlate error messages with users? This patch lets PHP call openlog() with a configurable program name.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,7,13,16],"tags":[140,178,189,248,405,277],"class_list":["post-502","post","type-post","status-publish","format-standard","hentry","category-admin","category-english","category-php-digital-2","category-syslog","tag-logging","tag-patch","tag-php","tag-suphp","tag-syslog","tag-webserver"],"_links":{"self":[{"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/posts\/502","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/comments?post=502"}],"version-history":[{"count":0,"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/posts\/502\/revisions"}],"wp:attachment":[{"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/media?parent=502"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/categories?post=502"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mschuette.name\/wp\/wp-json\/wp\/v2\/tags?post=502"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}