diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ssh-keygen.c | 32 |
2 files changed, 28 insertions, 13 deletions
@@ -1,3 +1,10 @@ | |||
1 | 20010310 | ||
2 | - OpenBSD CVS Sync | ||
3 | - deraadt@cvs.openbsd.org 2001/03/09 03:14:39 | ||
4 | [ssh-keygen.c] | ||
5 | create *.pub files with umask 0644, so that you can mv them to | ||
6 | authorized_keys | ||
7 | |||
1 | 20010309 | 8 | 20010309 |
2 | - OpenBSD CVS Sync | 9 | - OpenBSD CVS Sync |
3 | - stevesk@cvs.openbsd.org 2001/03/08 18:47:12 | 10 | - stevesk@cvs.openbsd.org 2001/03/08 18:47:12 |
@@ -4457,4 +4464,4 @@ | |||
4457 | - Wrote replacements for strlcpy and mkdtemp | 4464 | - Wrote replacements for strlcpy and mkdtemp |
4458 | - Released 1.0pre1 | 4465 | - Released 1.0pre1 |
4459 | 4466 | ||
4460 | $Id: ChangeLog,v 1.930 2001/03/09 00:12:22 mouring Exp $ | 4467 | $Id: ChangeLog,v 1.931 2001/03/09 18:19:24 mouring Exp $ |
diff --git a/ssh-keygen.c b/ssh-keygen.c index e5e34cb2f..dbb46ac90 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: ssh-keygen.c,v 1.45 2001/02/22 08:03:51 deraadt Exp $"); | 15 | RCSID("$OpenBSD: ssh-keygen.c,v 1.46 2001/03/09 03:14:39 deraadt Exp $"); |
16 | 16 | ||
17 | #include <openssl/evp.h> | 17 | #include <openssl/evp.h> |
18 | #include <openssl/pem.h> | 18 | #include <openssl/pem.h> |
@@ -512,12 +512,11 @@ do_change_passphrase(struct passwd *pw) | |||
512 | void | 512 | void |
513 | do_change_comment(struct passwd *pw) | 513 | do_change_comment(struct passwd *pw) |
514 | { | 514 | { |
515 | char new_comment[1024], *comment; | 515 | char new_comment[1024], *comment, *passphrase; |
516 | Key *private; | 516 | Key *private, *public; |
517 | Key *public; | ||
518 | char *passphrase; | ||
519 | struct stat st; | 517 | struct stat st; |
520 | FILE *f; | 518 | FILE *f; |
519 | int fd; | ||
521 | 520 | ||
522 | if (!have_identity) | 521 | if (!have_identity) |
523 | ask_filename(pw, "Enter file in which the key is"); | 522 | ask_filename(pw, "Enter file in which the key is"); |
@@ -585,11 +584,16 @@ do_change_comment(struct passwd *pw) | |||
585 | key_free(private); | 584 | key_free(private); |
586 | 585 | ||
587 | strlcat(identity_file, ".pub", sizeof(identity_file)); | 586 | strlcat(identity_file, ".pub", sizeof(identity_file)); |
588 | f = fopen(identity_file, "w"); | 587 | fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
589 | if (!f) { | 588 | if (fd == -1) { |
590 | printf("Could not save your public key in %s\n", identity_file); | 589 | printf("Could not save your public key in %s\n", identity_file); |
591 | exit(1); | 590 | exit(1); |
592 | } | 591 | } |
592 | f = fdopen(fd, "w"); | ||
593 | if (f == NULL) { | ||
594 | printf("fdopen %s failed", identity_file); | ||
595 | exit(1); | ||
596 | } | ||
593 | if (!key_write(public, f)) | 597 | if (!key_write(public, f)) |
594 | fprintf(stderr, "write key failed"); | 598 | fprintf(stderr, "write key failed"); |
595 | key_free(public); | 599 | key_free(public); |
@@ -617,12 +621,11 @@ int | |||
617 | main(int ac, char **av) | 621 | main(int ac, char **av) |
618 | { | 622 | { |
619 | char dotsshdir[16 * 1024], comment[1024], *passphrase1, *passphrase2; | 623 | char dotsshdir[16 * 1024], comment[1024], *passphrase1, *passphrase2; |
624 | Key *private, *public; | ||
620 | struct passwd *pw; | 625 | struct passwd *pw; |
621 | int opt, type; | 626 | int opt, type, fd; |
622 | struct stat st; | 627 | struct stat st; |
623 | FILE *f; | 628 | FILE *f; |
624 | Key *private; | ||
625 | Key *public; | ||
626 | 629 | ||
627 | extern int optind; | 630 | extern int optind; |
628 | extern char *optarg; | 631 | extern char *optarg; |
@@ -827,11 +830,16 @@ passphrase_again: | |||
827 | printf("Your identification has been saved in %s.\n", identity_file); | 830 | printf("Your identification has been saved in %s.\n", identity_file); |
828 | 831 | ||
829 | strlcat(identity_file, ".pub", sizeof(identity_file)); | 832 | strlcat(identity_file, ".pub", sizeof(identity_file)); |
830 | f = fopen(identity_file, "w"); | 833 | fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644); |
831 | if (!f) { | 834 | if (fd == -1) { |
832 | printf("Could not save your public key in %s\n", identity_file); | 835 | printf("Could not save your public key in %s\n", identity_file); |
833 | exit(1); | 836 | exit(1); |
834 | } | 837 | } |
838 | f = fdopen(fd, "w"); | ||
839 | if (f == NULL) { | ||
840 | printf("fdopen %s failed", identity_file); | ||
841 | exit(1); | ||
842 | } | ||
835 | if (!key_write(public, f)) | 843 | if (!key_write(public, f)) |
836 | fprintf(stderr, "write key failed"); | 844 | fprintf(stderr, "write key failed"); |
837 | fprintf(f, " %s\n", comment); | 845 | fprintf(f, " %s\n", comment); |