From: Miek Gieben Date: Wed, 14 Sep 2005 07:07:42 +0000 (+0000) Subject: reworked the patch somewhat, mostly geared toward ldns-update.c X-Git-Tag: release-1.0.0~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2bfa53c94519b58db6c38ab4a10e741ca36993fb;p=thirdparty%2Fldns.git reworked the patch somewhat, mostly geared toward ldns-update.c --- diff --git a/Makefile.in b/Makefile.in index d94fc0f0..834f0b51 100644 --- a/Makefile.in +++ b/Makefile.in @@ -73,12 +73,12 @@ LINK_LIB = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) all: lib tools -tools: $(PROG_TARGETS) confdrill tools-drill +tools: $(PROG_TARGETS) drill -confdrill: ./drill/configure +./drill/config.log: ./drill/configure ( cd drill ; ./configure --with-ldns=../) -drill: confdrill +drill: ./drill/config.log ( cd drill ; make -f Makefile all) lib: $(LIBDNS_OBJECTS) b64_pton$U.o b64_ntop$U.o diff --git a/dnssec.c b/dnssec.c index 97e4cbd6..86c500e1 100644 --- a/dnssec.c +++ b/dnssec.c @@ -26,6 +26,7 @@ #include #include +/* used only on the public key RR */ uint16_t ldns_calc_keytag(ldns_rr *key) { @@ -958,10 +959,6 @@ ldns_sign_public_rsamd5(ldns_buffer *to_sign, RSA *key) return sigdata_rdf; } -/* -ldns_rr * -ldns_create_nsec(ldns_rr_list *before, ldns_rr_list *after) -*/ ldns_rr * ldns_create_nsec(ldns_rdf *cur_owner, ldns_rdf *next_owner, ldns_rr_list *rrs) { @@ -1156,7 +1153,7 @@ ldns_zone_sign(ldns_zone *zone, ldns_key_list *key_list) ldns_rr *ckey; uint16_t i; ldns_rr_type cur_rrset_type; -ldns_status result; + ldns_status result; signed_zone = ldns_zone_new(); diff --git a/higher.c b/higher.c index d5bf7195..aea0589d 100644 --- a/higher.c +++ b/higher.c @@ -276,7 +276,7 @@ ldns_getaddrinfo_secure(void) * \param[in] tsig_cred credentials for TSIG-protected update messages */ ldns_status -ldns_update_send_simple_A(const char *fqdn, const char *zone, +ldns_update_send_simple_addr(const char *fqdn, const char *zone, const char *ipaddr, u_int16_t ttl, ldns_tsig_credentials *tsig_cred) { ldns_resolver *res; diff --git a/ldns-update.c b/ldns-update.c index 644174de..5cb351d9 100644 --- a/ldns-update.c +++ b/ldns-update.c @@ -6,15 +6,28 @@ #include + +void +usage(FILE *fp, char *prog) { + fprintf(fp, "%s domain [zone] ip [tsig_name tsig_alg tsig_hmac]\n", prog); + fprintf(fp, " send a dynamic update packet to \n\n"); + fprintf(fp, " Use 'none' instead of ip to remove any previous address\n"); + fprintf(fp, " If 'zone' is not specified, try to figure it out from the zone's SOA\n"); + fprintf(fp, " Example: %s my.example.org 1.2.3.4\n", prog); +} + + int main(int argc, char **argv) { - char *fqdn, *ipaddr, *zone; - u_int16_t defttl = 300; + char *fqdn, *ipaddr, *zone, *prog; ldns_status ret; ldns_tsig_credentials tsig_cr, *tsig_cred; int c = 2; + uint16_t defttl = 300; + prog = strdup(argv[0]); + switch (argc) { case 3: case 4: @@ -22,49 +35,46 @@ main(int argc, char **argv) case 7: break; default: - fprintf(stderr, "usage: %s FQDN [zone] IP " - "[tsig_name tsig_alg tsig_hmac]\n", argv[0]); - fprintf(stderr, "Example: %s my.host.org 1.2.3.4\n", argv[0]); - fprintf(stderr, "Use 'none' instead of IP to remove any " - "previous address.\n"); - fprintf(stderr, "If 'zone' is not specified, " - "try to figure it from SOA.\n"); - exit(1); + usage(stderr, prog); + exit(EXIT_FAILURE); } fqdn = argv[1]; c = 2; - if (argc == 4 || argc == 7) + if (argc == 4 || argc == 7) { zone = argv[c++]; - else + } else { zone = NULL; + } - if (strcmp(argv[c], "none") == 0) + if (strcmp(argv[c], "none") == 0) { ipaddr = NULL; - else + } else { ipaddr = argv[c]; + } c++; if (argc == 6 || argc == 7) { tsig_cr.keyname = argv[c++]; - if (strncasecmp(argv[c], "hmac-sha1", 9) == 0) - tsig_cr.algorithm = "hmac-sha1."; - else if (strncasecmp(argv[c], "hmac-md5", 8) == 0) - tsig_cr.algorithm = "hmac-md5.sig-alg.reg.int."; - else { + if (strncasecmp(argv[c], "hmac-sha1", 9) == 0) { + tsig_cr.algorithm = (char*)"hmac-sha1."; + } else if (strncasecmp(argv[c], "hmac-md5", 8) == 0) { + tsig_cr.algorithm = (char*)"hmac-md5.sig-alg.reg.int."; + } else { fprintf(stderr, "Unknown algorithm, try \"hmac-md5\" " "or \"hmac-sha1\".\n"); - exit(1); + exit(EXIT_FAILURE); } tsig_cr.keydata = argv[++c]; tsig_cred = &tsig_cr; - } else + } else { tsig_cred = NULL; + } printf(";; trying UPDATE with FQDN \"%s\" and IP \"%s\"\n", fqdn, ipaddr ? ipaddr : ""); printf(";; tsig: \"%s\" \"%s\" \"%s\"\n", tsig_cr.keyname, tsig_cr.algorithm, tsig_cr.keydata); - ret = ldns_update_send_simple_A(fqdn, zone, ipaddr, defttl, tsig_cred); + ret = ldns_update_send_simple_addr(fqdn, zone, ipaddr, defttl, tsig_cred); exit(ret); } diff --git a/ldns/higher.h b/ldns/higher.h index 9e5a2b02..27bac08a 100644 --- a/ldns/higher.h +++ b/ldns/higher.h @@ -95,7 +95,7 @@ ldns_rr_list *ldns_getaddrinfo_secure(); * \param[in] ttl the update RR TTL * \param[in] tsig_cred credentials for TSIG-protected update messages */ -ldns_status ldns_update_send_simple_A(const char *fqdn, const char *zone, +ldns_status ldns_update_send_simple_addr(const char *fqdn, const char *zone, const char *ipaddr, u_int16_t tll, ldns_tsig_credentials *tsig_cred); #endif /* _LDNS_HIGHER_H */ diff --git a/tsig.c b/tsig.c index 31a5fe0c..32884598 100644 --- a/tsig.c +++ b/tsig.c @@ -152,34 +152,34 @@ ldns_create_tsig_mac( ldns_rdf *orig_mac_rdf ) { - ldns_buffer *data_buffer = NULL; char *wireformat; int wiresize; unsigned char *mac_bytes; - unsigned int md_len = EVP_MAX_MD_SIZE; unsigned char *key_bytes; int key_size; const EVP_MD *digester; char *algorithm_name; + unsigned int md_len = EVP_MAX_MD_SIZE; ldns_rdf *result = NULL; + ldns_buffer *data_buffer = NULL; /* * prepare the digestable information */ - data_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN); + data_buffer = ldns_buffer_new(LDNS_MIN_BUFLEN); /* we scale autom. */ /* if orig_mac is not NULL, add it too */ if (orig_mac_rdf) { (void) ldns_rdf2buffer_wire(data_buffer, orig_mac_rdf); } ldns_buffer_write(data_buffer, pkt_wire, pkt_wire_size); - (void) ldns_rdf2buffer_wire(data_buffer, key_name_rdf); + (void)ldns_rdf2buffer_wire(data_buffer, key_name_rdf); ldns_buffer_write_u16(data_buffer, LDNS_RR_CLASS_ANY); ldns_buffer_write_u32(data_buffer, 0); - (void) ldns_rdf2buffer_wire(data_buffer, algorithm_rdf); - (void) ldns_rdf2buffer_wire(data_buffer, time_signed_rdf); - (void) ldns_rdf2buffer_wire(data_buffer, fudge_rdf); - (void) ldns_rdf2buffer_wire(data_buffer, error_rdf); - (void) ldns_rdf2buffer_wire(data_buffer, other_data_rdf); + (void)ldns_rdf2buffer_wire(data_buffer, algorithm_rdf); + (void)ldns_rdf2buffer_wire(data_buffer, time_signed_rdf); + (void)ldns_rdf2buffer_wire(data_buffer, fudge_rdf); + (void)ldns_rdf2buffer_wire(data_buffer, error_rdf); + (void)ldns_rdf2buffer_wire(data_buffer, other_data_rdf); wireformat = (char *) data_buffer->_data; wiresize = (int) ldns_buffer_position(data_buffer); @@ -400,5 +400,3 @@ ldns_pkt_tsig_sign(ldns_pkt *pkt, const char *key_name, const char *key_data, ui ldns_rdf_free(other_data_rdf); return status; } - -