php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #58829 syslog polution
Submitted: 2009-08-25 10:17 UTC Modified: 2017-10-24 23:23 UTC
From: ob dot php at daevel dot fr Assigned:
Status: Suspended Package: proctitle (PECL)
PHP Version: 5.2.6 OS: debian lenny 64bits
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ob dot php at daevel dot fr
New email:
PHP Version: OS:

 

 [2009-08-25 10:17 UTC] ob dot php at daevel dot fr
Description:
------------
If I use setproctitle() then syslog() to report a message, this message contains part of the setproctitle() parameter followed by lot of spaces.
But maybe it's a syslog normal behaviour ?

Reproduce code:
---------------
<?php
setproctitle('modified title');
syslog(LOG_INFO, 'tracked error');
?>

Expected result:
----------------
Aug 25 16:15:24 gloof php tracked error
or
Aug 25 16:15:24 gloof modified title tracked error

Actual result:
--------------
Aug 25 16:15:24 gloof modified title                                                                                                                 : tracked error


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-25 10:20 UTC] ob dot php at daevel dot fr
note : the size of "modified title" + spaces + ":" is exactly 128 bytes.
 [2009-09-21 16:16 UTC] jhaagsma at gmail dot com
This problem also exists for listing the process with ps aux for example

the issue is the space padding to MAX_TITLE_LENGTH I believe, having browsed through the code a bit; not knowing anything about process titles in linux, I must ask, is it necessary to pad it with spaces?  Must it be the max length? somehow it seems like it shouldn't be necessary given it's only these processes that show this behaviour

Incidentally, for ps auxf, the lines just trail off the screen, but if you pipe them to something (like grep) it is immediately apparent that the titles are much longer than the rest
 [2009-09-21 16:23 UTC] ob dot php at daevel dot fr
A workaround is to concat chr(0) add the end of the string.
 [2009-09-21 17:13 UTC] jhaagsma at gmail dot com
Ahh, that does make it a little better; oddly enough though, since I was renaming a (forked) process that had been run from a fairly long path, the remainder of the path showed up after that part:

original name:
/usr/bin/php /var/botdir/bin/bot_master_process.php

intended name:
bot child: ranks_scraper

actual name:
bot child: ranks_scraper bin/bot_master_process.php


as a workaround of that, I just used str_pad with just enough spaces to cover the original name, then chr(0)

so still some 'space' pollution, but better than before
 [2009-09-21 18:58 UTC] magicaltux@php.net
Unfortunately, the spaces addition is due to a limitation in linux linked to process changing.

On *BSD, a syscall exists to change the process' name, and everything is alright.
On Linux, we have to overwrite 128 bytes with spaces.

I guess this can be half-fixed by reading initial string's length, and not adding more spaces than required...
 [2010-05-21 09:51 UTC] glibin dot v at gmail dot com
My solution was adding:

# diff proctitle.old.c proctitle.c
51a52
> 	buffer[tlen] = '\0';

And works fine for me (Debian Lenny 64bits).
 [2010-05-21 17:47 UTC] magicaltux@php.net
fix by glibin dot v at gmail dot com will cause the process 
title to not be fully overwritten if not long enough to cover 
the existing title.
I'll see to release a new version with more memcpy and two 
new defines (PROCTITLE_SAFE_LEN and PROCTITLE_MAX_LEN, first 
one being the max length without overwriting environ, and 
second one being the overall max len)
 [2017-10-24 23:23 UTC] kalle@php.net
-Status: Open +Status: Suspended
 [2017-10-24 23:23 UTC] kalle@php.net
The proctitle package have not had a release since 2012 and no development since, its safe to say that this package is no longer maintained, if development picks back up then this report should be re-opened
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Feb 16 01:01:26 2019 UTC