Patch to ldns-key2ds to allow writing to stdout with a new -n option,
instead of creating a key file with complex name.
This commit is contained in:
parent
8c563d83a7
commit
4946c4a2db
73
ldns-1.2.0-ldns-key2ds.patch
Normal file
73
ldns-1.2.0-ldns-key2ds.patch
Normal file
@ -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<name>+<alg>+<id>.ds\n");
|
||||
fprintf(fp, " The base name (K<name>+<alg>+<id> 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);
|
||||
Loading…
Reference in New Issue
Block a user