mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-26 23:44:35 +02:00
fdopen fix in keygen utility
This commit is contained in:
parent
c25f6a0d5e
commit
12db568b03
@ -990,6 +990,11 @@ do_gen_all_hostkeys(struct passwd *pw)
|
||||
}
|
||||
sshkey_free(private);
|
||||
strlcat(identity_file, ".pub", sizeof(identity_file));
|
||||
#ifdef WINDOWS
|
||||
if ((f = fopen(identity_file, "w")) == NULL) {
|
||||
error("fopen %s failed: %s", identity_file, strerror(errno));
|
||||
/* TODO - set permissions on file */
|
||||
#else
|
||||
fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (fd == -1) {
|
||||
error("Could not save your public key in %s",
|
||||
@ -999,9 +1004,11 @@ do_gen_all_hostkeys(struct passwd *pw)
|
||||
continue;
|
||||
}
|
||||
f = fdopen(fd, "w");
|
||||
|
||||
if (f == NULL) {
|
||||
error("fdopen %s failed", identity_file);
|
||||
close(fd);
|
||||
#endif
|
||||
sshkey_free(public);
|
||||
first = 0;
|
||||
continue;
|
||||
@ -2765,10 +2772,10 @@ passphrase_again:
|
||||
printf("Your identification has been saved in %s.\n", identity_file);
|
||||
|
||||
strlcat(identity_file, ".pub", sizeof(identity_file));
|
||||
/* TODO - for windows call fopen directly*/
|
||||
#ifdef WINDOWS
|
||||
if ((f = fopen(identity_file, "w")) == NULL)
|
||||
fatal("fopen %s failed: %s", identity_file, strerror(errno));
|
||||
/* TODO - set permissions on file */
|
||||
#else
|
||||
if ((fd = open(identity_file, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1)
|
||||
fatal("Unable to save public key to %s: %s",
|
||||
|
Loading…
x
Reference in New Issue
Block a user