my ($csec, $usec) = gettimeofday ();
- my $cinfo = PVE::INotify::read_file("cluster.conf");
+ my $cinfo = PMG::ClusterConfig->new();
my $lcid = $cinfo->{local}->{cid};
my $role = $cinfo->{local}->{type} // '-';
my $err = $@;
if ($err) {
- $self->log(0, PMG::Utils::msgquote("ERROR: $err"));
+ $self->log(0, "ERROR: $err");
return;
}
# this produces too much log traffic
# my $targets = join (", ", @rcvrs);
#my $msg = "expire mail $ref->{instance} from $ref->{sender} to $targets";
- #$self->log (0, PMG::Utils::msgquote ($msg));
+ #$self->log (0, $msg);
}
$dbh->do ($cmds) if $cmds;
if ($err) {
$dbh->rollback if $dbh;
- $self->log(0, PMG::Utils::msgquote($err));
+ $self->log(0, $err);
} else {
$self->log(2, "end greylist database maintainance ($ptime ms)");
}
# reloading server configuration
if (defined $prop->{children}) {
foreach my $pid (keys %{$prop->{children}}) {
- kill (10, $pid); # SIGUSR1 childs
+ kill(10, $pid); # SIGUSR1 childs
}
}
};
}
my $pmg_cfg = PMG::Config->new ();
- $self->{use_rbl} = $pmg_cfg->get('mail', 'use_rbl');
$self->{use_spf} = $pmg_cfg->get('mail', 'spf');
$self->{use_greylist} = $pmg_cfg->get('mail', 'greylist');
+ if ($opt_testmode) {
+ $self->{use_spf} = 1;
+ $self->{use_greylist} = 1;
+ }
+
my $nodename = PVE::INotify::nodename();
- my $resolv = PVE::INotify::read_file('resolvconf');
- my $domain = $resolv->{search};
- $self->{fqdn} = "$nodename.$domain";
+ $self->{fqdn} = PVE::Tools::get_fqdn($nodename);
- my $cinfo = PVE::INotify::read_file("cluster.conf");
+ my $cinfo = PMG::ClusterConfig->new();
my $lcid = $cinfo->{local}->{cid};
$self->{cinfo} = $cinfo;
$self->{lcid} = $lcid;
$self->{rulecache} = PMG::RuleCache->new($self->{ruledb});
};
if (my $err = $@) {
- $self->log(0, PMG::Utils::msgquote("ERROR: unable to load database : $err"));
+ $self->log(0, "ERROR: unable to load database : $err");
}
$self->{reload_config} = 0;
hostname => $self->{fqdn}, dns_resolver => $self->{dns_resolver});
};
if (my $err = $@) {
- $self->log(0, PMG::Utils::msgquote($err));
+ $self->log(0, $err);
$self->child_finish_hook;
exit(-1);
}
};
my $err = $@;
if ($err) {
- $self->log(0, PMG::Utils::msgquote("unable to reconnect to database server: $err"));
+ $self->log(0, "unable to reconnect to database server: $err");
return 'dunno';
}
$self->{ruledb} = PMG::RuleDB->new($dbh);
if ($err) {
$err = $err->text if UNIVERSAL::isa ($err, 'Mail::SPF::Exception');
- $self->log (0, PMG::Utils::msgquote($err));
+ $self->log (0, $err);
} else {
if ($result && $result eq 'pass') {
if (!defined($ref->{rctime})) {
- $dbh->do("SELECT merge_greylist(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", undef,
+ $dbh->do($PMG::DBTools::cgreylist_merge_sql, undef,
$net, $host, $sender, $rcpt, $instance,
$ctime, $ctime + 10, 0, 100000, 0, $ctime, $self->{lcid});
}
};
if (my $err = $@) {
$dbh->rollback;
- $self->log(0, PMG::Utils::msgquote($err));
+ $self->log(0, $err);
}
}
}
if (!defined($ref->{rctime})) {
- $dbh->do ("SELECT merge_greylist(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", undef,
- $net, $host, $sender, $rcpt, $instance,
- $ctime, $ctime + $greylist_lifetime, 0, 1, 0, $ctime, $self->{lcid});
+ $dbh->do($PMG::DBTools::cgreylist_merge_sql, undef,
+ $net, $host, $sender, $rcpt, $instance,
+ $ctime, $ctime + $greylist_lifetime, 0, 1, 0, $ctime, $self->{lcid});
$res = $defer_res;
$self->log(3, "defer greylisted mail");
};
if (my $err = $@) {
$dbh->rollback;
- $self->log (0, PMG::Utils::msgquote($err));
+ $self->log (0, $err);
}
return $res;
lc ($attribute->{instance}));
};
if (my $err = $@) {
- $self->log(0, PMG::Utils::msgquote($err));
+ $self->log(0, $err);
}
}
$$dataref = '';
}
- $self->log(0, PMG::Utils::msgquote($err)) if $err;
+ $self->log(0, $err) if $err;
}
sub restart_close_hook {
if (defined $prop->{_HUP}) {
undef $prop->{pid_file_unlink};
}
+
+ if (defined $prop->{children}) {
+ foreach my $pid (keys %{$prop->{children}}) {
+ kill(1, $pid); # HUP childs
+ }
+ }
+
+ # nicely shutdown childs (give them max 30 seconds to shut down)
+ my $previous_alarm = alarm(30);
+ eval {
+ local $SIG{ALRM} = sub { die "Timed Out!\n" };
+
+ my $pid;
+ 1 while ((($pid = waitpid(-1, 0)) > 0) || ($! == EINTR));
+
+ alarm(0); # avoid race
+ };
+ alarm ($previous_alarm);
}
sub setup_fork_signal_mask {
# sometimes the socket is not usable, don't know why
my $flags = fcntl($sock, F_GETFL, 0);
if (!$flags) {
- $self->log(0, PMG::Utils::msgquote("socket not ready - $!"));
+ $self->log(0, "socket not ready - $!");
exit (-1);
}
$mux->loop;
};
if (my $err = $@) {
- $self->log(0, PMG::Utils::msgquote("ERROR: $err"));
+ $self->log(0, "ERROR: $err");
}
$self->child_finish_hook;