]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: allow "-" as output file for moduli screening
authordjm@openbsd.org <djm@openbsd.org>
Fri, 18 Oct 2024 05:37:24 +0000 (05:37 +0000)
committerDamien Miller <djm@mindrot.org>
Fri, 18 Oct 2024 05:37:53 +0000 (16:37 +1100)
based on GHPR393

OpenBSD-Commit-ID: 1517763764eb55d03a6092dd120d2909c6fef0e1

ssh-keygen.c

index 8396c40368d27854884a37f5d0fa3c2e42c976a4..f7ea069684c5c2be722eee23f45675d3e617949e 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.475 2024/09/15 00:47:01 djm Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.476 2024/10/18 05:37:24 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -3028,7 +3028,9 @@ do_moduli_gen(const char *out_file, char **opts, size_t nopts)
                }
        }
 
-       if ((out = fopen(out_file, "w")) == NULL) {
+       if (strcmp(out_file, "-") == 0)
+               out = stdout;
+       else if ((out = fopen(out_file, "w")) == NULL) {
                fatal("Couldn't open modulus candidate file \"%s\": %s",
                    out_file, strerror(errno));
        }
@@ -3093,7 +3095,9 @@ do_moduli_screen(const char *out_file, char **opts, size_t nopts)
                }
        }
 
-       if ((out = fopen(out_file, "a")) == NULL) {
+       if (strcmp(out_file, "-") == 0)
+               out = stdout;
+       else if ((out = fopen(out_file, "a")) == NULL) {
                fatal("Couldn't open moduli file \"%s\": %s",
                    out_file, strerror(errno));
        }