Web Hosting Talk







View Full Version : Webalizer 2, rights


phuture
02-09-2002, 01:27 PM
Hi,

I installed the Webalizer2 Package from http://cobalt-aid.sourceforge.net/files/ which now stores the stats in a ~stats directory for every virtual host.

The problem is, that all the statistics which are generated by the /usr/bin/webalizer2.pl script (this is the main script which does all the jobs nightly) are owned by root so that the site admin of the virtual host has no possibility to delete some of them when the account filesize limit is reached.

The script does:

# Where sites on a RaQ3/4 live
$prefix = "/home/sites";
# Status messages
my $messages;

chdir "$prefix" or die "Can't cd to $prefix??: $!\n";
opendir THEROOT, $prefix or die "Couldn't open $prefix?: $!\n";
@allsites = grep !/^\.\.?$/, readdir THEROOT;

foreach $asite (@allsites)
{
if (-l "$asite")
{
$webpath = "$prefix/$asite/web";
$thepath = "$prefix/$asite/users/stats";

# Get the group id of the directory
my $gid = (stat $webpath)[5];
my $name = (getgrgid $gid)[0];

# Create a directory /users/stats if it isn't there yet
if (!-d $thepath)
{
mkdir $thepath, 775;
chown 0, $gid, $thepath;
chmod 0755, $thepath;
}


$thepath = "$prefix/$asite/users/stats/web";
# Create a directory /users/stats if it isn't there yet
if (!-d $thepath)
{
mkdir $thepath, 775;
chown 0, $gid, $thepath;
chmod 0755, $thepath;
}

# Create a .htaccess if it isn't there yet
if (!-e '$thepath/.htaccess')
{
my $string = "#Access file\norder allow,deny\nallow from all\nrequire group $name\nAuthname WebStats\nAuthtype Basic";
open HTACCESS, qq(>$thepath/.htaccess);
print HTACCESS $string;
close HTACCESS;
chmod 0744, qq($thepath/.htaccess);
}

# Now just run webalizer
$messages .=
`webazolver -N15 -D /home/log/reverse.dns $prefix/$asite/logs/web.log`;
$messages .=
`webalizer -p -n $asite -q -T -D /home/log/reverse.dns -o $thepath $prefix/$asite/logs/web.log`;
}
}

# Debugging printer, uncomment to use.
# print $messages;
exit 0;


Is there a possibility to make a chmod or a chown at the end of the loop so that the generated files and of course the old ones could be deleted by the site admin?

Regards,
Felix-Gabriel