#!/bin/bash # # log-qmail-inject # John Simpson 2009-12-14 # # qmail-inject wrapper to log calls. useful for tracking down broken or # compromised web scripts. # ############################################################################### # # Copyright (C) 2009 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 3, as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### # # configuration # # location of the real qmail-inject REAL=/var/qmail/bin/qmail-inject.real ############################################################################### ############################################################################### ############################################################################### # # let's do this LOGFILE=`mktemp /tmp/qmail-inject.XXXXXX` ( echo Time: `date "+%Y-%m-%d %H:%M:%S %z"` echo Cmd: qmail-inject "$@" id if [ "`uname -s`" = "Linux" ] then echo "" echo "============================================================" echo Parent processes echo "------------------------------------------------------------" X=$$ while [ "$X" != "0" ] do printf "%6d " $X if [ -d /proc/$X ] then printf "[%s] " `readlink /proc/$X/cwd` tr '\0' ' ' < /proc/$X/cmdline echo "" else echo "(gone)" break fi X=`grep PPid /proc/$X/status | sed 's/[^0-9]//g'` done fi echo "" echo "============================================================" echo Environment echo "------------------------------------------------------------" env | sort echo "" echo "============================================================" echo Message sent echo "------------------------------------------------------------" ) > $LOGFILE 2>&1 ############################################################################### # # run the real qmail-inject tee -a $LOGFILE | $REAL "$@"