Browse Source
OpenSSH uses a link to take a backup while replacing the known_hosts file: (1) link known_hosts to known_hosts.old (2) move new file to known_hosts (overwriting the link there) Since links are not allowed we replace link with rename: (1) rename known_hosts to known_hosts.old (2) move new file to known_hosts This means that there is a window between (1) and (2) where the known_hosts file is not available, but that is a really short window and is hopefully acceptable here. Fixes #2909.android-5
Fredrik Fornwall
6 years ago
3 changed files with 31 additions and 1 deletions
@ -0,0 +1,15 @@ |
|||||
|
diff -u -r ../openssh-7.8p1/hostfile.c ./hostfile.c
|
||||
|
--- ../openssh-7.8p1/hostfile.c 2018-08-23 05:41:42.000000000 +0000
|
||||
|
+++ ./hostfile.c 2018-09-29 08:21:44.261152558 +0000
|
||||
|
@@ -603,7 +603,11 @@
|
||||
|
r = SSH_ERR_SYSTEM_ERROR; |
||||
|
goto fail; |
||||
|
} |
||||
|
+#ifdef __ANDROID__
|
||||
|
+ if (rename(filename, back) == -1) {
|
||||
|
+#else
|
||||
|
if (link(filename, back) == -1) { |
||||
|
+#endif
|
||||
|
oerrno = errno; |
||||
|
error("%s: link %.100s to %.100s: %s", __func__, |
||||
|
filename, back, strerror(errno)); |
@ -0,0 +1,15 @@ |
|||||
|
diff -u -r ../openssh-7.8p1/ssh-keygen.c ./ssh-keygen.c
|
||||
|
--- ../openssh-7.8p1/ssh-keygen.c 2018-08-23 05:41:42.000000000 +0000
|
||||
|
+++ ./ssh-keygen.c 2018-09-29 08:34:27.584063901 +0000
|
||||
|
@@ -1289,7 +1347,11 @@
|
||||
|
/* Backup existing file */ |
||||
|
if (unlink(old) == -1 && errno != ENOENT) |
||||
|
fatal("unlink %.100s: %s", old, strerror(errno)); |
||||
|
+#ifdef __ANDROID__
|
||||
|
+ if (rename(identity_file, old) == -1)
|
||||
|
+#else
|
||||
|
if (link(identity_file, old) == -1) |
||||
|
+#endif
|
||||
|
fatal("link %.100s to %.100s: %s", identity_file, old, |
||||
|
strerror(errno)); |
||||
|
/* Move new one into place */ |
Loading…
Reference in new issue