1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-12 16:47:42 -05:00

Fix `puttygen-unix-perms': f_open(), PuTTY's wrapper on fopen, now

takes a third argument which is TRUE if the file is being opened for
writing and wants to be created in such a way that it's readable
only to the owner. This is used when saving private keys.

While I'm here, I also use this option when writing session logs, on
the general principle that they probably contain _something_
sensitive.

The new argument is only supported on Unix, for the moment. (I think
writing owner-accessible-only files is the default on Windows.)

[originally from svn r7084]
This commit is contained in:
Simon Tatham
2007-01-09 18:14:30 +00:00
parent dbbd6eb5ec
commit 4fa9564c90
9 changed files with 37 additions and 22 deletions

View File

@ -333,7 +333,7 @@ static struct openssh_key *load_openssh_key(const Filename *filename,
ret->encrypted = 0;
memset(ret->iv, 0, sizeof(ret->iv));
fp = f_open(*filename, "r");
fp = f_open(*filename, "r", FALSE);
if (!fp) {
errmsg = "unable to open key file";
goto error;
@ -893,7 +893,7 @@ int openssh_write(const Filename *filename, struct ssh2_userkey *key,
* And save it. We'll use Unix line endings just in case it's
* subsequently transferred in binary mode.
*/
fp = f_open(*filename, "wb"); /* ensure Unix line endings */
fp = f_open(*filename, "wb", TRUE); /* ensure Unix line endings */
if (!fp)
goto error;
fputs(header, fp);
@ -1027,7 +1027,7 @@ static struct sshcom_key *load_sshcom_key(const Filename *filename,
ret->keyblob = NULL;
ret->keyblob_len = ret->keyblob_size = 0;
fp = f_open(*filename, "r");
fp = f_open(*filename, "r", FALSE);
if (!fp) {
errmsg = "unable to open key file";
goto error;
@ -1646,7 +1646,7 @@ int sshcom_write(const Filename *filename, struct ssh2_userkey *key,
* And save it. We'll use Unix line endings just in case it's
* subsequently transferred in binary mode.
*/
fp = f_open(*filename, "wb"); /* ensure Unix line endings */
fp = f_open(*filename, "wb", TRUE); /* ensure Unix line endings */
if (!fp)
goto error;
fputs("---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----\n", fp);