UnderHost Networks Ltd


If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.



Reply
  #1 (permalink)  
Old 05-01-2009, 04:21 AM
UnderHost's Avatar
UnderHost Management
 
Join Date: Jul 2008
Posts: 588
Default How to track mail from PHP when run as nobody?

Problem:

One of the biggest problems with shared hosting is that PHP runs as the web server user rather than the user assigned in the virtualhost (unless your running PHP as CGI). This is a huge problem because when a site is compromised and a attacker is using your server to spam it can be very difficult to track down what site/script/page is causing the problem.


Solution:

The solution is a patch located at http://choon.net/php-mail-header.php. It modifies php's mail.c file so that when the mail function is called from the web that it stores the following information.

X-PHP-Script: www.example.com/~user/testapp/send-mail.php for 10.0.0.1

in the headers so that when a spam report does come in, you can easily track where it came from.



Below is a how to for cPanel servers that shows how you can implement this patch.



Run the following as root:

PHP Code:
mkdir -/var/cpanel/buildapache/scripts
cat 
>> phppost << EOF
#AUTO PATCH FROM http://choon.net/php-mail-header.php
PHPVER=`find -type d -iname "php-*"|sed "s/.///g"`
wget http://choon.net/opensource/php/$PHPVER-mail-header.patch
patch -p0 $PHPVER-mail-header.patch
EOF 

Once that's done, run
PHP Code:
/scripts/easyapache 
like you normally would.
__________________

UnderHostProviding Affordable and Quality Web Hosting & Offshore Hosting
24/7 Fast Support / 99.9% Uptime Guarantee
UHVPSVirtual Private Servers & Premium Offshore VPS
Hong Kong - Singapore - USA - Canada - Netherlands - United Kingdom - Germany
Reply With Quote
underhost.us
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Loading...


All times are GMT -4. The time now is 04:41 PM.
Copyright © 2009 UnderHost Networks Ltd