New upstream release 1.5.5 (#1269137)
- Removed the anchor update from %post section of -libs subpackage (#1269137#c2) Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
parent
cd4af25f21
commit
63b277e028
1
.gitignore
vendored
1
.gitignore
vendored
@ -31,3 +31,4 @@ unbound-1.4.5.tar.gz
|
||||
/unbound-1.5.1.tar.gz
|
||||
/unbound-1.5.3.tar.gz
|
||||
/unbound-1.5.4.tar.gz
|
||||
/unbound-1.5.5.tar.gz
|
||||
|
@ -1,312 +0,0 @@
|
||||
From 12d6612439271b2ca5c894ab2edda5364d6c4bfa Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Hozza <thozza@redhat.com>
|
||||
Date: Mon, 15 Jun 2015 18:42:10 +0200
|
||||
Subject: [PATCH 1/2] SOA negative TTL is capped at minimumttl in its rdata
|
||||
section. - cache-max-negative-ttl config option, default 3600.
|
||||
|
||||
git-svn-id: http://unbound.nlnetlabs.nl/svn/trunk@3431 be551aaa-1e26-0410-a405-d3ace91eadb9
|
||||
Signed-off-by: Tomas Hozza <thozza@redhat.com>
|
||||
---
|
||||
doc/example.conf.in | 3 +++
|
||||
doc/unbound-control.8.in | 3 ++-
|
||||
doc/unbound.conf.5.in | 4 ++++
|
||||
testcode/unitmsgparse.c | 3 +++
|
||||
testdata/iter_domain_sale.rpl | 3 ++-
|
||||
testdata/iter_domain_sale_nschange.rpl | 6 ++++--
|
||||
util/config_file.c | 5 +++++
|
||||
util/config_file.h | 2 ++
|
||||
util/configlexer.lex | 1 +
|
||||
util/configparser.y | 12 +++++++++++-
|
||||
util/data/msgparse.h | 2 ++
|
||||
util/data/msgreply.c | 29 ++++++++++++++++++++++++++---
|
||||
12 files changed, 65 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/doc/example.conf.in b/doc/example.conf.in
|
||||
index 60ed5c8..31b965c 100644
|
||||
--- a/doc/example.conf.in
|
||||
+++ b/doc/example.conf.in
|
||||
@@ -135,6 +135,9 @@ server:
|
||||
# cache. Items are not cached for longer. In seconds.
|
||||
# cache-max-ttl: 86400
|
||||
|
||||
+ # the time to live (TTL) value cap for negative responses in the cache
|
||||
+ # cache-max-negative-ttl: 3600
|
||||
+
|
||||
# the time to live (TTL) value for cached roundtrip times, lameness and
|
||||
# EDNS version information for hosts. In seconds.
|
||||
# infra-host-ttl: 900
|
||||
diff --git a/doc/unbound-control.8.in b/doc/unbound-control.8.in
|
||||
index f6eae24..749a9fe 100644
|
||||
--- a/doc/unbound-control.8.in
|
||||
+++ b/doc/unbound-control.8.in
|
||||
@@ -177,7 +177,8 @@ harden\-glue, harden\-dnssec\-stripped, harden\-below\-nxdomain,
|
||||
harden\-referral\-path, prefetch, prefetch\-key, log\-queries,
|
||||
hide\-identity, hide\-version, identity, version, val\-log\-level,
|
||||
val\-log\-squelch, ignore\-cd\-flag, add\-holddown, del\-holddown,
|
||||
-keep\-missing, tcp\-upstream, ssl\-upstream, max\-udp\-size.
|
||||
+keep\-missing, tcp\-upstream, ssl\-upstream, max\-udp\-size,
|
||||
+cache\-max\-ttl, cache\-min\-ttl, cache\-max\-negative\-ttl.
|
||||
.TP
|
||||
.B get_option \fIopt
|
||||
Get the value of the option. Give the option name without a trailing ':'.
|
||||
diff --git a/doc/unbound.conf.5.in b/doc/unbound.conf.5.in
|
||||
index 9b088f3..5856ae7 100644
|
||||
--- a/doc/unbound.conf.5.in
|
||||
+++ b/doc/unbound.conf.5.in
|
||||
@@ -290,6 +290,10 @@ Zero makes sure the data in the cache is as the domain owner intended,
|
||||
higher values, especially more than an hour or so, can lead to trouble as
|
||||
the data in the cache does not match up with the actual data any more.
|
||||
.TP
|
||||
+.B cache\-max\-negative\-ttl: \fI<seconds>
|
||||
+Time to live maximum for negative responses, these have a SOA in the
|
||||
+authority section that is limited in time. Default is 3600.
|
||||
+.TP
|
||||
.B infra\-host\-ttl: \fI<seconds>
|
||||
Time to live for entries in the host cache. The host cache contains
|
||||
roundtrip timing, lameness and EDNS support information. Default is 900.
|
||||
diff --git a/testcode/unitmsgparse.c b/testcode/unitmsgparse.c
|
||||
index b33a240..d3d9359 100644
|
||||
--- a/testcode/unitmsgparse.c
|
||||
+++ b/testcode/unitmsgparse.c
|
||||
@@ -497,9 +497,11 @@ testfromdrillfile(sldns_buffer* pkt, struct alloc_cache* alloc,
|
||||
|
||||
void msgparse_test(void)
|
||||
{
|
||||
+ time_t origttl = MAX_NEG_TTL;
|
||||
sldns_buffer* pkt = sldns_buffer_new(65553);
|
||||
sldns_buffer* out = sldns_buffer_new(65553);
|
||||
struct alloc_cache super_a, alloc;
|
||||
+ MAX_NEG_TTL = 86400;
|
||||
/* init */
|
||||
alloc_init(&super_a, NULL, 0);
|
||||
alloc_init(&alloc, &super_a, 2);
|
||||
@@ -536,4 +538,5 @@ void msgparse_test(void)
|
||||
alloc_clear(&super_a);
|
||||
sldns_buffer_free(pkt);
|
||||
sldns_buffer_free(out);
|
||||
+ MAX_NEG_TTL = origttl;
|
||||
}
|
||||
diff --git a/testdata/iter_domain_sale.rpl b/testdata/iter_domain_sale.rpl
|
||||
index 724b51d..ff61278 100644
|
||||
--- a/testdata/iter_domain_sale.rpl
|
||||
+++ b/testdata/iter_domain_sale.rpl
|
||||
@@ -238,7 +238,8 @@ SECTION QUESTION
|
||||
nx1.example.com. IN A
|
||||
SECTION ANSWER
|
||||
SECTION AUTHORITY
|
||||
-example.com. 3600 IN SOA a. b. 1 2 3 4 5
|
||||
+; at TTL 5 because TTL is capped at min-ttl of 5 in rdata of SOA
|
||||
+example.com. 5 IN SOA a. b. 1 2 3 4 5
|
||||
example.com. 1800 IN NS ns.example.com.
|
||||
SECTION ADDITIONAL
|
||||
ns.example.com. 1800 IN A 1.2.3.4
|
||||
diff --git a/testdata/iter_domain_sale_nschange.rpl b/testdata/iter_domain_sale_nschange.rpl
|
||||
index a7d9f11..bc396f6 100644
|
||||
--- a/testdata/iter_domain_sale_nschange.rpl
|
||||
+++ b/testdata/iter_domain_sale_nschange.rpl
|
||||
@@ -285,7 +285,8 @@ SECTION QUESTION
|
||||
nx1.example.com. IN A
|
||||
SECTION ANSWER
|
||||
SECTION AUTHORITY
|
||||
-example.com. 3600 IN SOA a. b. 1 2 3 4 5
|
||||
+; at TTL 5 because TTL capped at ttl of minttl in rdata of SOA.
|
||||
+example.com. 5 IN SOA a. b. 1 2 3 4 5
|
||||
example.com. 3600 IN NS nsb.example.com.
|
||||
SECTION ADDITIONAL
|
||||
nsb.example.com. 3600 IN A 1.2.3.4
|
||||
@@ -306,7 +307,8 @@ SECTION QUESTION
|
||||
nx1.example.com. IN A
|
||||
SECTION ANSWER
|
||||
SECTION AUTHORITY
|
||||
-example.com. 3600 IN SOA a. b. 1 2 3 4 5
|
||||
+; at TTL 5 because TTL capped at ttl of minttl in rdata of SOA.
|
||||
+example.com. 5 IN SOA a. b. 1 2 3 4 5
|
||||
example.com. 1800 IN NS nsb.example.com.
|
||||
SECTION ADDITIONAL
|
||||
nsb.example.com. 3600 IN A 1.2.3.4
|
||||
diff --git a/util/config_file.c b/util/config_file.c
|
||||
index 5c4e897..ca29a02 100644
|
||||
--- a/util/config_file.c
|
||||
+++ b/util/config_file.c
|
||||
@@ -131,6 +131,7 @@ config_create(void)
|
||||
cfg->bogus_ttl = 60;
|
||||
cfg->min_ttl = 0;
|
||||
cfg->max_ttl = 3600 * 24;
|
||||
+ cfg->max_negative_ttl = 3600;
|
||||
cfg->prefetch = 0;
|
||||
cfg->prefetch_key = 0;
|
||||
cfg->infra_cache_slabs = 4;
|
||||
@@ -378,6 +379,8 @@ int config_set_option(struct config_file* cfg, const char* opt,
|
||||
else S_YNO("prefetch-key:", prefetch_key)
|
||||
else if(strcmp(opt, "cache-max-ttl:") == 0)
|
||||
{ IS_NUMBER_OR_ZERO; cfg->max_ttl = atoi(val); MAX_TTL=(time_t)cfg->max_ttl;}
|
||||
+ else if(strcmp(opt, "cache-max-negative-ttl:") == 0)
|
||||
+ { IS_NUMBER_OR_ZERO; cfg->max_negative_ttl = atoi(val); MAX_NEG_TTL=(time_t)cfg->max_negative_ttl;}
|
||||
else if(strcmp(opt, "cache-min-ttl:") == 0)
|
||||
{ IS_NUMBER_OR_ZERO; cfg->min_ttl = atoi(val); MIN_TTL=(time_t)cfg->min_ttl;}
|
||||
else if(strcmp(opt, "infra-cache-min-rtt:") == 0) {
|
||||
@@ -629,6 +632,7 @@ config_get_option(struct config_file* cfg, const char* opt,
|
||||
else O_YNO(opt, "prefetch-key", prefetch_key)
|
||||
else O_YNO(opt, "prefetch", prefetch)
|
||||
else O_DEC(opt, "cache-max-ttl", max_ttl)
|
||||
+ else O_DEC(opt, "cache-max-negative-ttl", max_negative_ttl)
|
||||
else O_DEC(opt, "cache-min-ttl", min_ttl)
|
||||
else O_DEC(opt, "infra-host-ttl", host_ttl)
|
||||
else O_DEC(opt, "infra-cache-slabs", infra_cache_slabs)
|
||||
@@ -1198,6 +1202,7 @@ config_apply(struct config_file* config)
|
||||
{
|
||||
MAX_TTL = (time_t)config->max_ttl;
|
||||
MIN_TTL = (time_t)config->min_ttl;
|
||||
+ MAX_NEG_TTL = (time_t)config->max_negative_ttl;
|
||||
RTT_MIN_TIMEOUT = config->infra_cache_min_rtt;
|
||||
EDNS_ADVERTISED_SIZE = (uint16_t)config->edns_buffer_size;
|
||||
MINIMAL_RESPONSES = config->minimal_responses;
|
||||
diff --git a/util/config_file.h b/util/config_file.h
|
||||
index ca512d7..a5cb19b 100644
|
||||
--- a/util/config_file.h
|
||||
+++ b/util/config_file.h
|
||||
@@ -185,6 +185,8 @@ struct config_file {
|
||||
int max_ttl;
|
||||
/** the number of seconds minimum TTL used for RRsets and messages */
|
||||
int min_ttl;
|
||||
+ /** the number of seconds maximal negative TTL for SOA in auth */
|
||||
+ int max_negative_ttl;
|
||||
/** if prefetching of messages should be performed. */
|
||||
int prefetch;
|
||||
/** if prefetching of DNSKEYs should be performed. */
|
||||
diff --git a/util/configlexer.lex b/util/configlexer.lex
|
||||
index dbde811..1045320 100644
|
||||
--- a/util/configlexer.lex
|
||||
+++ b/util/configlexer.lex
|
||||
@@ -239,6 +239,7 @@ msg-cache-slabs{COLON} { YDVAR(1, VAR_MSG_CACHE_SLABS) }
|
||||
rrset-cache-size{COLON} { YDVAR(1, VAR_RRSET_CACHE_SIZE) }
|
||||
rrset-cache-slabs{COLON} { YDVAR(1, VAR_RRSET_CACHE_SLABS) }
|
||||
cache-max-ttl{COLON} { YDVAR(1, VAR_CACHE_MAX_TTL) }
|
||||
+cache-max-negative-ttl{COLON} { YDVAR(1, VAR_CACHE_MAX_NEGATIVE_TTL) }
|
||||
cache-min-ttl{COLON} { YDVAR(1, VAR_CACHE_MIN_TTL) }
|
||||
infra-host-ttl{COLON} { YDVAR(1, VAR_INFRA_HOST_TTL) }
|
||||
infra-lame-ttl{COLON} { YDVAR(1, VAR_INFRA_LAME_TTL) }
|
||||
diff --git a/util/configparser.y b/util/configparser.y
|
||||
index 396ea3c..825927a 100644
|
||||
--- a/util/configparser.y
|
||||
+++ b/util/configparser.y
|
||||
@@ -118,6 +118,7 @@ extern struct config_parser_state* cfg_parser;
|
||||
%token VAR_DNSTAP_LOG_CLIENT_RESPONSE_MESSAGES
|
||||
%token VAR_DNSTAP_LOG_FORWARDER_QUERY_MESSAGES
|
||||
%token VAR_DNSTAP_LOG_FORWARDER_RESPONSE_MESSAGES
|
||||
+%token VAR_CACHE_MAX_NEGATIVE_TTL
|
||||
|
||||
%%
|
||||
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
|
||||
@@ -177,7 +178,7 @@ content_server: server_num_threads | server_verbosity | server_port |
|
||||
server_minimal_responses | server_rrset_roundrobin | server_max_udp_size |
|
||||
server_so_reuseport | server_delay_close | server_unblock_lan_zones |
|
||||
server_dns64_prefix | server_dns64_synthall |
|
||||
- server_infra_cache_min_rtt
|
||||
+ server_infra_cache_min_rtt | server_cache_max_negative_ttl
|
||||
;
|
||||
stubstart: VAR_STUB_ZONE
|
||||
{
|
||||
@@ -991,6 +992,15 @@ server_cache_max_ttl: VAR_CACHE_MAX_TTL STRING_ARG
|
||||
free($2);
|
||||
}
|
||||
;
|
||||
+server_cache_max_negative_ttl: VAR_CACHE_MAX_NEGATIVE_TTL STRING_ARG
|
||||
+ {
|
||||
+ OUTYY(("P(server_cache_max_negative_ttl:%s)\n", $2));
|
||||
+ if(atoi($2) == 0 && strcmp($2, "0") != 0)
|
||||
+ yyerror("number expected");
|
||||
+ else cfg_parser->cfg->max_negative_ttl = atoi($2);
|
||||
+ free($2);
|
||||
+ }
|
||||
+ ;
|
||||
server_cache_min_ttl: VAR_CACHE_MIN_TTL STRING_ARG
|
||||
{
|
||||
OUTYY(("P(server_cache_min_ttl:%s)\n", $2));
|
||||
diff --git a/util/data/msgparse.h b/util/data/msgparse.h
|
||||
index 221a45a..549cc2d 100644
|
||||
--- a/util/data/msgparse.h
|
||||
+++ b/util/data/msgparse.h
|
||||
@@ -76,6 +76,8 @@ struct regional;
|
||||
extern time_t MAX_TTL;
|
||||
/** Minimum TTL that is allowed. */
|
||||
extern time_t MIN_TTL;
|
||||
+/** Maximum Negative TTL that is allowed */
|
||||
+extern time_t MAX_NEG_TTL;
|
||||
/** Negative cache time (for entries without any RRs.) */
|
||||
#define NORR_TTL 5 /* seconds */
|
||||
|
||||
diff --git a/util/data/msgreply.c b/util/data/msgreply.c
|
||||
index 68bcfd0..d197ad7 100644
|
||||
--- a/util/data/msgreply.c
|
||||
+++ b/util/data/msgreply.c
|
||||
@@ -57,6 +57,8 @@
|
||||
time_t MAX_TTL = 3600 * 24 * 10; /* ten days */
|
||||
/** MIN TTL default for messages and rrsets */
|
||||
time_t MIN_TTL = 0;
|
||||
+/** MAX Negative TTL, for SOA records in authority section */
|
||||
+time_t MAX_NEG_TTL = 3600; /* one hour */
|
||||
|
||||
/** allocate qinfo, return 0 on error */
|
||||
static int
|
||||
@@ -152,10 +154,23 @@ repinfo_alloc_rrset_keys(struct reply_info* rep, struct alloc_cache* alloc,
|
||||
return 1;
|
||||
}
|
||||
|
||||
+/** find the minimumttl in the rdata of SOA record */
|
||||
+static time_t
|
||||
+soa_find_minttl(struct rr_parse* rr)
|
||||
+{
|
||||
+ uint16_t rlen = sldns_read_uint16(rr->ttl_data+4);
|
||||
+ if(rlen < 20)
|
||||
+ return 0; /* rdata too small for SOA (dname, dname, 5*32bit) */
|
||||
+ /* minimum TTL is the last 32bit value in the rdata of the record */
|
||||
+ /* at position ttl_data + 4(ttl) + 2(rdatalen) + rdatalen - 4(timeval)*/
|
||||
+ return (time_t)sldns_read_uint32(rr->ttl_data+6+rlen-4);
|
||||
+}
|
||||
+
|
||||
/** do the rdata copy */
|
||||
static int
|
||||
rdata_copy(sldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to,
|
||||
- struct rr_parse* rr, time_t* rr_ttl, uint16_t type)
|
||||
+ struct rr_parse* rr, time_t* rr_ttl, uint16_t type,
|
||||
+ sldns_pkt_section section)
|
||||
{
|
||||
uint16_t pkt_len;
|
||||
const sldns_rr_descriptor* desc;
|
||||
@@ -164,6 +179,14 @@ rdata_copy(sldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to,
|
||||
/* RFC 2181 Section 8. if msb of ttl is set treat as if zero. */
|
||||
if(*rr_ttl & 0x80000000U)
|
||||
*rr_ttl = 0;
|
||||
+ if(type == LDNS_RR_TYPE_SOA && section == LDNS_SECTION_AUTHORITY) {
|
||||
+ /* negative response. see if TTL of SOA record larger than the
|
||||
+ * minimum-ttl in the rdata of the SOA record */
|
||||
+ if(*rr_ttl > soa_find_minttl(rr))
|
||||
+ *rr_ttl = soa_find_minttl(rr);
|
||||
+ if(*rr_ttl > MAX_NEG_TTL)
|
||||
+ *rr_ttl = MAX_NEG_TTL;
|
||||
+ }
|
||||
if(*rr_ttl < MIN_TTL)
|
||||
*rr_ttl = MIN_TTL;
|
||||
if(*rr_ttl < data->ttl)
|
||||
@@ -253,7 +276,7 @@ parse_rr_copy(sldns_buffer* pkt, struct rrset_parse* pset,
|
||||
data->rr_data[i] = nextrdata;
|
||||
nextrdata += rr->size;
|
||||
if(!rdata_copy(pkt, data, data->rr_data[i], rr,
|
||||
- &data->rr_ttl[i], pset->type))
|
||||
+ &data->rr_ttl[i], pset->type, pset->section))
|
||||
return 0;
|
||||
rr = rr->next;
|
||||
}
|
||||
@@ -264,7 +287,7 @@ parse_rr_copy(sldns_buffer* pkt, struct rrset_parse* pset,
|
||||
data->rr_data[i] = nextrdata;
|
||||
nextrdata += rr->size;
|
||||
if(!rdata_copy(pkt, data, data->rr_data[i], rr,
|
||||
- &data->rr_ttl[i], LDNS_RR_TYPE_RRSIG))
|
||||
+ &data->rr_ttl[i], LDNS_RR_TYPE_RRSIG, pset->section))
|
||||
return 0;
|
||||
rr = rr->next;
|
||||
}
|
||||
--
|
||||
2.4.3
|
||||
|
@ -1,127 +0,0 @@
|
||||
From 2b3840deb32d58faa44cf4f02404b4fda51789ba Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Hozza <thozza@redhat.com>
|
||||
Date: Tue, 14 Apr 2015 12:05:15 +0200
|
||||
Subject: [PATCH 1/4] Use print_function also for Python2
|
||||
|
||||
Signed-off-by: Tomas Hozza <thozza@redhat.com>
|
||||
---
|
||||
libunbound/python/examples/async-lookup.py | 1 +
|
||||
libunbound/python/examples/dns-lookup.py | 1 +
|
||||
libunbound/python/examples/dnssec-valid.py | 1 +
|
||||
libunbound/python/examples/dnssec_test.py | 1 +
|
||||
libunbound/python/examples/example8-1.py | 1 +
|
||||
libunbound/python/examples/idn-lookup.py | 1 +
|
||||
libunbound/python/examples/mx-lookup.py | 1 +
|
||||
libunbound/python/examples/ns-lookup.py | 1 +
|
||||
libunbound/python/examples/reverse-lookup.py | 1 +
|
||||
9 files changed, 9 insertions(+)
|
||||
|
||||
diff --git a/libunbound/python/examples/async-lookup.py b/libunbound/python/examples/async-lookup.py
|
||||
index cbb8ea0..81ba447 100644
|
||||
--- a/libunbound/python/examples/async-lookup.py
|
||||
+++ b/libunbound/python/examples/async-lookup.py
|
||||
@@ -32,6 +32,7 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
+from __future__ import print_function
|
||||
import unbound
|
||||
import time
|
||||
|
||||
diff --git a/libunbound/python/examples/dns-lookup.py b/libunbound/python/examples/dns-lookup.py
|
||||
index b3f4008..ec85673 100644
|
||||
--- a/libunbound/python/examples/dns-lookup.py
|
||||
+++ b/libunbound/python/examples/dns-lookup.py
|
||||
@@ -32,6 +32,7 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
+from __future__ import print_function
|
||||
import unbound
|
||||
|
||||
ctx = unbound.ub_ctx()
|
||||
diff --git a/libunbound/python/examples/dnssec-valid.py b/libunbound/python/examples/dnssec-valid.py
|
||||
index 5c3cad9..e613fd2 100644
|
||||
--- a/libunbound/python/examples/dnssec-valid.py
|
||||
+++ b/libunbound/python/examples/dnssec-valid.py
|
||||
@@ -32,6 +32,7 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
+from __future__ import print_function
|
||||
import os
|
||||
from unbound import ub_ctx,RR_TYPE_A,RR_CLASS_IN
|
||||
|
||||
diff --git a/libunbound/python/examples/dnssec_test.py b/libunbound/python/examples/dnssec_test.py
|
||||
index 0d62b9f..a90ac0c 100644
|
||||
--- a/libunbound/python/examples/dnssec_test.py
|
||||
+++ b/libunbound/python/examples/dnssec_test.py
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
+from __future__ import print_function
|
||||
from unbound import ub_ctx, RR_TYPE_A, RR_TYPE_RRSIG, RR_TYPE_NSEC, RR_TYPE_NSEC3
|
||||
import ldns
|
||||
|
||||
diff --git a/libunbound/python/examples/example8-1.py b/libunbound/python/examples/example8-1.py
|
||||
index ca868e5..ba093d9 100644
|
||||
--- a/libunbound/python/examples/example8-1.py
|
||||
+++ b/libunbound/python/examples/example8-1.py
|
||||
@@ -33,6 +33,7 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
+from __future__ import print_function
|
||||
import unbound
|
||||
|
||||
ctx = unbound.ub_ctx()
|
||||
diff --git a/libunbound/python/examples/idn-lookup.py b/libunbound/python/examples/idn-lookup.py
|
||||
index 2170637..8cc63e0 100644
|
||||
--- a/libunbound/python/examples/idn-lookup.py
|
||||
+++ b/libunbound/python/examples/idn-lookup.py
|
||||
@@ -33,6 +33,7 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
+from __future__ import print_function
|
||||
import unbound
|
||||
import locale
|
||||
|
||||
diff --git a/libunbound/python/examples/mx-lookup.py b/libunbound/python/examples/mx-lookup.py
|
||||
index f83f690..f3c4e5f 100644
|
||||
--- a/libunbound/python/examples/mx-lookup.py
|
||||
+++ b/libunbound/python/examples/mx-lookup.py
|
||||
@@ -33,6 +33,7 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
+from __future__ import print_function
|
||||
import unbound
|
||||
|
||||
ctx = unbound.ub_ctx()
|
||||
diff --git a/libunbound/python/examples/ns-lookup.py b/libunbound/python/examples/ns-lookup.py
|
||||
index bcd51de..5acf2a3 100644
|
||||
--- a/libunbound/python/examples/ns-lookup.py
|
||||
+++ b/libunbound/python/examples/ns-lookup.py
|
||||
@@ -33,6 +33,7 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
+from __future__ import print_function
|
||||
import unbound
|
||||
|
||||
ctx = unbound.ub_ctx()
|
||||
diff --git a/libunbound/python/examples/reverse-lookup.py b/libunbound/python/examples/reverse-lookup.py
|
||||
index 7e06844..da8ab1a 100644
|
||||
--- a/libunbound/python/examples/reverse-lookup.py
|
||||
+++ b/libunbound/python/examples/reverse-lookup.py
|
||||
@@ -32,6 +32,7 @@
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
'''
|
||||
+from __future__ import print_function
|
||||
import unbound
|
||||
|
||||
ctx = unbound.ub_ctx()
|
||||
--
|
||||
2.1.0
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,183 +0,0 @@
|
||||
From 17384c3ec2eb1d11dc430765890397679699fce1 Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Hozza <thozza@redhat.com>
|
||||
Date: Tue, 14 Apr 2015 12:05:50 +0200
|
||||
Subject: [PATCH 2/4] libunbound examples: produce sorted output
|
||||
|
||||
Signed-off-by: Tomas Hozza <thozza@redhat.com>
|
||||
---
|
||||
libunbound/python/examples/async-lookup.py | 4 ++--
|
||||
libunbound/python/examples/dns-lookup.py | 2 +-
|
||||
libunbound/python/examples/dnssec-valid.py | 2 +-
|
||||
libunbound/python/examples/dnssec_test.py | 8 ++++----
|
||||
libunbound/python/examples/example8-1.py | 6 +++---
|
||||
libunbound/python/examples/idn-lookup.py | 6 +++---
|
||||
libunbound/python/examples/mx-lookup.py | 4 ++--
|
||||
libunbound/python/examples/ns-lookup.py | 2 +-
|
||||
libunbound/python/examples/reverse-lookup.py | 2 +-
|
||||
9 files changed, 18 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/libunbound/python/examples/async-lookup.py b/libunbound/python/examples/async-lookup.py
|
||||
index 81ba447..936be32 100644
|
||||
--- a/libunbound/python/examples/async-lookup.py
|
||||
+++ b/libunbound/python/examples/async-lookup.py
|
||||
@@ -40,9 +40,9 @@ ctx = unbound.ub_ctx()
|
||||
ctx.resolvconf("/etc/resolv.conf")
|
||||
|
||||
def call_back(my_data,status,result):
|
||||
- print("Call_back:", my_data)
|
||||
+ print("Call_back:", sorted(my_data))
|
||||
if status == 0 and result.havedata:
|
||||
- print("Result:", result.data.address_list)
|
||||
+ print("Result:", sorted(result.data.address_list))
|
||||
my_data['done_flag'] = True
|
||||
|
||||
|
||||
diff --git a/libunbound/python/examples/dns-lookup.py b/libunbound/python/examples/dns-lookup.py
|
||||
index ec85673..a175dfb 100644
|
||||
--- a/libunbound/python/examples/dns-lookup.py
|
||||
+++ b/libunbound/python/examples/dns-lookup.py
|
||||
@@ -40,6 +40,6 @@ ctx.resolvconf("/etc/resolv.conf")
|
||||
|
||||
status, result = ctx.resolve("www.nic.cz", unbound.RR_TYPE_A, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
- print("Result:", result.data.address_list)
|
||||
+ print("Result:", sorted(result.data.address_list))
|
||||
elif status != 0:
|
||||
print("Error:", unbound.ub_strerror(status))
|
||||
diff --git a/libunbound/python/examples/dnssec-valid.py b/libunbound/python/examples/dnssec-valid.py
|
||||
index e613fd2..386f4c2 100644
|
||||
--- a/libunbound/python/examples/dnssec-valid.py
|
||||
+++ b/libunbound/python/examples/dnssec-valid.py
|
||||
@@ -49,7 +49,7 @@ if os.path.isfile("keys"):
|
||||
status, result = ctx.resolve("www.nic.cz", RR_TYPE_A, RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
|
||||
- print("Result:", result.data.address_list)
|
||||
+ print("Result:", sorted(result.data.address_list))
|
||||
|
||||
if result.secure:
|
||||
print("Result is secure")
|
||||
diff --git a/libunbound/python/examples/dnssec_test.py b/libunbound/python/examples/dnssec_test.py
|
||||
index a90ac0c..430e51a 100644
|
||||
--- a/libunbound/python/examples/dnssec_test.py
|
||||
+++ b/libunbound/python/examples/dnssec_test.py
|
||||
@@ -13,16 +13,16 @@ def dnssecParse(domain, rrType=RR_TYPE_A):
|
||||
raise RuntimeError("Error parsing DNS packet")
|
||||
|
||||
rrsigs = pkt.rr_list_by_type(RR_TYPE_RRSIG, ldns.LDNS_SECTION_ANSWER)
|
||||
- print("RRSIGs from answer:", rrsigs)
|
||||
+ print("RRSIGs from answer:", sorted(rrsigs))
|
||||
|
||||
rrsigs = pkt.rr_list_by_type(RR_TYPE_RRSIG, ldns.LDNS_SECTION_AUTHORITY)
|
||||
- print("RRSIGs from authority:", rrsigs)
|
||||
+ print("RRSIGs from authority:", sorted(rrsigs))
|
||||
|
||||
nsecs = pkt.rr_list_by_type(RR_TYPE_NSEC, ldns.LDNS_SECTION_AUTHORITY)
|
||||
- print("NSECs:", nsecs)
|
||||
+ print("NSECs:", sorted(nsecs))
|
||||
|
||||
nsec3s = pkt.rr_list_by_type(RR_TYPE_NSEC3, ldns.LDNS_SECTION_AUTHORITY)
|
||||
- print("NSEC3s:", nsec3s)
|
||||
+ print("NSEC3s:", sorted(nsec3s))
|
||||
|
||||
print("---")
|
||||
|
||||
diff --git a/libunbound/python/examples/example8-1.py b/libunbound/python/examples/example8-1.py
|
||||
index ba093d9..723c406 100644
|
||||
--- a/libunbound/python/examples/example8-1.py
|
||||
+++ b/libunbound/python/examples/example8-1.py
|
||||
@@ -43,20 +43,20 @@ status, result = ctx.resolve("nic.cz", unbound.RR_TYPE_MX, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
print("Result:")
|
||||
print(" raw data:", result.data)
|
||||
- for k in result.data.mx_list:
|
||||
+ for k in sorted(result.data.mx_list):
|
||||
print(" priority:%d address:%s" % k)
|
||||
|
||||
status, result = ctx.resolve("nic.cz", unbound.RR_TYPE_A, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
print("Result:")
|
||||
print(" raw data:", result.data)
|
||||
- for k in result.data.address_list:
|
||||
+ for k in sorted(result.data.address_list):
|
||||
print(" address:%s" % k)
|
||||
|
||||
status, result = ctx.resolve("nic.cz", unbound.RR_TYPE_NS, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
print("Result:")
|
||||
print(" raw data:", result.data)
|
||||
- for k in result.data.domain_list:
|
||||
+ for k in sorted(result.data.domain_list):
|
||||
print(" host: %s" % k)
|
||||
|
||||
diff --git a/libunbound/python/examples/idn-lookup.py b/libunbound/python/examples/idn-lookup.py
|
||||
index 8cc63e0..f283150 100644
|
||||
--- a/libunbound/python/examples/idn-lookup.py
|
||||
+++ b/libunbound/python/examples/idn-lookup.py
|
||||
@@ -46,18 +46,18 @@ status, result = ctx.resolve(u"www.háčkyčárky.cz", unbound.RR_TYPE_A, unboun
|
||||
if status == 0 and result.havedata:
|
||||
print("Result:")
|
||||
print(" raw data:", result.data)
|
||||
- for k in result.data.address_list:
|
||||
+ for k in sorted(result.data.address_list):
|
||||
print(" address:%s" % k)
|
||||
|
||||
status, result = ctx.resolve(u"háčkyčárky.cz", unbound.RR_TYPE_MX, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
print("Result:")
|
||||
print(" raw data:", result.data)
|
||||
- for k in result.data.mx_list_idn:
|
||||
+ for k in sorted(result.data.mx_list_idn):
|
||||
print(" priority:%d address:%s" % k)
|
||||
|
||||
status, result = ctx.resolve(unbound.reverse('217.31.204.66')+'.in-addr.arpa', unbound.RR_TYPE_PTR, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
print("Result.data:", result.data)
|
||||
- for k in result.data.domain_list_idn:
|
||||
+ for k in sorted(result.data.domain_list_idn):
|
||||
print(" dname:%s" % k)
|
||||
diff --git a/libunbound/python/examples/mx-lookup.py b/libunbound/python/examples/mx-lookup.py
|
||||
index f3c4e5f..e9394b3 100644
|
||||
--- a/libunbound/python/examples/mx-lookup.py
|
||||
+++ b/libunbound/python/examples/mx-lookup.py
|
||||
@@ -43,12 +43,12 @@ status, result = ctx.resolve("nic.cz", unbound.RR_TYPE_MX, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
print("Result:")
|
||||
print(" raw data:", result.data)
|
||||
- for k in result.data.mx_list:
|
||||
+ for k in sorted(result.data.mx_list):
|
||||
print(" priority:%d address:%s" % k)
|
||||
|
||||
status, result = ctx.resolve("nic.cz", unbound.RR_TYPE_A, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
print("Result:")
|
||||
print(" raw data:", result.data)
|
||||
- for k in result.data.address_list:
|
||||
+ for k in sorted(result.data.address_list):
|
||||
print(" address:%s" % k)
|
||||
diff --git a/libunbound/python/examples/ns-lookup.py b/libunbound/python/examples/ns-lookup.py
|
||||
index 5acf2a3..49f5672 100644
|
||||
--- a/libunbound/python/examples/ns-lookup.py
|
||||
+++ b/libunbound/python/examples/ns-lookup.py
|
||||
@@ -43,6 +43,6 @@ status, result = ctx.resolve("vutbr.cz", unbound.RR_TYPE_NS, unbound.RR_CLASS_IN
|
||||
if status == 0 and result.havedata:
|
||||
print("Result:")
|
||||
print(" raw data:", result.data)
|
||||
- for k in result.data.domain_list:
|
||||
+ for k in sorted(result.data.domain_list):
|
||||
print(" host: %s" % k)
|
||||
|
||||
diff --git a/libunbound/python/examples/reverse-lookup.py b/libunbound/python/examples/reverse-lookup.py
|
||||
index da8ab1a..c9a13fe 100644
|
||||
--- a/libunbound/python/examples/reverse-lookup.py
|
||||
+++ b/libunbound/python/examples/reverse-lookup.py
|
||||
@@ -40,5 +40,5 @@ ctx.resolvconf("/etc/resolv.conf")
|
||||
|
||||
status, result = ctx.resolve(unbound.reverse("74.125.43.147") + ".in-addr.arpa.", unbound.RR_TYPE_PTR, unbound.RR_CLASS_IN)
|
||||
if status == 0 and result.havedata:
|
||||
- print("Result.data:", result.data, result.data.domain_list)
|
||||
+ print("Result.data:", result.data, sorted(result.data.domain_list))
|
||||
|
||||
--
|
||||
2.1.0
|
||||
|
@ -1,37 +0,0 @@
|
||||
From a26697b196418201e1162f04317649d64aec89b5 Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Hozza <thozza@redhat.com>
|
||||
Date: Thu, 16 Apr 2015 11:29:21 +0200
|
||||
Subject: [PATCH 3/4] libunbound-Python: libldns is not used anymore
|
||||
|
||||
Signed-off-by: Tomas Hozza <thozza@redhat.com>
|
||||
---
|
||||
libunbound/python/Makefile | 7 ++-----
|
||||
1 file changed, 2 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/libunbound/python/Makefile b/libunbound/python/Makefile
|
||||
index 86ba177..01b0577 100644
|
||||
--- a/libunbound/python/Makefile
|
||||
+++ b/libunbound/python/Makefile
|
||||
@@ -48,17 +48,14 @@ help:
|
||||
#../../.libs/libunbound.so.0: ../../Makefile
|
||||
#$(MAKE) -C ../..
|
||||
|
||||
-#../../ldns-src/lib/libldns.so: ../../ldns-src/Makefile
|
||||
- #$(MAKE) -C ../../ldns-src
|
||||
-
|
||||
clean:
|
||||
rm -rdf examples/unbound
|
||||
rm -f _unbound.so libunbound_wrap.o
|
||||
$(MAKE) -C ../.. clean
|
||||
|
||||
-testenv: ../../.libs/libunbound.so.2 ../../ldns-src/lib/libldns.so ../../.libs/_unbound.so
|
||||
+testenv: ../../.libs/libunbound.so.2 ../../.libs/_unbound.so
|
||||
rm -rdf examples/unbound
|
||||
- cd examples && mkdir unbound && ln -s ../../unbound.py unbound/__init__.py && ln -s ../../_unbound.so unbound/_unbound.so && ln -s ../../../../.libs/libunbound.so.2 unbound/libunbound.so.2 && ln -s ../../../../ldns-src/lib/libldns.so.1 unbound/libldns.so.1 && ls -la
|
||||
+ cd examples && mkdir unbound && ln -s ../../unbound.py unbound/__init__.py && ln -s ../../_unbound.so unbound/_unbound.so && ln -s ../../../../.libs/libunbound.so.2 unbound/libunbound.so.2 && ls -la
|
||||
cd examples && if test -f ../../../.libs/_unbound.so; then cp ../../../.libs/_unbound.so . ; fi
|
||||
@echo "Run a script by typing ./script_name.py"
|
||||
cd examples && LD_LIBRARY_PATH=unbound bash
|
||||
--
|
||||
2.1.0
|
||||
|
@ -1,356 +0,0 @@
|
||||
From 5fe01bc3b8932b5dffa88578663727c3df694bc4 Mon Sep 17 00:00:00 2001
|
||||
From: Tomas Hozza <thozza@redhat.com>
|
||||
Date: Tue, 14 Apr 2015 14:01:02 +0200
|
||||
Subject: [PATCH 4/4] Resolve Python 3 incompatibilities in libunbound and
|
||||
pythonmod wrappers
|
||||
|
||||
Signed-off-by: Tomas Hozza <thozza@redhat.com>
|
||||
|
||||
Fix issue with Python 3 mapping of FILE* using file_py3.i from ldns.
|
||||
---
|
||||
Makefile.in | 3 +-
|
||||
configure.ac | 2 +
|
||||
libunbound/python/file_py3.i | 155 +++++++++++++++++++++++++++++++++++++++++
|
||||
libunbound/python/libunbound.i | 4 ++
|
||||
pythonmod/interface.i | 28 ++++----
|
||||
pythonmod/pythonmod.c | 8 ++-
|
||||
6 files changed, 184 insertions(+), 16 deletions(-)
|
||||
create mode 100644 libunbound/python/file_py3.i
|
||||
|
||||
diff --git a/Makefile.in b/Makefile.in
|
||||
index 94b126d..a84b303 100644
|
||||
--- a/Makefile.in
|
||||
+++ b/Makefile.in
|
||||
@@ -25,6 +25,7 @@ DNSTAP_SRC=@DNSTAP_SRC@
|
||||
DNSTAP_OBJ=@DNSTAP_OBJ@
|
||||
WITH_PYTHONMODULE=@WITH_PYTHONMODULE@
|
||||
WITH_PYUNBOUND=@WITH_PYUNBOUND@
|
||||
+PY_MAJOR_VERSION=@PY_MAJOR_VERSION@
|
||||
PYTHON_SITE_PKG=@PYTHON_SITE_PKG@
|
||||
PYTHONMOD_INSTALL=@PYTHONMOD_INSTALL@
|
||||
PYTHONMOD_UNINSTALL=@PYTHONMOD_UNINSTALL@
|
||||
@@ -393,7 +394,7 @@ libunbound_wrap.lo libunbound_wrap.o: libunbound/python/libunbound_wrap.c \
|
||||
unbound.h
|
||||
libunbound/python/libunbound_wrap.c: $(srcdir)/libunbound/python/libunbound.i unbound.h
|
||||
@-if test ! -d libunbound/python; then $(INSTALL) -d libunbound/python; fi
|
||||
- $(SWIG) -python -o $@ $(CPPFLAGS) $(srcdir)/libunbound/python/libunbound.i
|
||||
+ $(SWIG) -python -o $@ $(CPPFLAGS) -DPY_MAJOR_VERSION=$(PY_MAJOR_VERSION) $(srcdir)/libunbound/python/libunbound.i
|
||||
|
||||
# Pyunbound python unbound wrapper
|
||||
_unbound.la: libunbound_wrap.lo libunbound.la
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index 6028138..de809af 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -475,6 +475,8 @@ if test x_$ub_test_python != x_no; then
|
||||
AC_ERROR([Python version >= 2.4.0 is required])
|
||||
fi
|
||||
|
||||
+ PY_MAJOR_VERSION="`$PYTHON -c "import sys; print(sys.version_info.major)"`"
|
||||
+ AC_SUBST(PY_MAJOR_VERSION)
|
||||
# Have Python
|
||||
AC_DEFINE(HAVE_PYTHON,1,[Define if you have Python libraries and header files.])
|
||||
LIBS="$PYTHON_LDFLAGS $LIBS"
|
||||
diff --git a/libunbound/python/file_py3.i b/libunbound/python/file_py3.i
|
||||
new file mode 100644
|
||||
index 0000000..5d8b5a2
|
||||
--- /dev/null
|
||||
+++ b/libunbound/python/file_py3.i
|
||||
@@ -0,0 +1,155 @@
|
||||
+/*
|
||||
+ * file_py3.i: Typemaps for FILE* for Python 3
|
||||
+ *
|
||||
+ * Copyright (c) 2011, Karel Slany (karel.slany AT nic.cz)
|
||||
+ * All rights reserved.
|
||||
+ *
|
||||
+ * Redistribution and use in source and binary forms, with or without
|
||||
+ * modification, are permitted provided that the following conditions are met:
|
||||
+ *
|
||||
+ * * Redistributions of source code must retain the above copyright notice,
|
||||
+ * this list of conditions and the following disclaimer.
|
||||
+ * * Redistributions in binary form must reproduce the above copyright
|
||||
+ * notice, this list of conditions and the following disclaimer in the
|
||||
+ * documentation and/or other materials provided with the distribution.
|
||||
+ * * Neither the name of the organization nor the names of its
|
||||
+ * contributors may 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 COPYRIGHT OWNER 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.
|
||||
+ */
|
||||
+
|
||||
+%{
|
||||
+#include <unistd.h>
|
||||
+#include <fcntl.h>
|
||||
+%}
|
||||
+
|
||||
+%types(FILE *);
|
||||
+
|
||||
+//#define SWIG_FILE3_DEBUG
|
||||
+
|
||||
+/* converts basic file descriptor flags onto a string */
|
||||
+%fragment("fdfl_to_str", "header") {
|
||||
+const char *
|
||||
+fdfl_to_str(int fdfl) {
|
||||
+
|
||||
+ static const char * const file_mode[] = {"w+", "w", "r"};
|
||||
+
|
||||
+ if (fdfl & O_RDWR) {
|
||||
+ return file_mode[0];
|
||||
+ } else if (fdfl & O_WRONLY) {
|
||||
+ return file_mode[1];
|
||||
+ } else {
|
||||
+ return file_mode[2];
|
||||
+ }
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+%fragment("is_obj_file", "header") {
|
||||
+int
|
||||
+is_obj_file(PyObject *obj) {
|
||||
+ int fd, fdfl;
|
||||
+ if (!PyLong_Check(obj) && /* is not an integer */
|
||||
+ PyObject_HasAttrString(obj, "fileno") && /* has fileno method */
|
||||
+ (PyObject_CallMethod(obj, "flush", NULL) != NULL) && /* flush() succeeded */
|
||||
+ ((fd = PyObject_AsFileDescriptor(obj)) != -1) && /* got file descriptor */
|
||||
+ ((fdfl = fcntl(fd, F_GETFL)) != -1) /* got descriptor flags */
|
||||
+ ) {
|
||||
+ return 1;
|
||||
+ }
|
||||
+ else {
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+%fragment("obj_to_file","header", fragment="fdfl_to_str,is_obj_file") {
|
||||
+FILE *
|
||||
+obj_to_file(PyObject *obj) {
|
||||
+ int fd, fdfl;
|
||||
+ FILE *fp;
|
||||
+ if (is_obj_file(obj)) {
|
||||
+ fd = PyObject_AsFileDescriptor(obj);
|
||||
+ fdfl = fcntl(fd, F_GETFL);
|
||||
+ fp = fdopen(dup(fd), fdfl_to_str(fdfl)); /* the FILE* must be flushed
|
||||
+ and closed after being used */
|
||||
+#ifdef SWIG_FILE3_DEBUG
|
||||
+ fprintf(stderr, "opening fd %d (fl %d \"%s\") as FILE %p\n",
|
||||
+ fd, fdfl, fdfl_to_str(fdfl), (void *)fp);
|
||||
+#endif
|
||||
+ return fp;
|
||||
+ }
|
||||
+ return NULL;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+/* returns -1 if error occurred */
|
||||
+/* caused magic SWIG Syntax errors when was commented out */
|
||||
+#if 0
|
||||
+%fragment("dispose_file", "header") {
|
||||
+int
|
||||
+dispose_file(FILE **fp) {
|
||||
+#ifdef SWIG_FILE3_DEBUG
|
||||
+ fprintf(stderr, "flushing FILE %p\n", (void *)fp);
|
||||
+#endif
|
||||
+ if (*fp == NULL) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ if ((fflush(*fp) == 0) && /* flush file */
|
||||
+ (fclose(*fp) == 0)) { /* close file */
|
||||
+ *fp = NULL;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ return -1;
|
||||
+}
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+%typemap(arginit, noblock = 1) FILE* {
|
||||
+ $1 = NULL;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * added due to ub_ctx_debugout since since it is overloaded:
|
||||
+ * takes void* and FILE*. In reality only FILE* but the wrapper
|
||||
+ * and the function is declared in such way.
|
||||
+ */
|
||||
+%typemap(typecheck, noblock = 1, fragment = "is_obj_file", precedence = SWIG_TYPECHECK_POINTER) FILE* {
|
||||
+ $1 = is_obj_file($input);
|
||||
+}
|
||||
+
|
||||
+%typemap(check, noblock = 1) FILE* {
|
||||
+ if ($1 == NULL) {
|
||||
+ /* The generated wrapper function raises TypeError on mismatching types. */
|
||||
+ SWIG_exception_fail(SWIG_TypeError, "in method '" "$symname" "', argument "
|
||||
+ "$argnum"" of type '" "$type""'");
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+%typemap(in, noblock = 1, fragment = "obj_to_file") FILE* {
|
||||
+ $1 = obj_to_file($input);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * Commented out due the way how ub_ctx_debugout() uses the parameter.
|
||||
+ * This typemap would cause the FILE* to be closed after return from
|
||||
+ * the function. This caused Python interpreter to crash, since the
|
||||
+ * function just stores the FILE* internally in ctx and use it for
|
||||
+ * logging. So we'll leave the closing of the file on the OS.
|
||||
+ */
|
||||
+/*%typemap(freearg, noblock = 1, fragment = "dispose_file") FILE* {
|
||||
+ if (dispose_file(&$1) == -1) {
|
||||
+ SWIG_exception_fail(SWIG_IOError, "closing file in method '" "$symname" "', argument "
|
||||
+ "$argnum"" of type '" "$type""'");
|
||||
+ }
|
||||
+}*/
|
||||
diff --git a/libunbound/python/libunbound.i b/libunbound/python/libunbound.i
|
||||
index 1bef79f..3c0e45b 100644
|
||||
--- a/libunbound/python/libunbound.i
|
||||
+++ b/libunbound/python/libunbound.i
|
||||
@@ -60,7 +60,11 @@
|
||||
%}
|
||||
|
||||
//%include "doc.i"
|
||||
+#if PY_MAJOR_VERSION >= 3
|
||||
+%include "file_py3.i" // python 3 FILE *
|
||||
+#else
|
||||
%include "file.i"
|
||||
+#endif
|
||||
|
||||
%feature("docstring") strerror "Convert error value to a human readable string."
|
||||
|
||||
diff --git a/pythonmod/interface.i b/pythonmod/interface.i
|
||||
index cfaabb3..4b20c6e 100644
|
||||
--- a/pythonmod/interface.i
|
||||
+++ b/pythonmod/interface.i
|
||||
@@ -37,7 +37,7 @@
|
||||
%include "stdint.i" // uint_16_t can be known type now
|
||||
|
||||
%inline %{
|
||||
- //converts [len][data][len][data][0] string to a List of labels (PyStrings)
|
||||
+ //converts [len][data][len][data][0] string to a List of labels (PyBytes)
|
||||
PyObject* GetNameAsLabelList(const char* name, int len) {
|
||||
PyObject* list;
|
||||
int cnt=0, i;
|
||||
@@ -79,8 +79,8 @@ struct query_info {
|
||||
%inline %{
|
||||
enum enum_rr_class {
|
||||
RR_CLASS_IN = 1,
|
||||
- RR_CLASS_CH = 3,
|
||||
- RR_CLASS_HS = 4,
|
||||
+ RR_CLASS_CH = 3,
|
||||
+ RR_CLASS_HS = 4,
|
||||
RR_CLASS_NONE = 254,
|
||||
RR_CLASS_ANY = 255,
|
||||
};
|
||||
@@ -164,7 +164,7 @@ struct query_info {
|
||||
char buf[LDNS_MAX_DOMAINLEN+1];
|
||||
buf[0] = '\0';
|
||||
dname_str((uint8_t*)dname, buf);
|
||||
- return PyString_FromString(buf);
|
||||
+ return PyBytes_FromString(buf);
|
||||
}
|
||||
%}
|
||||
|
||||
@@ -440,7 +440,7 @@ struct comm_reply {
|
||||
reply_addr2str(reply, dest, 64);
|
||||
if (dest[0] == 0)
|
||||
return Py_None;
|
||||
- return PyString_FromString(dest);
|
||||
+ return PyBytes_FromString(dest);
|
||||
}
|
||||
|
||||
PyObject* _comm_reply_family_get(struct comm_reply* reply) {
|
||||
@@ -448,9 +448,9 @@ struct comm_reply {
|
||||
int af = (int)((struct sockaddr_in*) &(reply->addr))->sin_family;
|
||||
|
||||
switch(af) {
|
||||
- case AF_INET: return PyString_FromString("ip4");
|
||||
- case AF_INET6: return PyString_FromString("ip6");
|
||||
- case AF_UNIX: return PyString_FromString("unix");
|
||||
+ case AF_INET: return PyBytes_FromString("ip4");
|
||||
+ case AF_INET6: return PyBytes_FromString("ip6");
|
||||
+ case AF_UNIX: return PyBytes_FromString("unix");
|
||||
}
|
||||
|
||||
return Py_None;
|
||||
@@ -711,13 +711,13 @@ struct delegpt {
|
||||
|
||||
%inline %{
|
||||
PyObject* _get_dp_dname(struct delegpt* dp) {
|
||||
- return PyString_FromStringAndSize((char*)dp->name, dp->namelen);
|
||||
+ return PyBytes_FromStringAndSize((char*)dp->name, dp->namelen);
|
||||
}
|
||||
PyObject* _get_dp_dname_components(struct delegpt* dp) {
|
||||
return GetNameAsLabelList((char*)dp->name, dp->namelen);
|
||||
}
|
||||
PyObject* _get_dpns_dname(struct delegpt_ns* dpns) {
|
||||
- return PyString_FromStringAndSize((char*)dpns->name, dpns->namelen);
|
||||
+ return PyBytes_FromStringAndSize((char*)dpns->name, dpns->namelen);
|
||||
}
|
||||
PyObject* _get_dpns_dname_components(struct delegpt_ns* dpns) {
|
||||
return GetNameAsLabelList((char*)dpns->name, dpns->namelen);
|
||||
@@ -728,7 +728,7 @@ struct delegpt {
|
||||
delegpt_addr_addr2str(target, dest, 64);
|
||||
if (dest[0] == 0)
|
||||
return Py_None;
|
||||
- return PyString_FromString(dest);
|
||||
+ return PyBytes_FromString(dest);
|
||||
}
|
||||
|
||||
%}
|
||||
@@ -842,7 +842,7 @@ int checkList(PyObject *l)
|
||||
for (i=0; i < PyList_Size(l); i++)
|
||||
{
|
||||
item = PyList_GetItem(l, i);
|
||||
- if (!PyString_Check(item))
|
||||
+ if (!PyBytes_Check(item))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@@ -864,12 +864,12 @@ int pushRRList(sldns_buffer* qb, PyObject *l, uint32_t default_ttl, int qsec,
|
||||
|
||||
len = sldns_buffer_remaining(qb);
|
||||
if(qsec) {
|
||||
- if(sldns_str2wire_rr_question_buf(PyString_AsString(item),
|
||||
+ if(sldns_str2wire_rr_question_buf(PyBytes_AsString(item),
|
||||
sldns_buffer_current(qb), &len, NULL, NULL, 0, NULL, 0)
|
||||
!= 0)
|
||||
return 0;
|
||||
} else {
|
||||
- if(sldns_str2wire_rr_buf(PyString_AsString(item),
|
||||
+ if(sldns_str2wire_rr_buf(PyBytes_AsString(item),
|
||||
sldns_buffer_current(qb), &len, NULL, default_ttl,
|
||||
NULL, 0, NULL, 0) != 0)
|
||||
return 0;
|
||||
diff --git a/pythonmod/pythonmod.c b/pythonmod/pythonmod.c
|
||||
index 190d41a..48dbc01 100644
|
||||
--- a/pythonmod/pythonmod.c
|
||||
+++ b/pythonmod/pythonmod.c
|
||||
@@ -133,7 +133,13 @@ int pythonmod_init(struct module_env* env, int id)
|
||||
/* Initialize Python libraries */
|
||||
if (!Py_IsInitialized())
|
||||
{
|
||||
- Py_SetProgramName("unbound");
|
||||
+#if PY_MAJOR_VERSION >= 3
|
||||
+ wchar_t progname[8];
|
||||
+ mbstowcs(progname, "unbound", 8);
|
||||
+#else
|
||||
+ char *progname = "unbound";
|
||||
+#endif
|
||||
+ Py_SetProgramName(progname);
|
||||
Py_NoSiteFlag = 1;
|
||||
Py_Initialize();
|
||||
PyEval_InitThreads();
|
||||
--
|
||||
2.1.0
|
||||
|
2
sources
2
sources
@ -1 +1 @@
|
||||
f85854baad15adc7ce8acefe6cda4cf8 unbound-1.5.4.tar.gz
|
||||
e86cccd261c1b01fa9e34cb59b0013d3 unbound-1.5.5.tar.gz
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
Summary: Validating, recursive, and caching DNS(SEC) resolver
|
||||
Name: unbound
|
||||
Version: 1.5.4
|
||||
Release: 5%{?extra_version:.%{extra_version}}%{?dist}
|
||||
Version: 1.5.5
|
||||
Release: 1%{?extra_version:.%{extra_version}}%{?dist}
|
||||
License: BSD
|
||||
Url: http://www.nlnetlabs.nl/unbound/
|
||||
Source: http://www.unbound.net/downloads/%{name}-%{version}%{?extra_version}.tar.gz
|
||||
@ -299,7 +299,6 @@ useradd -r -g unbound -d %{_sysconfdir}/unbound -s /sbin/nologin \
|
||||
|
||||
%post libs
|
||||
/sbin/ldconfig
|
||||
%{_sbindir}/runuser --command="%{_sbindir}/unbound-anchor -a %{_sharedstatedir}/unbound/root.key -c %{_sysconfdir}/unbound/icannbundle.pem" --shell /bin/sh unbound ||:
|
||||
%systemd_post unbound-anchor.timer
|
||||
# start the timer only if installing the package to prevent starting it, if it was stopped on purpose
|
||||
if [ "$1" -eq 1 ]; then
|
||||
@ -430,6 +429,10 @@ popd
|
||||
|
||||
|
||||
%changelog
|
||||
* Wed Oct 07 2015 Tomas Hozza <thozza@redhat.com> - 1.5.5-1
|
||||
- New upstream release 1.5.5 (#1269137)
|
||||
- Removed the anchor update from %%post section of -libs subpackage (#1269137#c2)
|
||||
|
||||
* Tue Sep 15 2015 Tomas Hozza <thozza@redhat.com> - 1.5.4-5
|
||||
- Removed dependency and ordering on unbound-anchor.service in unbound.service
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user