diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2014-03-13 02:00:31 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2014-03-13 02:00:31 +0000 |
commit | 1342178419a992679fb622184c3449e6053d979d (patch) | |
tree | b8975c10c366883880fc36098db88ca9c6fea345 /usr.sbin/nsd | |
parent | 44a24f3f6cd28feba938df41de9b014eb4364fee (diff) |
update to NSD 4.0.2, ok sthen@
Diffstat (limited to 'usr.sbin/nsd')
-rw-r--r-- | usr.sbin/nsd/LICENSE | 20 | ||||
-rw-r--r-- | usr.sbin/nsd/dbaccess.c | 23 | ||||
-rw-r--r-- | usr.sbin/nsd/dbcreate.c | 4 | ||||
-rw-r--r-- | usr.sbin/nsd/difffile.c | 13 | ||||
-rw-r--r-- | usr.sbin/nsd/lookup3.h | 20 | ||||
-rw-r--r-- | usr.sbin/nsd/mini_event.c | 20 | ||||
-rw-r--r-- | usr.sbin/nsd/mini_event.h | 20 | ||||
-rw-r--r-- | usr.sbin/nsd/namedb.c | 11 | ||||
-rw-r--r-- | usr.sbin/nsd/namedb.h | 7 | ||||
-rwxr-xr-x | usr.sbin/nsd/nsd-control-setup.sh.in | 20 | ||||
-rw-r--r-- | usr.sbin/nsd/nsd-control.8.in | 8 | ||||
-rw-r--r-- | usr.sbin/nsd/nsd-control.c | 20 | ||||
-rw-r--r-- | usr.sbin/nsd/radtree.c | 2 | ||||
-rw-r--r-- | usr.sbin/nsd/remote.c | 30 | ||||
-rw-r--r-- | usr.sbin/nsd/remote.h | 20 | ||||
-rw-r--r-- | usr.sbin/nsd/udb.c | 10 | ||||
-rw-r--r-- | usr.sbin/nsd/udbzone.c | 47 | ||||
-rw-r--r-- | usr.sbin/nsd/udbzone.h | 12 | ||||
-rw-r--r-- | usr.sbin/nsd/xfrd-notify.h | 10 | ||||
-rw-r--r-- | usr.sbin/nsd/xfrd.h | 10 |
20 files changed, 222 insertions, 105 deletions
diff --git a/usr.sbin/nsd/LICENSE b/usr.sbin/nsd/LICENSE index 55faacfc49b..9c8e0233199 100644 --- a/usr.sbin/nsd/LICENSE +++ b/usr.sbin/nsd/LICENSE @@ -18,13 +18,13 @@ be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/usr.sbin/nsd/dbaccess.c b/usr.sbin/nsd/dbaccess.c index 8c215c9c578..70366b058e9 100644 --- a/usr.sbin/nsd/dbaccess.c +++ b/usr.sbin/nsd/dbaccess.c @@ -492,8 +492,25 @@ namedb_read_zonefile(struct nsd* nsd, struct zone* zone, udb_base* taskudb, if(taskudb) task_new_soainfo(taskudb, last_task, zone, 0); return; } else { - /* check the mtime */ - if(udb_zone_get_mtime(nsd->db->udb, dname_name(domain_dname( + const char* zone_fname = udb_zone_get_file_str(nsd->db->udb, + dname_name(domain_dname(zone->apex)), domain_dname( + zone->apex)->name_size); + /* if no zone_fname, then it was acquired in zone transfer, + * see if the file is newer than the zone transfer + * (regardless if this is a different file), because the + * zone transfer is a different content source too */ + if(!zone_fname && udb_zone_get_mtime(nsd->db->udb, + dname_name(domain_dname(zone->apex)), domain_dname( + zone->apex)->name_size) >= (uint64_t)mtime) { + VERBOSITY(3, (LOG_INFO, "zonefile %s is older than " + "zone transfer in memory", fname)); + return; + + /* if zone_fname, then the file was acquired from reading it, + * and see if filename changed or mtime newer to read it */ + } else if(zone_fname && fname && + strcmp(zone_fname, fname) == 0 && + udb_zone_get_mtime(nsd->db->udb, dname_name(domain_dname( zone->apex)), domain_dname(zone->apex)->name_size) >= (uint64_t)mtime) { VERBOSITY(3, (LOG_INFO, "zonefile %s is not modified", @@ -549,7 +566,7 @@ namedb_read_zonefile(struct nsd* nsd, struct zone* zone, udb_base* taskudb, zone->is_ok = 1; zone->is_changed = 0; /* store zone into udb */ - if(!write_zone_to_udb(nsd->db->udb, zone, mtime)) { + if(!write_zone_to_udb(nsd->db->udb, zone, mtime, fname)) { log_msg(LOG_ERR, "failed to store zone in db"); } else { VERBOSITY(2, (LOG_INFO, "zone %s written to db", diff --git a/usr.sbin/nsd/dbcreate.c b/usr.sbin/nsd/dbcreate.c index b764c7352cb..92f3976e4bc 100644 --- a/usr.sbin/nsd/dbcreate.c +++ b/usr.sbin/nsd/dbcreate.c @@ -146,7 +146,8 @@ write_zone(udb_base* udb, udb_ptr* z, zone_type* zone) /** create and write a zone */ int -write_zone_to_udb(udb_base* udb, zone_type* zone, time_t mtime) +write_zone_to_udb(udb_base* udb, zone_type* zone, time_t mtime, + const char* file_str) { udb_ptr z; /* make udb dirty */ @@ -167,6 +168,7 @@ write_zone_to_udb(udb_base* udb, zone_type* zone, time_t mtime) ZONE(&z)->mtime = (uint64_t)mtime; ZONE(&z)->is_changed = 0; udb_zone_set_log_str(udb, &z, NULL); + udb_zone_set_file_str(udb, &z, file_str); /* write zone */ if(!write_zone(udb, &z, zone)) { udb_base_set_userflags(udb, 0); diff --git a/usr.sbin/nsd/difffile.c b/usr.sbin/nsd/difffile.c index 08f213c22c7..5b9bd789845 100644 --- a/usr.sbin/nsd/difffile.c +++ b/usr.sbin/nsd/difffile.c @@ -300,8 +300,14 @@ static int rdatas_equal(rdata_atom_type *a, rdata_atom_type *b, int num, uint16_t type, int* rdnum, char** reason) { - int k; - for(k = 0; k < num; k++) + int k, start, end; + start = 0; + end = num; + if (type == TYPE_SOA) { + start = 2; + end = 2; + } + for(k = start; k < end; k++) { if(rdata_atom_is_domain(type, k)) { if(dname_compare(domain_dname(a[k].domain), @@ -1185,7 +1191,7 @@ check_for_bad_serial(namedb_type* db, const char* zone_str, uint32_t old_serial) zone_type* zone = 0; domain = domain_table_find(db->domains, zone_name); if(domain) - zone = domain_find_zone(domain); + zone = domain_find_zone(db, domain); if(zone && zone->apex == domain && zone->soa_rrset && old_serial) { uint32_t memserial; @@ -1321,6 +1327,7 @@ apply_ixfr_for_zone(nsd_type* nsd, zone_type* zonedb, FILE* in, ZONE(&z)->is_changed = 1; ZONE(&z)->mtime = time_end_0; udb_zone_set_log_str(nsd->db->udb, &z, log_buf); + udb_zone_set_file_str(nsd->db->udb, &z, NULL); udb_ptr_unlink(&z, nsd->db->udb); if(softfail && taskudb && !is_axfr) { log_msg(LOG_ERR, "Failed to apply IXFR cleanly " diff --git a/usr.sbin/nsd/lookup3.h b/usr.sbin/nsd/lookup3.h index 06211fdde22..59dad7c48b5 100644 --- a/usr.sbin/nsd/lookup3.h +++ b/usr.sbin/nsd/lookup3.h @@ -21,16 +21,16 @@ * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** diff --git a/usr.sbin/nsd/mini_event.c b/usr.sbin/nsd/mini_event.c index 4048bcfae89..c96dbbb1cef 100644 --- a/usr.sbin/nsd/mini_event.c +++ b/usr.sbin/nsd/mini_event.c @@ -21,16 +21,16 @@ * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ diff --git a/usr.sbin/nsd/mini_event.h b/usr.sbin/nsd/mini_event.h index b40983b6479..1b4a2f2dd3e 100644 --- a/usr.sbin/nsd/mini_event.h +++ b/usr.sbin/nsd/mini_event.h @@ -21,16 +21,16 @@ * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** diff --git a/usr.sbin/nsd/namedb.c b/usr.sbin/nsd/namedb.c index 5ffb6ff10dd..4fb23671550 100644 --- a/usr.sbin/nsd/namedb.c +++ b/usr.sbin/nsd/namedb.c @@ -508,14 +508,17 @@ domain_find_any_rrset(domain_type* domain, zone_type* zone) } zone_type * -domain_find_zone(domain_type* domain) +domain_find_zone(namedb_type* db, domain_type* domain) { rrset_type* rrset; while (domain) { - for (rrset = domain->rrsets; rrset; rrset = rrset->next) { - if (rrset_rrtype(rrset) == TYPE_SOA) { - return rrset->zone; + if(domain->is_apex) { + for (rrset = domain->rrsets; rrset; rrset = rrset->next) { + if (rrset_rrtype(rrset) == TYPE_SOA) { + return rrset->zone; + } } + return namedb_find_zone(db, domain_dname(domain)); } domain = domain->parent; } diff --git a/usr.sbin/nsd/namedb.h b/usr.sbin/nsd/namedb.h index 1c41e5e4991..34de36be6fb 100644 --- a/usr.sbin/nsd/namedb.h +++ b/usr.sbin/nsd/namedb.h @@ -32,6 +32,7 @@ typedef struct rr rr_type; typedef struct domain_table domain_table_type; typedef struct domain domain_type; typedef struct zone zone_type; +typedef struct namedb namedb_type; struct domain_table { @@ -236,7 +237,7 @@ void domain_add_rrset(domain_type* domain, rrset_type* rrset); rrset_type* domain_find_rrset(domain_type* domain, zone_type* zone, uint16_t type); rrset_type* domain_find_any_rrset(domain_type* domain, zone_type* zone); -zone_type* domain_find_zone(domain_type* domain); +zone_type* domain_find_zone(namedb_type* db, domain_type* domain); zone_type* domain_find_parent_zone(zone_type* zone); domain_type* domain_find_ns_rrsets(domain_type* domain, zone_type* zone, rrset_type **ns); @@ -281,7 +282,6 @@ static inline const char* domain_to_string(domain_type* domain) */ uint16_t rr_rrsig_type_covered(rr_type* rr); -typedef struct namedb namedb_type; struct namedb { region_type* region; @@ -331,7 +331,8 @@ void domain_table_deldomain(namedb_type* db, domain_type* domain); /** dbcreate.c */ int udb_write_rr(struct udb_base* udb, struct udb_ptr* z, rr_type* rr); void udb_del_rr(struct udb_base* udb, struct udb_ptr* z, rr_type* rr); -int write_zone_to_udb(struct udb_base* udb, zone_type* zone, time_t mtime); +int write_zone_to_udb(struct udb_base* udb, zone_type* zone, time_t mtime, + const char* file_str); /** marshal rdata into buffer, must be MAX_RDLENGTH in size */ size_t rr_marshal_rdata(rr_type* rr, uint8_t* rdata, size_t sz); /* dbaccess.c */ diff --git a/usr.sbin/nsd/nsd-control-setup.sh.in b/usr.sbin/nsd/nsd-control-setup.sh.in index 394afb40c41..a774717a740 100755 --- a/usr.sbin/nsd/nsd-control-setup.sh.in +++ b/usr.sbin/nsd/nsd-control-setup.sh.in @@ -22,16 +22,16 @@ # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # settings: diff --git a/usr.sbin/nsd/nsd-control.8.in b/usr.sbin/nsd/nsd-control.8.in index b9a32c36a07..6e176e1665c 100644 --- a/usr.sbin/nsd/nsd-control.8.in +++ b/usr.sbin/nsd/nsd-control.8.in @@ -1,4 +1,4 @@ -.TH "nsd\-control" "8" "Jan 27, 2014" "NLnet Labs" "nsd 4.0.1" +.TH "nsd\-control" "8" "Mar 12, 2014" "NLnet Labs" "nsd 4.0.2" .\" Copyright (c) 2011, NLnet Labs. All rights reserved. .\" See LICENSE for the license. .SH "NAME" @@ -121,6 +121,12 @@ increases, use the 'transfer' command. Print state of the zone, the serial numbers and since when they have been acquired. Also prints the notify action (to which server), and zone transfer (and from which master) if there is activity right now. +The state of the zone is printed as: 'master' (master zones), 'ok' (slave +zone is up\-to\-date), 'expired' (slave zone has expired), 'refreshing' (slave +zone has transfers active). The serial numbers printed are +the 'served\-serial' (currently active), the 'commit\-serial' (is in reload), +the 'notified\-serial' (got notify, busy fetching the data). The serial +numbers are only printed if such a serial number is available. .TP .B serverpid Prints the PID of the server process. This is used for statistics (and diff --git a/usr.sbin/nsd/nsd-control.c b/usr.sbin/nsd/nsd-control.c index e9551851f17..4a9abbc69ca 100644 --- a/usr.sbin/nsd/nsd-control.c +++ b/usr.sbin/nsd/nsd-control.c @@ -21,16 +21,16 @@ * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** diff --git a/usr.sbin/nsd/radtree.c b/usr.sbin/nsd/radtree.c index 11bfb4fcd30..014d23908aa 100644 --- a/usr.sbin/nsd/radtree.c +++ b/usr.sbin/nsd/radtree.c @@ -444,7 +444,7 @@ radsel_split(struct region* region, struct radsel* r, uint8_t* k, /* create the shared prefix to go in r */ if(common_len > 0) { common_str = (uint8_t*)region_alloc(region, - common_len*sizeof(uint8_t*)); + common_len*sizeof(uint8_t)); if(!common_str) { region_recycle(region, com, sizeof(*com)); region_recycle(region, s1_str, s1_len); diff --git a/usr.sbin/nsd/remote.c b/usr.sbin/nsd/remote.c index 2eb9abd86bb..4b3659878f9 100644 --- a/usr.sbin/nsd/remote.c +++ b/usr.sbin/nsd/remote.c @@ -21,16 +21,16 @@ * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** @@ -59,9 +59,15 @@ #include <assert.h> #include <fcntl.h> #ifndef USE_MINI_EVENT -#include <event.h> +# ifdef HAVE_EVENT_H +# include <event.h> +# else +# include <event2/event.h> +# include "event2/event_struct.h" +# include "event2/event_compat.h" +# endif #else -#include "mini_event.h" +# include "mini_event.h" #endif #include "remote.h" #include "util.h" diff --git a/usr.sbin/nsd/remote.h b/usr.sbin/nsd/remote.h index 4317e1fec65..d3f8b7c35fb 100644 --- a/usr.sbin/nsd/remote.h +++ b/usr.sbin/nsd/remote.h @@ -21,16 +21,16 @@ * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** diff --git a/usr.sbin/nsd/udb.c b/usr.sbin/nsd/udb.c index 6c0ffe7d0c0..02c81973942 100644 --- a/usr.sbin/nsd/udb.c +++ b/usr.sbin/nsd/udb.c @@ -134,12 +134,17 @@ udb_base_create_fd(const char* fname, int fd, udb_walk_relptr_func walkfunc, if(g.hsize > UDB_HEADER_SIZE) { log_msg(LOG_WARNING, "%s: header size too large %d", fname, (int)g.hsize); - log_msg(LOG_WARNING, "attempting to continue..."); + goto fail; } if(g.clean_close != 0) { log_msg(LOG_WARNING, "%s: not cleanly closed %d", fname, (int)g.clean_close); - log_msg(LOG_WARNING, "attempting to continue..."); + goto fail; + } + if(g.dirty_alloc != 0) { + log_msg(LOG_WARNING, "%s: not cleanly closed (alloc:%d)", fname, + (int)g.dirty_alloc); + goto fail; } /* TODO check if too large (>4g on 32bit); mmap-usage would fail */ @@ -169,6 +174,7 @@ udb_base_create_fd(const char* fname, int fd, udb_walk_relptr_func walkfunc, /* init completion */ udb->glob_data = (udb_glob_d*)(udb->base+sizeof(uint64_t)); r = 0; + /* cannot be dirty because that is goto fail above */ if(udb->glob_data->dirty_alloc != udb_dirty_clean) r = 1; udb->alloc = udb_alloc_create(udb, (udb_alloc_d*)( diff --git a/usr.sbin/nsd/udbzone.c b/usr.sbin/nsd/udbzone.c index bd5929b3929..67de2db94d1 100644 --- a/usr.sbin/nsd/udbzone.c +++ b/usr.sbin/nsd/udbzone.c @@ -22,6 +22,7 @@ udb_zone_delete_plain(udb_base* udb, udb_ptr* zone) udb_rptr_zero(&ZONE(zone)->node, udb); udb_rptr_zero(&ZONE(zone)->nsec3param, udb); udb_rptr_zero(&ZONE(zone)->log_str, udb); + udb_rptr_zero(&ZONE(zone)->file_str, udb); udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); udb_rptr_zero(&ZONE(zone)->domains, udb); udb_radix_tree_delete(udb, &dtree); @@ -89,6 +90,7 @@ udb_zone_create(udb_base* udb, udb_ptr* result, const uint8_t* dname, udb_rel_ptr_init(&ZONE(&z)->domains); udb_rel_ptr_init(&ZONE(&z)->nsec3param); udb_rel_ptr_init(&ZONE(&z)->log_str); + udb_rel_ptr_init(&ZONE(&z)->file_str); ZONE(&z)->rrset_count = 0; ZONE(&z)->rr_count = 0; ZONE(&z)->expired = 0; @@ -205,6 +207,7 @@ udb_zone_clear(udb_base* udb, udb_ptr* zone) udb_ptr_new(&dtree, udb, &ZONE(zone)->domains); udb_rptr_zero(&ZONE(zone)->nsec3param, udb); udb_zone_set_log_str(udb, zone, NULL); + udb_zone_set_file_str(udb, zone, NULL); /* walk and delete all domains, rrsets, rrs, but keep tree */ for(udb_radix_first(udb, &dtree, &d); d.data; udb_radix_next(udb, &d)){ @@ -288,6 +291,49 @@ void udb_zone_set_log_str(udb_base* udb, udb_ptr* zone, const char* str) } } +void udb_zone_set_file_str(udb_base* udb, udb_ptr* zone, const char* str) +{ + /* delete original file str (if any) */ + if(ZONE(zone)->file_str.data) { + udb_ptr s; + size_t sz; + udb_ptr_new(&s, udb, &ZONE(zone)->file_str); + udb_rptr_zero(&ZONE(zone)->file_str, udb); + sz = strlen((char*)udb_ptr_data(&s))+1; + udb_ptr_free_space(&s, udb, sz); + } + + /* set new file str */ + if(str) { + udb_ptr s; + size_t sz = strlen(str)+1; + if(!udb_ptr_alloc_space(&s, udb, udb_chunk_type_data, sz)) { + return; /* failed to allocate file string */ + } + memmove(udb_ptr_data(&s), str, sz); + udb_rptr_set_ptr(&ZONE(zone)->file_str, udb, &s); + udb_ptr_unlink(&s, udb); + } +} + +const char* udb_zone_get_file_str(udb_base* udb, const uint8_t* dname, + size_t dlen) +{ + udb_ptr z; + if(udb_zone_search(udb, &z, dname, dlen)) { + const char* str; + if(ZONE(&z)->file_str.data) { + udb_ptr s; + udb_ptr_new(&s, udb, &ZONE(&z)->file_str); + str = (const char*)udb_ptr_data(&s); + udb_ptr_unlink(&s, udb); + } else str = NULL; + udb_ptr_unlink(&z, udb); + return str; + } + return NULL; +} + #ifdef NSEC3 /** select the nsec3param for nsec3 usage */ static void @@ -706,6 +752,7 @@ udb_zone_walk_chunk(void* base, void* d, uint64_t s, udb_walk_relptr_cb* cb, (*cb)(base, &p->domains, arg); (*cb)(base, &p->nsec3param, arg); (*cb)(base, &p->log_str, arg); + (*cb)(base, &p->file_str, arg); } void diff --git a/usr.sbin/nsd/udbzone.h b/usr.sbin/nsd/udbzone.h index f1163e4dfe5..eb81675a18b 100644 --- a/usr.sbin/nsd/udbzone.h +++ b/usr.sbin/nsd/udbzone.h @@ -15,7 +15,10 @@ * | * v * zonetree -> zone -- zone_name - * radtree | + * radtree |--> nsec3param + * |--> log_str + * |--> file_str + * | * v * domain --> rrset -> rr * radtree list list @@ -32,6 +35,8 @@ struct zone_d { udb_rel_ptr nsec3param; /** the log_str for the AXFR change, or 0 */ udb_rel_ptr log_str; + /** the file name when read from a file, or 0 */ + udb_rel_ptr file_str; /** modification time, time when the zone data was changed */ uint64_t mtime; /** number of RRsets in the zone */ @@ -105,6 +110,11 @@ int udb_zone_search(udb_base* udb, udb_ptr* result, const uint8_t* dname, uint64_t udb_zone_get_mtime(udb_base* udb, const uint8_t* dname, size_t dlen); /** set log str in udb, or remove it */ void udb_zone_set_log_str(udb_base* udb, udb_ptr* zone, const char* str); +/** set file str in udb, or remove it */ +void udb_zone_set_file_str(udb_base* udb, udb_ptr* zone, const char* str); +/** get file string for zone or NULL */ +const char* udb_zone_get_file_str(udb_base* udb, const uint8_t* dname, + size_t dlen); /** find a domain name in the zone domain tree */ int udb_domain_find(udb_base* udb, udb_ptr* zone, const uint8_t* nm, size_t nmlen, udb_ptr* result); diff --git a/usr.sbin/nsd/xfrd-notify.h b/usr.sbin/nsd/xfrd-notify.h index 4f084d302e7..a4b7e088dbd 100644 --- a/usr.sbin/nsd/xfrd-notify.h +++ b/usr.sbin/nsd/xfrd-notify.h @@ -11,9 +11,15 @@ #define XFRD_NOTIFY_H #ifndef USE_MINI_EVENT -#include <event.h> +# ifdef HAVE_EVENT_H +# include <event.h> +# else +# include <event2/event.h> +# include "event2/event_struct.h" +# include "event2/event_compat.h" +# endif #else -#include "mini_event.h" +# include "mini_event.h" #endif #include "tsig.h" #include "rbtree.h" diff --git a/usr.sbin/nsd/xfrd.h b/usr.sbin/nsd/xfrd.h index b71f8c54f5e..83cb93fa51b 100644 --- a/usr.sbin/nsd/xfrd.h +++ b/usr.sbin/nsd/xfrd.h @@ -11,9 +11,15 @@ #define XFRD_H #ifndef USE_MINI_EVENT -#include <event.h> +# ifdef HAVE_EVENT_H +# include <event.h> +# else +# include <event2/event.h> +# include "event2/event_struct.h" +# include "event2/event_compat.h" +# endif #else -#include "mini_event.h" +# include "mini_event.h" #endif #include "rbtree.h" #include "namedb.h" |