You forgot the frontpage users
If someone i susing frontpage the user is nobody
-----Oorspronkelijk bericht-----
So, in that case, I just have to remove the entry in the local-host-names.
I tried to write a little script to set sendmail's envelope from to the
right user so that any bounces from mail send from phpscripts go to the
owner of that script, and not me, as an admin.
I am no expert at perl. In fact, this is just my second perl script. So if
anyone sees any glitch or think it can be more efficient, please let me
know.
You can put the script in /etc/cron.daily
#!/usr/bin/perl
#
# Set sendmail's 'envelope from' to all owners of a site
#
$allsitespath = "/home/sites/";
$checkpath = "/web/";
$configpath = "/etc/httpd/conf/vhosts/";
$phpcommand = "php_admin_value sendmail_path ";
$localhosts = "/etc/mail/local-host-names";
# if we're no mailrelay for a vhost, what should we use?
$defaultname = "admin";
$defaultsite = "yourdefaultdomain";
# read localhostsname
open (LHOSTS, "<$localhosts") or die "Can't open $localhosts: $!\n";;
@localhostsarray=<LHOSTS>;
close LHOSTS;
opendir THEROOT, $allsitespath or die "Couldn't open $prefix: $!\n";
@allsites = grep !/^\.\.?$/, readdir THEROOT;
foreach $site (@allsites)
{
my $sitedir = $allsitespath . $site . $checkpath;
opendir SITEROOT, $sitedir or die "Couldn't open $siteindex: $!\n";
(at mark) thissite = grep /^index\..*/, readdir SITEROOT;
for $index (@thissite)
{
$messages .= "*** $site:\n";
# Get the owner id of the directory
my $oid = (stat $sitedir . $index)[4];
my $gid = (stat $sitedir . $index)[5];
my $name = (getpwuid $oid)[0];
my $group = (getgrgid $gid)[0];
# remove www. in front of sitename
if ($site =~ /^www\..*/)
{
$ownersite = substr($site, 4);
$ok = IsALocalHostname($ownersite);
}
else
{
# trigger a test
$ok = 1;
}
if ($ok != 0)
{
if (IsALocalHostname($site) == 0)
{
$ownersite = $site
}
else
{
$name = $defaultname;
$ownersite = $defaulsite;
}
}
my $envelope = $name . " (at mark) " . $ownersite;
my $sendmail = "\" /usr/sbin/sendmail -t -i -f$envelope\"";
$configfile = $configpath . $group . ".include";
open (CONF, $configfile) or die "Can't open $configfile: $!\n";
@configcontent = <CONF>;
close CONF;
$i = 0;
while ($i <= @configcontent)
{
if ($configcontent[$i] =~ /$phpcommand/ && $configcontent[$i] !~ /^
*\#/)
{
last;
}
else
{
$i++;
}
}
if ($i > @configcontent)
{
$messages .= "$phpcommand not defined in $configfile. Will
append.\n";
open (CONF, ">>$configfile");
print CONF ("$phpcommand $sendmail\n");
}
else
{
open (CONF, ">$configfile");
$configcontent[$i] = $phpcommand . $sendmail . "\n";
print CONF (@configcontent);
$messages .= "Changed line $i in $configfile\n";
}
$messages .= "$envelope\n";
}
}
$messages .= `/etc/rc.d/init.d/httpd restart`;
#uncomment for debug
#print $messages;
# subroutine to check if a line exists
sub IsALocalHostname
{
my($test) = @_;
if (grep{/^$test$/}@localhostsarray)
{
$messages .= "$test is a localhostname\n";
return 0;
}
else
{
$messages .= "$test is NOT a localhostname\n";
return 1;
}
}
--
Maurice de Laat