From a8f0d8c5982060d95b762c0808e467009d2dbe6f Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr> Date: Mon, 17 Nov 2008 15:21:35 +0000 Subject: [PATCH] log truncating for unrecognized IPs only & lowered to 4kB --- boot/upload-bmlog.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/boot/upload-bmlog.php b/boot/upload-bmlog.php index 4584111..ed13534 100755 --- a/boot/upload-bmlog.php +++ b/boot/upload-bmlog.php @@ -1,11 +1,15 @@ <?php - // Thierry Parmentelat -- INRIA - // first draft for a revival of former (3.x?) alpina-logs in 5.0 +// Thierry Parmentelat -- INRIA +// first draft for a revival of former (3.x?) alpina-logs in 5.0 - // this needs be created with proper permissions at package install time +// this needs be created with proper permissions at package install time $logdir="/var/log/bm"; -$limit_bytes=16*1024; + +// limit: applies to uploads coming from an unrecognized IP +$limit_bytes=4*1024; + +$default_hostname="unknown"; function mkdir_if_needed ($dirname) { if (is_dir ($dirname)) @@ -21,7 +25,7 @@ global $adm; // with an ip the same as the http requestor ip $ip = $_SERVER['REMOTE_ADDR']; -$hostname="unknown"; +$hostname=$default_hostname; // locate hostname from DB based on this IP $interfaces=$adm->GetInterfaces(array("ip"=>$ip)); if (! empty($interfaces) ) { @@ -54,8 +58,8 @@ fprintf ($log, "BootManager log created on: %s-%s\n",$month,$time); fprintf( $log, "From IP: %s\n",$ip); fprintf( $log, "hostname: %s\n",$hostname); fprintf ( $log, "uploaded file: %s (%d bytes)\n",$uploaded_name,$uploaded_size); -if ( $uploaded_size >= $limit_bytes) { - fprintf ( $log, "contents truncated to %d bytes\n",$limit_bytes); +if ( ( strcmp($hostname,$default_hostname)==0) && ( $uploaded_size >= $limit_bytes) ) { + fprintf ( $log, "contents from an unrecognized IP address was truncated to %d bytes\n",$limit_bytes); $truncated=TRUE; $uploaded_size=$limit_bytes; } -- 2.47.0