This is a discussion on Proposed patch: ssh-keygen allows writing to stdout for moduli within the OpenSSH Development forums, part of the Networking and Network Related category; Hello all, I propose the following patch to ssh-keygen.c for openssh version 4.5. It allows to redirect ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello all,
I propose the following patch to ssh-keygen.c for openssh version 4.5. It allows to redirect output of the moduli operations to stdout, to do something like e.g.: $ ssh-keygen -G - -b 2048 | ssh-keygen -T - -f - >moduli Best regards, Christian --- ssh/ssh-keygen.c.old 2007-03-01 12:43:06.000000000 +0100 +++ ssh/ssh-keygen.c 2007-03-01 12:47:32.000000000 +0100 @@ -1270,13 +1270,16 @@ main(int ac, char **av) } if (do_gen_candidates) { - FILE *out = fopen(out_file, "w"); - - if (out == NULL) { - error("Couldn't open modulus candidate file \"%s\": %s", - out_file, strerror(errno)); - return (1); - } + FILE *out; + + if (strcmp(out_file, "-") != 0) { + if ((out = fopen(out_file, "w")) == NULL) { + fatal("Couldn't open modulus candidate file \"%s\": %s", + out_file, strerror(errno)); + } + } else + out = stdout; + if (bits == 0) bits = DEFAULT_BITS; if (gen_candidates(out, memory, bits, start) != 0) @@ -1287,8 +1290,16 @@ main(int ac, char **av) if (do_screen_candidates) { FILE *in; - FILE *out = fopen(out_file, "w"); + FILE *out; + if (strcmp(out_file, "-") != 0) { + if ((out = fopen(out_file, "w")) == NULL) { + fatal("Couldn't open moduli file \"%s\": %s", + out_file, strerror(errno)); + } + } else + out = stdout; + if (have_identity && strcmp(identity_file, "-") != 0) { if ((in = fopen(identity_file, "r")) == NULL) { fatal("Couldn't open modulus candidate " @@ -1298,10 +1309,6 @@ main(int ac, char **av) } else in = stdin; - if (out == NULL) { - fatal("Couldn't open moduli file \"%s\": %s", - out_file, strerror(errno)); - } if (prime_test(in, out, trials, generator_wanted) != 0) fatal("modulus screening failed"); return (0); _______________________________________________ openssh-unix-dev mailing list openssh-unix-dev@mindrot.org http://lists.mindrot.org/mailman/lis...enssh-unix-dev |