diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2015-04-01 18:17:47 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2015-04-01 20:41:42 +0300 |
commit | 74828acdf2dcce9e66318a2852ec4473364c7458 (patch) | |
tree | dd2fc8bdc8eb7536f5e4315f4ff9f0772942e6ca | |
parent | a51ba4fa1a4d3e2e868e1028c85145e302a1462d (diff) | |
download | dnstools-74828acdf2dcce9e66318a2852ec4473364c7458.tar.gz dnstools-74828acdf2dcce9e66318a2852ec4473364c7458.tar.bz2 |
Bigfixes
* nsdbimport/nsdbimport: Improve docs.
* whoseip/Whoseip/DB.pm: Docs formatting fix.
-rwxr-xr-x | nsdbimport/nsdbimport | 293 | ||||
-rw-r--r-- | whoseip/Whoseip/DB.pm | 1 |
2 files changed, 264 insertions, 30 deletions
diff --git a/nsdbimport/nsdbimport b/nsdbimport/nsdbimport index e2969c8..dc93c6d 100755 --- a/nsdbimport/nsdbimport +++ b/nsdbimport/nsdbimport | |||
@@ -1,5 +1,5 @@ | |||
1 | #! /usr/bin/perl | 1 | #! /usr/bin/perl |
2 | # Copyright (C) 2014 Sergey Poznyakoff <gray@gnu.org> | 2 | # Copyright (C) 2015 Sergey Poznyakoff <gray@gnu.org> |
3 | # | 3 | # |
4 | # This program is free software; you can redistribute it and/or modify | 4 | # This program is free software; you can redistribute it and/or modify |
5 | # it under the terms of the GNU General Public License as published by | 5 | # it under the terms of the GNU General Public License as published by |
@@ -138,10 +138,10 @@ my @rrtypes = ('A', 'AAAA', 'A6', 'AFSDB', | |||
138 | 'CNAME', 'DNAME', 'DNSKEY', 'DS', | 138 | 'CNAME', 'DNAME', 'DNSKEY', 'DS', |
139 | 'EUI48', 'EUI64', 'HINFO', 'ISDN', | 139 | 'EUI48', 'EUI64', 'HINFO', 'ISDN', |
140 | 'KEY', 'LOC', 'MX', 'NAPTR', | 140 | 'KEY', 'LOC', 'MX', 'NAPTR', |
141 | 'NS', 'NSEC', 'NXT', 'NXT', | 141 | 'NS', 'NSEC', 'NXT', 'PTR', |
142 | 'PTR', 'RP', 'RRSIG', 'RT', | 142 | 'RP', 'RRSIG', 'RT', 'SIG', |
143 | 'SIG', 'SOA', 'SPF', 'SRV', | 143 | 'SOA', 'SPF', 'SRV', 'TXT', |
144 | 'TXT', 'WKS', 'X25'); | 144 | 'WKS', 'X25'); |
145 | my $rx_rr = array_to_regexp(@rrtypes); | 145 | my $rx_rr = array_to_regexp(@rrtypes); |
146 | 146 | ||
147 | # ################### | 147 | # ################### |
@@ -397,7 +397,7 @@ sub zimport { | |||
397 | 397 | ||
398 | # ################### | 398 | # ################### |
399 | my $conffile; | 399 | my $conffile; |
400 | my $origin; | 400 | my $origin = '.'; |
401 | 401 | ||
402 | GetOptions("h" => sub { | 402 | GetOptions("h" => sub { |
403 | pod2usage(-message => "$progname: $progdescr", | 403 | pod2usage(-message => "$progname: $progdescr", |
@@ -422,10 +422,10 @@ unless (defined($conffile)) { | |||
422 | ($conffile) = grep { -e $_ } ( | 422 | ($conffile) = grep { -e $_ } ( |
423 | '.nsdbimport.conf', | 423 | '.nsdbimport.conf', |
424 | "$ENV{HOME}/.nsdbimport.conf", | 424 | "$ENV{HOME}/.nsdbimport.conf", |
425 | '/etc/.nsdbimport.conf'); | 425 | '/etc/nsdbimport.conf'); |
426 | } | 426 | } |
427 | 427 | ||
428 | abend(EX_USAGE, "no configuration file; please use the --config option") | 428 | abend(EX_OSFILE, "no configuration file; please use the --config option") |
429 | unless defined $conffile; | 429 | unless defined $conffile; |
430 | 430 | ||
431 | my %kw = ('database' => 1, | 431 | my %kw = ('database' => 1, |
@@ -509,6 +509,20 @@ B<nsdbimport> | |||
509 | 509 | ||
510 | =head1 DESCRIPTION | 510 | =head1 DESCRIPTION |
511 | 511 | ||
512 | Imports DNS records from zone files in BIND-compatible format into a SQL | ||
513 | database. The format of the database (or, more precisely, SQL statements | ||
514 | used to populate the database) is determined by configuration file. | ||
515 | |||
516 | Source files can either be listed as command line arguments, or read directly | ||
517 | from BIND configuration file, supplied by the B<--bind-config> option. In | ||
518 | former case, it is recommended to define explicit origin using the | ||
519 | B<--origin> option. | ||
520 | |||
521 | When using B<--bind-config> option, no files can be given in the command line. | ||
522 | Instead, B<nsdbimport> parses B<named> configuration file and selects B<zone> | ||
523 | statements that have type B<master>. Then it imports files listed in these | ||
524 | statements. In this case, origin is determined automatically for each file. | ||
525 | |||
512 | =head1 OPTIONS | 526 | =head1 OPTIONS |
513 | 527 | ||
514 | =over 4 | 528 | =over 4 |
@@ -526,10 +540,10 @@ file names will be searched in that directory. | |||
526 | 540 | ||
527 | Read configuration from I<FILE>. If this option is not given, B<nsdbimport> | 541 | Read configuration from I<FILE>. If this option is not given, B<nsdbimport> |
528 | tries the following files: F<.nsdbimport.conf>, F<~/.nsdbimport.conf> and | 542 | tries the following files: F<.nsdbimport.conf>, F<~/.nsdbimport.conf> and |
529 | F</etc/.nsdbimport.conf>. First of them which exists is read. See the | 543 | F</etc/nsdbimport.conf>. First of them which exists is read. See the |
530 | section B<CONFIGURATION> below for a discussion of configuration file format. | 544 | section B<CONFIGURATION> below for a discussion of configuration file format. |
531 | 545 | ||
532 | =item B<--bind-config=>, B<--from-config=>I<FILE> | 546 | =item B<--bind-config>, B<--from-config=>I<FILE> |
533 | 547 | ||
534 | Parse BIND configuration file I<FILE> and process all files corresponding | 548 | Parse BIND configuration file I<FILE> and process all files corresponding |
535 | to master zones. Note, that this option relies on B<cfpeek>(1) being | 549 | to master zones. Note, that this option relies on B<cfpeek>(1) being |
@@ -570,17 +584,18 @@ Configuration file supplies credentials for accessing the database and | |||
570 | templates for the SQL queries (normally, B<INSERT> statements) to be | 584 | templates for the SQL queries (normally, B<INSERT> statements) to be |
571 | used in order to import records of particular B<RR> types. | 585 | used in order to import records of particular B<RR> types. |
572 | 586 | ||
573 | Upon startupe B<nsdbimport> looks for the following files (in that order): | 587 | If the command line option B<--config> (B<-c>) is given, B<nsdbimport> |
574 | F<.nsdbimport.conf>, F<~/.nsdbimport.conf>, or F</etc/.nsdbimport.conf>. | 588 | takes its value as the name of configuration file to read. Otherwies, |
575 | First of them that exists is read and parsed as a configuration file. | 589 | it tries to read file F<.nsdbimport.conf> from the current working |
576 | 590 | directory. If it does not exist, the program looks it up in the home | |
577 | If the command line option B<--config> (B<-c>) is given, its value is | 591 | directory of the user. If that file doesn't exist either, |
578 | taken as the name of the configuration file to read. In that case, | 592 | F</etc/nsdbimport.conf> is read. If none of these files exists, |
579 | default configuration files are not scanned. | 593 | B<nsdbimport> terminates with error code . |
580 | 594 | ||
581 | Configuration consists of I<keyword>=I<value> pairs. Any amount of white | 595 | The configuration file consists of statements -- pairs I<keyword>=I<value>, |
582 | space is allowed on either side of the equals sign. Each pair occupies | 596 | occupying a single logical line. Within a statement, any amount of white |
583 | a single logical line. To split very long lines, the usual backslash | 597 | space is allowed before I<keyword>, after I<value> and on either side of |
598 | the equals sign. To split very long lines, the usual backslash | ||
584 | escaping is used: any line ending with a backslash immediately followed | 599 | escaping is used: any line ending with a backslash immediately followed |
585 | by a newline indicates continuation on the next line. The newline character | 600 | by a newline indicates continuation on the next line. The newline character |
586 | is stripped off and the contents of the next line is appended in its place. | 601 | is stripped off and the contents of the next line is appended in its place. |
@@ -589,13 +604,13 @@ Comments begin with B<#> character and extend to the end of physical line. | |||
589 | 604 | ||
590 | Empty lines are ignored. | 605 | Empty lines are ignored. |
591 | 606 | ||
592 | The following statements configure database credentials | 607 | The following statements configure database credentials: |
593 | 608 | ||
594 | =over 4 | 609 | =over 4 |
595 | 610 | ||
596 | =item B<database=>I<STRING> | 611 | =item B<database=>I<STRING> |
597 | 612 | ||
598 | Database name. | 613 | Database name. |
599 | 614 | ||
600 | =item B<host=>I<NAME> | 615 | =item B<host=>I<NAME> |
601 | 616 | ||
@@ -603,11 +618,12 @@ Hostname or IP address of the host running the database server. | |||
603 | 618 | ||
604 | =item B<port=>I<NUM> | 619 | =item B<port=>I<NUM> |
605 | 620 | ||
606 | Port number, if differs from the default. | 621 | Port number, if it differs from the default. |
607 | 622 | ||
608 | =item B<db-params=>I<STRING> | 623 | =item B<db-params=>I<STRING> |
609 | 624 | ||
610 | Additional options. | 625 | Additional database-specific options. E.g. path to the UNIX socket file, or |
626 | the like. | ||
611 | 627 | ||
612 | =item B<user=>I<STRING> | 628 | =item B<user=>I<STRING> |
613 | 629 | ||
@@ -636,17 +652,234 @@ Enable or disable processing of B<$GENERATE> directives. Such directives | |||
636 | usually insert enormous amount of data into the database and therefore | 652 | usually insert enormous amount of data into the database and therefore |
637 | are disabled by default. Set B<generate = yes> to enable them. | 653 | are disabled by default. Set B<generate = yes> to enable them. |
638 | 654 | ||
639 | =item B<rr-query=>I<TEMPLATE> | 655 | =back |
656 | |||
657 | =head2 Query templates | ||
658 | |||
659 | SQL statements used to actually import DNS data into the database are | ||
660 | formed using I<templates>. Configuration statements that define templates | ||
661 | have the following form: | ||
662 | |||
663 | =over 4 | ||
664 | |||
665 | B<I<rrtype>-query = >I<TEMPLATE> | ||
666 | |||
667 | =back | ||
668 | |||
669 | where I<rrtype> is the B<RR> of the record converted to lower case. At the | ||
670 | time of this writing, B<nsdbimport> supports the following B<RR> types: B<A>, | ||
671 | B<AAAA>, B<A6>, B<AFSDB>, B<CNAME>, B<DNAME>, B<DNSKEY>, B<DS>, B<EUI48>, | ||
672 | B<EUI64>, B<HINFO>, B<ISDN>, B<KEY>, B<LOC>, B<MX>, B<NAPTR>, B<NS>, B<NSEC>, | ||
673 | B<NXT>, B<PTR>, B<RP>, B<RRSIG>, B<RT>, B<SIG>, B<SOA>, B<SPF>, B<SRV>, | ||
674 | B<TXT>, B<WKS>, B<X25B>. Thus, for example, the statement B<soa-query> defines | ||
675 | the query used to import B<SOA> records. | ||
676 | |||
677 | However, you don't need to define a template for each possible B<RR> type. | ||
678 | Instead you can use the I<generic query>, which is defined using the following | ||
679 | statement: | ||
680 | |||
681 | =over 4 | ||
682 | |||
683 | B<rr-query = >I<TEMPLATE> | ||
684 | |||
685 | =back | ||
686 | |||
687 | This query will be used whenever no particular query is defined for the | ||
688 | B<RR> type of a record being imported. | ||
689 | |||
690 | The I<TEMPLATE> used in B<*-query> statements must be a valid SQL statement | ||
691 | (normally, an B<INSERT>), with I<macro references> used in place of the | ||
692 | actual data. In its simplest form, a macro reference is B<${I<macro>}>, | ||
693 | where I<macro> is the name of a macro variable. Upon executing the statement, | ||
694 | macro references are replaced with the actual values of the corresponding | ||
695 | variables. The following variables are defined for all B<RR> types: | ||
696 | |||
697 | =over 4 | ||
698 | |||
699 | =item B<rr> | ||
700 | |||
701 | The B<RR> type. | ||
702 | |||
703 | =item B<origin> | ||
704 | |||
705 | Origin of the record. | ||
706 | |||
707 | =item B<label> | ||
708 | |||
709 | Label (or I<owner-user>) of the record. | ||
710 | |||