mirror of
https://github.com/clearml/dropbear
synced 2025-02-07 13:21:15 +00:00
Fix if the first write fails
--HG-- extra : convert_revision : 5a12aa1aa66c9cfd5d0097acea235cd3cd7658ab
This commit is contained in:
parent
70b7c24cb0
commit
857dfdeb9e
15
cli-kex.c
15
cli-kex.c
@ -164,13 +164,16 @@ static void checkhostkey(unsigned char* keyblob, unsigned int keybloblen) {
|
||||
|
||||
snprintf(filename, len+18, "%s/.ssh/known_hosts", pw->pw_dir);
|
||||
hostsfile = fopen(filename, "a+");
|
||||
fseek(hostsfile, 0, SEEK_SET);
|
||||
|
||||
/* We mightn't have been able to open it if it was read-only */
|
||||
if (hostsfile == NULL && (errno == EACCES || errno == EROFS)) {
|
||||
TRACE(("trying readonly: %s", strerror(errno)));
|
||||
readonly = 1;
|
||||
hostsfile = fopen(filename, "r");
|
||||
if (hostsfile != NULL) {
|
||||
fseek(hostsfile, 0, SEEK_SET);
|
||||
} else {
|
||||
/* We mightn't have been able to open it if it was read-only */
|
||||
if (errno == EACCES || errno == EROFS) {
|
||||
TRACE(("trying readonly: %s", strerror(errno)));
|
||||
readonly = 1;
|
||||
hostsfile = fopen(filename, "r");
|
||||
}
|
||||
}
|
||||
|
||||
if (hostsfile == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user