Last change
on this file since 33 was 27, checked in by Kris Deugau, 14 years ago |
/trunk/uribl
Add URI blacklist database interface code
|
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Date Rev Author Id
|
File size:
1.2 KB
|
Line | |
---|
1 | #!/usr/bin/perl
|
---|
2 | # Export URI blacklist data
|
---|
3 |
|
---|
4 | use strict;
|
---|
5 | use warnings;
|
---|
6 | use DBI;
|
---|
7 |
|
---|
8 | use URIdb;
|
---|
9 |
|
---|
10 | my $uridb = new URIdb;
|
---|
11 |
|
---|
12 | # default DB info - all other settings should be loaded from the DB.
|
---|
13 | my $dbhost = "localhost";
|
---|
14 | my $dbname = "uridb";
|
---|
15 | my $dbuser = "uridb";
|
---|
16 | my $dbpass = "spambgone";
|
---|
17 |
|
---|
18 | warn "Need DNS data type argument\n" if !$ARGV[0];
|
---|
19 | my $mode = shift @ARGV || 'rbldnsd';
|
---|
20 |
|
---|
21 | # Load a config ref containing DB host, name, user, and pass info based on
|
---|
22 | # from the server name + full script web path. This allows us to host
|
---|
23 | # multiple instances without having to duplicate the code.
|
---|
24 | # This file is a Perl fragment to be processed inline.
|
---|
25 | if (-e "/etc/uridb/uridb.conf") {
|
---|
26 | my $cfg = `cat /etc/uridb/uridb.conf`;
|
---|
27 | ($cfg) = ($cfg =~ /^(.+)$/s); # avoid warnings, failures, and general nastiness with taint mode
|
---|
28 | eval $cfg;
|
---|
29 | }
|
---|
30 |
|
---|
31 | my $dbh = $uridb->connect($dbhost, $dbname, $dbuser, $dbpass);
|
---|
32 |
|
---|
33 | my %config;
|
---|
34 | my $sth = $dbh->prepare("SELECT key,value FROM misc");
|
---|
35 | $sth->execute;
|
---|
36 | while (my ($key,$value) = $sth->fetchrow_array) {
|
---|
37 | $config{$key} = $value;
|
---|
38 | }
|
---|
39 |
|
---|
40 | print "\$SOA 900 ".($config{blzone} ? $config{blzone} : 'uri').".dnsbl systems.company.com 0 1200 600 600 900\n".
|
---|
41 | "\$NS 3600 127.0.0.1\n".
|
---|
42 | "\$TTL 900\n";
|
---|
43 |
|
---|
44 | $uridb->export($mode,*STDOUT);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.