From 4946c4a2db5c8482c8a2419f37d2c816d222f494 Mon Sep 17 00:00:00 2001 From: Paul Wouters Date: Wed, 8 Aug 2007 22:12:07 +0000 Subject: [PATCH] Patch to ldns-key2ds to allow writing to stdout with a new -n option, instead of creating a key file with complex name. --- ldns-1.2.0-ldns-key2ds.patch | 73 ++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 ldns-1.2.0-ldns-key2ds.patch diff --git a/ldns-1.2.0-ldns-key2ds.patch b/ldns-1.2.0-ldns-key2ds.patch new file mode 100644 index 0000000..40108e8 --- /dev/null +++ b/ldns-1.2.0-ldns-key2ds.patch @@ -0,0 +1,73 @@ +diff -ruN ldns-1.2.0.orig/examples/ldns-key2ds.c ldns-1.2.0/examples/ldns-key2ds.c +--- ldns-1.2.0.orig/examples/ldns-key2ds.c 2007-08-08 17:46:18.000000000 -0400 ++++ ldns-1.2.0/examples/ldns-key2ds.c 2007-08-08 17:46:36.000000000 -0400 +@@ -15,13 +15,14 @@ + + void + usage(FILE *fp, char *prog) { +- fprintf(fp, "%s [-1|-2] keyfile\n", prog); ++ fprintf(fp, "%s [-n] [-1|-2] keyfile\n", prog); + fprintf(fp, " Generate a DS RR from the key\n"); + fprintf(fp, " The following file will be created: "); + fprintf(fp, "K++.ds\n"); + fprintf(fp, " The base name (K++ will be printed to stdout\n"); + fprintf(fp, "Options:\n"); +- fprintf(fp, " -1 (default): use SHA1 for the DS hash\n"); ++ fprintf(fp, " -n: do not write to file but to stdout\n"); ++ fprintf(fp, " -1: (default): use SHA1 for the DS hash\n"); + fprintf(fp, " -2: use SHA256 for the DS hash\n"); + } + +@@ -36,7 +37,8 @@ + ldns_signing_algorithm alg; + ldns_hash h; + char *program = argv[0]; +- ++ int nofile=0; ++ + alg = 0; + h = LDNS_SHA1; + +@@ -50,7 +52,10 @@ + fprintf(stderr, "Error: Crypto library does not support SHA256 digests!"); + #endif + h = LDNS_SHA256; +- } ++ } ++ if (strcmp(argv[0], "-n") == 0) { ++ nofile=1; ++ } + argv++, argc--; + } + +@@ -89,18 +94,21 @@ + dsname = LDNS_XMALLOC(char, strlen(owner) + 16); + snprintf(dsname, strlen(owner) + 15, "K%s+%03u+%05u.ds", owner, alg, (unsigned int) ldns_calc_keytag(k)); + +- dsfp = fopen(dsname, "w"); +- if (!dsfp) { +- fprintf(stderr, "Unable to open %s: %s\n", dsname, strerror(errno)); +- exit(EXIT_FAILURE); +- } else { +- ldns_rr_print(dsfp, ds); +- fclose(dsfp); ++ if (nofile) ++ ldns_rr_print(stdout,ds); ++ else { ++ dsfp = fopen(dsname, "w"); ++ if (!dsfp) { ++ fprintf(stderr, "Unable to open %s: %s\n", dsname, strerror(errno)); ++ exit(EXIT_FAILURE); ++ } else { ++ ldns_rr_print(dsfp, ds); ++ fclose(dsfp); ++ fprintf(stdout, "K%s+%03u+%05u\n", owner, alg, (unsigned int) ldns_calc_keytag(k)); ++ } + } + + ldns_rr_free(ds); +- fprintf(stdout, "K%s+%03u+%05u\n", owner, alg, (unsigned int) ldns_calc_keytag(k)); +- + ldns_rr_free(k); + free(owner); + LDNS_FREE(dsname);