/[smeserver]/smeserver-tinydns-public/P/smeserver-tinydns-public-1.0.0-axfr-get_path.patch
ViewVC logotype

Annotation of /smeserver-tinydns-public/P/smeserver-tinydns-public-1.0.0-axfr-get_path.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Fri Sep 22 15:47:43 2006 UTC (18 years, 1 month ago) by charliebrady
Branch: MAIN
CVS Tags: HEAD
Fri Sep 22 11:47:40 2006                        Charlie Brady (bradyc)

See changelog
----------------------------------------------------------------------

1 charliebrady 1.1 diff -Nur -x '*.orig' -x '*.rej' smeserver-tinydns-public-1.0.0/root/var/service/autoaxfr/autoaxfr mezzanine_patched_smeserver-tinydns-public-1.0.0/root/var/service/autoaxfr/autoaxfr
2     --- smeserver-tinydns-public-1.0.0/root/var/service/autoaxfr/autoaxfr 2006-07-25 22:14:00.000000000 -0400
3     +++ mezzanine_patched_smeserver-tinydns-public-1.0.0/root/var/service/autoaxfr/autoaxfr 1969-12-31 19:00:00.000000000 -0500
4     @@ -1,177 +0,0 @@
5     -#!/usr/bin/perl
6     -# Copyright (c) 2000 Matt Armstrong <matt@lickey.com>
7     -# All rights reserved.
8     -#
9     -# Redistribution and use in source and binary forms, with or without
10     -# modification, are permitted provided that the following conditions
11     -# are met:
12     -# 1. Redistributions of source code must retain the above copyright
13     -# notice, this list of conditions and the following disclaimer.
14     -# 2. Redistributions in binary form must reproduce the above copyright
15     -# notice, this list of conditions and the following disclaimer in the
16     -# documentation and/or other materials provided with the distribution.
17     -#
18     -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19     -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20     -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21     -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22     -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23     -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24     -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25     -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26     -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27     -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28     -# SUCH DAMAGE.
29     -
30     -require 5.0;
31     -use English;
32     -use strict;
33     -$^W = 1;
34     -$| = 1;
35     -
36     -my $me = 'autoaxfr';
37     -
38     -die "$me: don't run as root" if ($UID == 0);
39     -
40     -my %soa_retry;
41     -my %next_try;
42     -
43     -die "$me: no ROOT environment variable" unless defined $ENV{'ROOT'};
44     -my $root = $ENV{'ROOT'};
45     -chdir($root) || die "$me: can't chdir($root): $!";
46     -
47     -# Is it time to refresh a given slave yet?
48     -sub time_to_refresh_slave {
49     - my $slave = shift;
50     - if (!defined $next_try{$slave} || $next_try{$slave} <= time()) {
51     - return 1;
52     - }
53     - return 0;
54     -}
55     -
56     -# given a file, what is the SOA serial number?
57     -sub get_serial {
58     - my $fn = shift;
59     - my $serial = 0;
60     - if (open(F, $fn)) {
61     - my $line = <F>;
62     - if (defined $line && $line =~ /^#(\d+) auto axfr-get$/) {
63     - $serial = $1;
64     - }
65     - close(F);
66     - }
67     - return $serial;
68     -}
69     -
70     -# got a zone, so read its SOA and initialize soa_retry{zone} and
71     -# next_try{zone}.
72     -sub got_zone {
73     - my $slave = shift;
74     - my $retval = 0;
75     -
76     - if (open(ZONE, "zones/$slave")) {
77     - while (<ZONE>) {
78     - chomp;
79     - if (/^Z/) {
80     - my @zone = split(/:/, $_);
81     - my $fqdn = $zone[0];
82     - $fqdn =~ s/^Z//;
83     - my $ref = $zone[4];
84     - my $ret = $zone[5];
85     - print "$me: zones/$slave, got domain $fqdn refresh $ref " .
86     - "retry $ret\n";
87     - my $slave = $fqdn eq "." ? "@" : $fqdn;
88     - $soa_retry{$slave} = $ret;
89     - $next_try{$slave} = time() + $ref;
90     - $retval = 1;
91     - }
92     - }
93     - }
94     - close(ZONE);
95     - return $retval;
96     -}
97     -
98     -# sleep until the next refresh time.
99     -sub sleep_until_next_try {
100     -
101     - my $now = time();
102     -
103     - # Sleep a max of an hour, but possibly less depending on slave
104     - # zone retry.
105     - my $refresh_time = $now + 60 * 60;
106     - foreach (keys %next_try) {
107     - if ($next_try{$_} < $refresh_time) {
108     - $refresh_time = $next_try{$_};
109     - }
110     - }
111     - my $sleep_time = $refresh_time - $now;
112     -
113     - # Never sleep less than 1 second.
114     - $sleep_time = 1 if $sleep_time <= 0;
115     -
116     - print "$me: sleeping $sleep_time\n";
117     -
118     - sleep($sleep_time);
119     -}
120     -
121     -
122     -# Possibly do an axfr for each zone in the slaves dir.
123     -sub process_requests {
124     - opendir(DIR, 'slaves') || die "$me: can't opendir $.: $!";
125     - my %slaves;
126     - foreach (readdir(DIR)) {
127     - next if /^\./;
128     - $slaves{$_} = 1;
129     - }
130     - closedir DIR;
131     -
132     - my $slave_file;
133     - foreach $slave_file (sort keys %slaves) {
134     -
135     - my $slave = $slave_file;
136     - $slave =~ s/^slave\.//;
137     -
138     - if (time_to_refresh_slave($slave)) {
139     - open(SLAVE, "slaves/$slave_file")
140     - || die "$me: can't open(slaves/$slave_file): $!";
141     - my @addrs = <SLAVE>;
142     - close(SLAVE);
143     - chomp @addrs;
144     - my $addr;
145     -
146     - # try an axfr for each ip listed in the slave file until
147     - # one works
148     - foreach $addr (@addrs) {
149     - print "$me: fetching $slave from $addr\n";
150     - my $slave_domain = $slave eq "@" ? "." : $slave;
151     - if (!system('tcpclient', '-v', $addr, 'domain', '../axfr-get',
152     - $slave_domain, "zones/$slave",
153     - "temp/$slave")) {
154     - last;
155     - }
156     - }
157     -
158     - # Get retry/refresh values from the fetched zone.
159     - if (!got_zone($slave)) {
160     - # No zone? Try again in 10 minutes.
161     - $next_try{$slave} = time() + 600;
162     - }
163     - }
164     - }
165     -
166     - # Get rid of keys in %next_try and %soa_retry that aren't in @slaves.
167     - # The admin might have deleted a slave domain.
168     - foreach (keys %next_try) {
169     - delete $next_try{$_} unless exists $slaves{$_};
170     - }
171     - foreach (keys %soa_retry) {
172     - delete $soa_retry{$_} unless exists $slaves{$_};
173     - }
174     -}
175     -
176     -while (1) {
177     - process_requests();
178     - sleep_until_next_try();
179     -}
180     -
181     -# vim: ts=8 sw=4
182     diff -Nur -x '*.orig' -x '*.rej' smeserver-tinydns-public-1.0.0/root/var/service/autoaxfr/run mezzanine_patched_smeserver-tinydns-public-1.0.0/root/var/service/autoaxfr/run
183     --- smeserver-tinydns-public-1.0.0/root/var/service/autoaxfr/run 2006-07-25 22:14:00.000000000 -0400
184     +++ mezzanine_patched_smeserver-tinydns-public-1.0.0/root/var/service/autoaxfr/run 2006-09-22 11:44:15.000000000 -0400
185     @@ -1,4 +1,5 @@
186     #!/bin/sh
187     exec 2>&1
188     ROOT=/var/service/autoaxfr/root; export ROOT
189     +PATH=$(pwd):$PATH
190     exec setuidgid autoaxfr ./autoaxfr

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed