2012-06-27 09:27:35 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2012-06-28 02:15:13 +02:00
|
|
|
use Cwd;
|
2012-06-27 09:27:35 +02:00
|
|
|
use Data::Dumper;
|
|
|
|
use File::Tail;
|
2013-04-24 06:27:07 +02:00
|
|
|
use Getopt::Std;
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
$Data::Dumper::Sortkeys = 1;
|
|
|
|
|
2013-04-24 06:27:07 +02:00
|
|
|
our $opt_l = 0;
|
|
|
|
getopts('l');
|
|
|
|
|
2012-06-27 09:27:35 +02:00
|
|
|
my (%plugins, %plugin_aliases, %seen_plugins, %pids);
|
|
|
|
my %hide_plugins = map { $_ => 1 } qw/ hostname /;
|
|
|
|
|
|
|
|
my $qpdir = get_qp_dir();
|
|
|
|
my $file = "$qpdir/log/main/current";
|
|
|
|
populate_plugins_from_registry();
|
2013-04-21 06:54:43 +02:00
|
|
|
my @sorted_plugins =
|
|
|
|
sort { $plugins{$a}{id} <=> $plugins{$b}{id} } keys %plugins;
|
|
|
|
|
|
|
|
my $fh = File::Tail->new(
|
|
|
|
name => $file,
|
|
|
|
interval => 1,
|
|
|
|
maxinterval => 1,
|
|
|
|
debug => 1,
|
|
|
|
tail => 1000
|
|
|
|
);
|
2012-06-27 09:27:35 +02:00
|
|
|
my $printed = 0;
|
|
|
|
my $has_cleanup;
|
|
|
|
|
|
|
|
my %formats = (
|
2013-04-21 06:54:43 +02:00
|
|
|
ip => "%-15.15s",
|
|
|
|
hostname => "%-20.20s",
|
|
|
|
distance => "%5.5s",
|
2013-04-24 06:27:07 +02:00
|
|
|
'ident::geoip' => $opt_l ? "%-20.20s" : "%-6.6s",
|
2013-04-21 06:54:43 +02:00
|
|
|
'ident::p0f' => "%-10.10s",
|
|
|
|
count_unrecognized_commands => "%-5.5s",
|
|
|
|
unrecognized_commands => "%-5.5s",
|
|
|
|
dnsbl => "%-3.3s",
|
|
|
|
rhsbl => "%-3.3s",
|
|
|
|
relay => "%-3.3s",
|
|
|
|
karma => "%-3.3s",
|
|
|
|
fcrdns => "%-3.3s",
|
|
|
|
earlytalker => "%-3.3s",
|
|
|
|
check_earlytalker => "%-3.3s",
|
|
|
|
helo => "%-3.3s",
|
|
|
|
tls => "%-3.3s",
|
|
|
|
'auth::auth_vpopmail' => "%-3.3s",
|
|
|
|
'auth::auth_vpopmaild' => "%-3.3s",
|
|
|
|
'auth::auth_vpopmail_sql' => "%-3.3s",
|
|
|
|
'auth::auth_checkpassword' => "%-3.3s",
|
|
|
|
badmailfrom => "%-3.3s",
|
|
|
|
check_badmailfrom => "%-3.3s",
|
|
|
|
sender_permitted_from => "%-3.3s",
|
|
|
|
resolvable_fromhost => "%-3.3s",
|
2013-04-26 03:40:09 +02:00
|
|
|
dont_require_anglebrackets => "%-3.3s",
|
2013-04-21 06:54:43 +02:00
|
|
|
'queue::qmail-queue' => "%-3.3s",
|
|
|
|
connection_time => "%-4.4s",
|
|
|
|
);
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
my %formats3 = (
|
2013-04-21 06:54:43 +02:00
|
|
|
%formats,
|
|
|
|
badrcptto => "%-3.3s",
|
|
|
|
check_badrcptto => "%-3.3s",
|
|
|
|
qmail_deliverable => "%-3.3s",
|
|
|
|
rcpt_ok => "%-3.3s",
|
|
|
|
check_basicheaders => "%-3.3s",
|
|
|
|
headers => "%-3.3s",
|
|
|
|
uribl => "%-3.3s",
|
|
|
|
bogus_bounce => "%-3.3s",
|
|
|
|
check_bogus_bounce => "%-3.3s",
|
|
|
|
domainkeys => "%-3.3s",
|
|
|
|
dkim => "%-3.3s",
|
|
|
|
dmarc => "%-3.3s",
|
|
|
|
spamassassin => "%-3.3s",
|
|
|
|
dspam => "%-3.3s",
|
|
|
|
'virus::clamdscan' => "%-3.3s",
|
|
|
|
);
|
|
|
|
|
|
|
|
while (defined(my $line = $fh->read)) {
|
2012-06-27 09:27:35 +02:00
|
|
|
chomp $line;
|
2013-04-26 03:40:09 +02:00
|
|
|
$line =~ s/[^[ -~]]//g; # strip out binary/unprintable
|
2013-04-21 06:54:43 +02:00
|
|
|
next if !$line;
|
|
|
|
my ($type, $pid, $hook, $plugin, $message) = parse_line($line);
|
|
|
|
next if !$type;
|
2012-06-30 02:28:38 +02:00
|
|
|
next if $type =~ /^(info|unknown|response|tcpserver)$/;
|
2013-04-21 06:54:43 +02:00
|
|
|
next if $type eq 'init'; # doesn't occur in all deployment models
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
if (!$pids{$pid}) { # haven't seen this pid
|
2012-06-27 09:27:35 +02:00
|
|
|
next if $type ne 'connect'; # ignore unless connect
|
|
|
|
my ($host, $ip) = split /\s/, $message;
|
|
|
|
$ip = substr $ip, 1, -1;
|
2013-04-21 06:54:43 +02:00
|
|
|
foreach (keys %seen_plugins, qw/ helo_host from to /) {
|
|
|
|
$pids{$pid}{$_} = '';
|
|
|
|
}
|
|
|
|
$pids{$pid}{ip} = $ip;
|
2012-06-27 09:27:35 +02:00
|
|
|
$pids{$pid}{hostname} = $host if $host ne 'Unknown';
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
if ($type eq 'close') {
|
|
|
|
next if $has_cleanup; # it'll get handled later
|
2012-06-27 09:27:35 +02:00
|
|
|
print_auto_format($pid, $line);
|
|
|
|
delete $pids{$pid};
|
|
|
|
}
|
2013-04-21 06:54:43 +02:00
|
|
|
elsif ($type eq 'cleanup') {
|
2012-06-27 09:27:35 +02:00
|
|
|
print_auto_format($pid, $line);
|
|
|
|
delete $pids{$pid};
|
|
|
|
}
|
2013-04-21 06:54:43 +02:00
|
|
|
elsif ($type eq 'plugin') {
|
2012-06-27 09:27:35 +02:00
|
|
|
next if $plugin eq 'naughty'; # housekeeping only
|
2013-04-21 06:54:43 +02:00
|
|
|
if (!$pids{$pid}{$plugin}) { # first entry for this plugin
|
2012-06-27 09:27:35 +02:00
|
|
|
$pids{$pid}{$plugin} = $message;
|
|
|
|
}
|
|
|
|
else { # subsequent log entry for this plugin
|
2013-04-21 06:54:43 +02:00
|
|
|
if ($pids{$pid}{$plugin} !~ /^(?:pass|fail|skip)/i) {
|
|
|
|
$pids{$pid}{$plugin} = $message; # overwrite 1st
|
2012-06-27 09:27:35 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#print "ignoring subsequent hit on $plugin: $message\n";
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
if ($plugin eq 'ident::geoip') {
|
|
|
|
if (length $message < 3) {
|
|
|
|
$formats{'ident::geoip'} = "%-3.3s";
|
2012-06-30 23:51:59 +02:00
|
|
|
$formats3{'ident::geoip'} = "%-3.3s";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my ($gip, $distance) = $message =~ /(.*?),\s+([\d]+)\skm/;
|
2013-04-21 06:54:43 +02:00
|
|
|
if ($distance) {
|
|
|
|
$pids{$pid}{$plugin} = $gip;
|
2012-06-30 23:51:59 +02:00
|
|
|
$pids{$pid}{distance} = $distance;
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
}
|
2013-04-21 06:54:43 +02:00
|
|
|
elsif ($type eq 'reject') { }
|
|
|
|
elsif ($type eq 'connect') { }
|
|
|
|
elsif ($type eq 'dispatch') {
|
|
|
|
if ($message =~ /^dispatching MAIL FROM/i) {
|
|
|
|
my ($from) = $message =~ /<(.*?)>/;
|
2012-06-27 09:27:35 +02:00
|
|
|
$pids{$pid}{from} = $from;
|
|
|
|
}
|
2013-04-21 06:54:43 +02:00
|
|
|
elsif ($message =~ /^dispatching RCPT TO/i) {
|
|
|
|
my ($to) = $message =~ /<(.*?)>/;
|
2012-06-27 09:27:35 +02:00
|
|
|
$pids{$pid}{to} = $to;
|
|
|
|
}
|
2013-04-21 06:54:43 +02:00
|
|
|
elsif ($message =~ m/dispatching (EHLO|HELO) (.*)/) {
|
2012-06-27 09:27:35 +02:00
|
|
|
$pids{$pid}{helo_host} = $2;
|
|
|
|
}
|
2013-04-21 06:54:43 +02:00
|
|
|
elsif ($message eq 'dispatching DATA') { }
|
|
|
|
elsif ($message eq 'dispatching QUIT') { }
|
|
|
|
elsif ($message eq 'dispatching STARTTLS') { }
|
|
|
|
elsif ($message eq 'dispatching RSET') {
|
2012-06-27 09:27:35 +02:00
|
|
|
print_auto_format($pid, $line);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# anything here is likely an unrecognized command
|
|
|
|
#print "$message\n";
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
print "$type $pid $hook $plugin $message\n";
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
sub parse_line {
|
|
|
|
my $line = shift;
|
|
|
|
my ($tai, $pid, $message) = split /\s+/, $line, 3;
|
2013-04-21 06:54:43 +02:00
|
|
|
return if !$message; # garbage in the log file
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
# lines seen many times per connection
|
2013-04-21 06:54:43 +02:00
|
|
|
return parse_line_plugin($line) if substr($message, 0, 1) eq '(';
|
|
|
|
return ('dispatch', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 12) eq 'dispatching ';
|
|
|
|
return ('response', $pid, undef, undef, $message)
|
|
|
|
if $message =~ /^[2|3]\d\d/;
|
|
|
|
return ('tcpserver', $pid, undef, undef, undef)
|
|
|
|
if substr($pid, 0, 10) eq 'tcpserver:';
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
# lines seen about once per connection
|
2013-04-21 06:54:43 +02:00
|
|
|
return ('init', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 19) eq 'Accepted connection';
|
|
|
|
return ('connect', $pid, undef, undef, substr($message, 16))
|
|
|
|
if substr($message, 0, 15) eq 'Connection from';
|
|
|
|
return ('close', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 6) eq 'close ';
|
|
|
|
return ('close', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 20) eq 'click, disconnecting';
|
|
|
|
return parse_line_cleanup($line)
|
|
|
|
if substr($message, 0, 11) eq 'cleaning up';
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
# lines seen less than once per connection
|
2013-04-21 06:54:43 +02:00
|
|
|
return ('info', $pid, undef, undef, $message)
|
|
|
|
if $message eq 'spooling message to disk';
|
|
|
|
return ('reject', $pid, undef, undef, $message) if $message =~ /^[4|5]\d\d/;
|
|
|
|
return ('reject', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 14) eq 'deny mail from';
|
|
|
|
return ('reject', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 18) eq 'denysoft mail from';
|
|
|
|
return ('info', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 15) eq 'Lost connection';
|
|
|
|
return ('info', $pid, undef, undef, $message)
|
|
|
|
if $message eq 'auth success cleared naughty';
|
|
|
|
return ('info', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 15) eq 'Running as user';
|
|
|
|
return ('info', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 16) eq 'Loaded Qpsmtpd::';
|
|
|
|
return ('info', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 24) eq 'Permissions on spool_dir';
|
|
|
|
return ('info', $pid, undef, undef, $message)
|
|
|
|
if substr($message, 0, 13) eq 'Listening on ';
|
|
|
|
|
|
|
|
return ('err', $pid, undef, undef, $message)
|
|
|
|
if $line =~ /at [\S]+ line \d/; # generic perl error
|
2012-06-27 09:27:35 +02:00
|
|
|
print "UNKNOWN LINE: $line\n";
|
2013-04-21 06:54:43 +02:00
|
|
|
return ('unknown', $pid, undef, undef, $message);
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
sub parse_line_plugin {
|
|
|
|
my ($line) = @_;
|
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
# @tai 13486 (connect) ident::p0f: Windows (XP/2000 (RFC1323+, w, tstamp-))
|
|
|
|
# @tai 13681 (connect) dnsbl: fail, NAUGHTY
|
|
|
|
# @tai 15787 (connect) karma: pass, no penalty (0 naughty, 3 nice, 3 connects)
|
|
|
|
# @tai 77603 (queue) queue::qmail_2dqueue: (for 77590) Queuing to /var/qmail/bin/qmail-queue
|
|
|
|
my ($tai, $pid, $hook, $plugin, $message) = split /\s/, $line, 5;
|
2012-06-27 09:27:35 +02:00
|
|
|
$plugin =~ s/:$//;
|
2013-04-21 06:54:43 +02:00
|
|
|
if ($plugin =~ /_3a/) {
|
|
|
|
($plugin) = split /_3a/, $plugin; # trim :N off the plugin log entry
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
$plugin =~ s/_2d/-/g;
|
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
$plugin = $plugin_aliases{$plugin}
|
|
|
|
if $plugin_aliases{$plugin}; # map alias to master
|
|
|
|
if ($hook eq '(queue)') {
|
2012-06-27 09:27:35 +02:00
|
|
|
($pid) = $message =~ /\(for ([\d]+)\)\s/;
|
|
|
|
$message = 'pass';
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
return ('plugin', $pid, $hook, $plugin, $message);
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
sub parse_line_cleanup {
|
|
|
|
my ($line) = @_;
|
2013-04-21 06:54:43 +02:00
|
|
|
|
2012-06-27 09:27:35 +02:00
|
|
|
# @tai 85931 cleaning up after 3210
|
2013-04-21 06:54:43 +02:00
|
|
|
my $pid = (split /\s+/, $line)[-1];
|
2012-06-27 09:27:35 +02:00
|
|
|
$has_cleanup++;
|
2013-04-21 06:54:43 +02:00
|
|
|
return ('cleanup', $pid, undef, undef, $line);
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
sub print_auto_format {
|
|
|
|
my ($pid, $line) = @_;
|
|
|
|
|
|
|
|
my $format;
|
|
|
|
my @headers;
|
|
|
|
my @values;
|
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
foreach my $plugin (qw/ ip hostname distance /, @sorted_plugins) {
|
|
|
|
if (defined $pids{$pid}{$plugin}) {
|
|
|
|
if (!$seen_plugins{$plugin}) { # first time seeing this plugin
|
2012-06-27 09:27:35 +02:00
|
|
|
$printed = 0; # force header print
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
$seen_plugins{$plugin}++;
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
next if !$seen_plugins{$plugin}; # hide unused plugins
|
|
|
|
if ($hide_plugins{$plugin}) { # user doesn't want to see
|
2012-06-27 09:27:35 +02:00
|
|
|
delete $pids{$pid}{$plugin};
|
|
|
|
next;
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-24 06:27:07 +02:00
|
|
|
my $wide = $opt_l ? 20 : 8;
|
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
if (defined $pids{$pid}{helo_host} && $plugin =~ /helo/) {
|
2013-04-24 06:27:07 +02:00
|
|
|
$format .= " %-$wide.${wide}s";
|
|
|
|
push @values, substr(delete $pids{$pid}{helo_host}, -$wide, $wide);
|
2012-06-27 09:27:35 +02:00
|
|
|
push @headers, 'HELO';
|
|
|
|
}
|
2013-04-21 06:54:43 +02:00
|
|
|
elsif (defined $pids{$pid}{from} && $plugin =~ /from/) {
|
2013-04-24 06:27:07 +02:00
|
|
|
$format .= " %-$wide.${wide}s";
|
|
|
|
push @values, substr(delete $pids{$pid}{from}, -$wide, $wide);
|
2012-06-27 09:27:35 +02:00
|
|
|
push @headers, 'MAIL FROM';
|
|
|
|
}
|
2013-04-21 06:54:43 +02:00
|
|
|
elsif (defined $pids{$pid}{to} && $plugin =~ /to|rcpt|recipient/) {
|
2013-04-24 06:27:07 +02:00
|
|
|
$format .= " %-$wide.${wide}s";
|
2013-04-21 06:54:43 +02:00
|
|
|
push @values, delete $pids{$pid}{to};
|
2012-06-27 09:27:35 +02:00
|
|
|
push @headers, 'RCPT TO';
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
$format .= $formats3{$plugin} ? " $formats3{$plugin}" : " %-10.10s";
|
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
if (defined $pids{$pid}{$plugin}) {
|
|
|
|
push @values, show_symbol(delete $pids{$pid}{$plugin});
|
2012-06-27 09:27:35 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
push @values, '';
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
push @headers,
|
|
|
|
($plugins{$plugin}{abb3} ? $plugins{$plugin}{abb3} : $plugin);
|
2012-06-27 09:27:35 +02:00
|
|
|
}
|
|
|
|
$format .= "\n";
|
2013-04-21 06:54:43 +02:00
|
|
|
printf("\n$format", @headers) if (!$printed || $printed % 20 == 0);
|
|
|
|
printf($format, @values);
|
2013-04-24 06:27:07 +02:00
|
|
|
#print Data::Dumper::Dumper($pids{$pid}) if keys %{$pids{$pid}};
|
2012-06-27 09:27:35 +02:00
|
|
|
$printed++;
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
sub show_symbol {
|
|
|
|
my $mess = shift;
|
|
|
|
return ' o' if $mess eq 'TLS setup returning';
|
2013-04-21 02:31:13 +02:00
|
|
|
return ' o' if $mess eq 'pass';
|
2012-06-27 09:27:35 +02:00
|
|
|
return ' -' if $mess eq 'skip';
|
2013-04-24 22:25:31 +02:00
|
|
|
return ' x' if 'fail, tolerated' eq substr($mess, 0, 15);
|
2013-04-21 02:31:13 +02:00
|
|
|
return ' X' if $mess eq 'fail';
|
2012-06-27 09:27:35 +02:00
|
|
|
return ' -' if $mess =~ /^skip[,:\s]/i;
|
|
|
|
return ' o' if $mess =~ /^pass[,:\s]/i;
|
|
|
|
return ' X' if $mess =~ /^fail[,:\s]/i;
|
|
|
|
return ' x' if $mess =~ /^negative[,:\s]/i;
|
|
|
|
return ' o' if $mess =~ /^positive[,:\s]/i;
|
|
|
|
return ' !' if $mess =~ /^error[,:\s]/i;
|
|
|
|
$mess =~ s/\s\s/ /g;
|
|
|
|
return $mess;
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
sub get_qp_dir {
|
2013-04-21 06:54:43 +02:00
|
|
|
foreach my $user (qw/ qpsmtpd smtpd /) {
|
|
|
|
my ($homedir) = (getpwnam($user))[7] or next;
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
if (-d "$homedir/plugins") {
|
2012-06-27 09:27:35 +02:00
|
|
|
return "$homedir";
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
foreach my $s (qw/ smtpd qpsmtpd qpsmtpd-dev /) {
|
|
|
|
if (-d "$homedir/$s/plugins") {
|
2012-06-30 02:39:44 +02:00
|
|
|
return "$homedir/$s";
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (-d "./plugins") {
|
2012-06-28 02:15:13 +02:00
|
|
|
return Cwd::getcwd();
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
sub populate_plugins_from_registry {
|
|
|
|
|
|
|
|
my $file = "$qpdir/plugins/registry.txt";
|
2013-04-21 06:54:43 +02:00
|
|
|
if (!-f $file) {
|
2012-06-27 09:27:35 +02:00
|
|
|
die "unable to find plugin registry\n";
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|
|
|
|
open my $F, '<', $file;
|
2013-04-21 06:54:43 +02:00
|
|
|
while (defined(my $line = <$F>)) {
|
|
|
|
next if $line =~ /^#/; # discard comments
|
2013-04-24 06:27:07 +02:00
|
|
|
chomp $line;
|
|
|
|
next if ! $line;
|
2012-06-27 09:27:35 +02:00
|
|
|
my ($id, $name, $abb3, $abb5, $aliases) = split /\s+/, $line;
|
2013-04-21 06:54:43 +02:00
|
|
|
next if !defined $name;
|
|
|
|
$plugins{$name} = {id => $id, abb3 => $abb3, abb5 => $abb5};
|
2012-06-27 09:27:35 +02:00
|
|
|
|
2013-04-21 06:54:43 +02:00
|
|
|
next if !$aliases;
|
2012-06-27 09:27:35 +02:00
|
|
|
$aliases =~ s/\s+//g;
|
|
|
|
$plugins{$name}{aliases} = $aliases;
|
2013-04-21 06:54:43 +02:00
|
|
|
foreach my $a (split /,/, $aliases) {
|
2012-06-27 09:27:35 +02:00
|
|
|
$plugin_aliases{$a} = $name;
|
2013-04-21 06:54:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-06-27 09:27:35 +02:00
|
|
|
|