mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-25 23:14:54 +02:00
use ifdef to prevent breaking core SSH code
This commit is contained in:
parent
4ade05af67
commit
673b8a4a1b
15
ssh-keygen.c
15
ssh-keygen.c
@ -1468,7 +1468,7 @@ do_change_comment(struct passwd *pw)
|
|||||||
struct sshkey *public;
|
struct sshkey *public;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int r;
|
int r, fd;
|
||||||
|
|
||||||
if (!have_identity)
|
if (!have_identity)
|
||||||
ask_filename(pw, "Enter file in which the key is");
|
ask_filename(pw, "Enter file in which the key is");
|
||||||
@ -1541,9 +1541,18 @@ do_change_comment(struct passwd *pw)
|
|||||||
sshkey_free(private);
|
sshkey_free(private);
|
||||||
|
|
||||||
strlcat(identity_file, ".pub", sizeof(identity_file));
|
strlcat(identity_file, ".pub", sizeof(identity_file));
|
||||||
f = fopen(identity_file, "w");
|
if ((fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
|
||||||
if (f == NULL)
|
fatal("Could not save your public key in %s: %s",
|
||||||
|
identity_file, strerror(errno));
|
||||||
|
#ifdef WINDOWS
|
||||||
|
/* Windows POSIX adpater does not support fdopen() on open(file)*/
|
||||||
|
close(fd);
|
||||||
|
if ((f = fopen(identity_file, "w")) == NULL)
|
||||||
fatal("fopen %s failed: %s", identity_file, strerror(errno));
|
fatal("fopen %s failed: %s", identity_file, strerror(errno));
|
||||||
|
#else /* !WINDOWS */
|
||||||
|
if ((f = fdopen(fd, "w")) == NULL)
|
||||||
|
fatal("fdopen %s failed: %s", identity_file, strerror(errno));
|
||||||
|
#endif /* !WINDOWS */
|
||||||
if ((r = sshkey_write(public, f)) != 0)
|
if ((r = sshkey_write(public, f)) != 0)
|
||||||
fatal("write key failed: %s", ssh_err(r));
|
fatal("write key failed: %s", ssh_err(r));
|
||||||
sshkey_free(public);
|
sshkey_free(public);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user