[vhffs-dev] [1189] logs and awstats directories now belong to uid/ gid of the website with a chmod 770, so that other users are not able to read logs of other websites anymore

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1189
Author:   gradator
Date:     2008-04-19 23:57:22 +0200 (Sat, 19 Apr 2008)

Log Message:
-----------
logs and awstats directories now belong to uid/gid of the website with a chmod 770, so that other users are not able to read logs of other websites anymore

Modified Paths:
--------------
    trunk/vhffs-robots/src/web_stats.pl


Modified: trunk/vhffs-robots/src/web_stats.pl
===================================================================
--- trunk/vhffs-robots/src/web_stats.pl	2008-04-07 09:36:36 UTC (rev 1188)
+++ trunk/vhffs-robots/src/web_stats.pl	2008-04-19 21:57:22 UTC (rev 1189)
@@ -74,8 +74,10 @@
 Vhffs::Robots::lock( $vhffs , "webstats" );
 
 my %websites;
-foreach ( @{$webs} )  {
-	$websites{$_->get_servername} = 1;
+foreach my $ws ( @{$webs} )  {
+	$websites{$ws->get_servername}{'servername'} = $ws->get_servername;
+	$websites{$ws->get_servername}{'owner_uid'} = $ws->get_owner_uid;
+	$websites{$ws->get_servername}{'owner_gid'} = $ws->get_owner_gid;
 }
 
 my @webservers;
@@ -158,7 +160,11 @@
 			# the website changed
 			if ( $prev ne $svname )  {
 				my $dir = $log_parsed_root."/".Vhffs::Functions::hash_webdir( $svname )."/logs";
-				Vhffs::Functions::create_dir($dir) if ( ! -d $dir );
+				unless( -d $dir )  {
+					Vhffs::Functions::create_dir($dir);
+					chown( $websites{$svname}{'owner_uid'} , $websites{$svname}{'owner_gid'} , $dir );
+					chmod( 0770 , $dir );
+				}
 
 				my $lff = $dir."/access.log";
 				close(FILEOUT);
@@ -190,7 +196,11 @@
 	#next if( -f $conffile );
 
 	next if ( ! -f $logpath );
-	Vhffs::Functions::create_dir($datadir) if ( ! -d $datadir );
+	unless( -d $datadir )  {
+		Vhffs::Functions::create_dir($datadir);
+		chown( $websites{$svname}{'owner_uid'} , $websites{$svname}{'owner_gid'} , $datadir );  
+		chmod( 0770 , $datadir );
+	}
 
 	# Create the config file
 	open( AWFILEIN , "< ".$awstats_sample );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/