mirror of
http://galexander.org/git/simplesshd.git
synced 2024-11-27 17:58:13 +00:00
use rename() if the underlying filesystem doesn't support link()
This commit is contained in:
parent
97533c8574
commit
25b613c4f5
@ -134,10 +134,10 @@ static void svr_ensure_hostkey() {
|
|||||||
if (link(fn_temp, fn) < 0) {
|
if (link(fn_temp, fn) < 0) {
|
||||||
/* It's OK to get EEXIST - we probably just lost a race
|
/* It's OK to get EEXIST - we probably just lost a race
|
||||||
with another connection to generate the key */
|
with another connection to generate the key */
|
||||||
if (errno != EEXIST) {
|
/* fallback to rename() if the fs doesn't support link() */
|
||||||
|
if ((errno != EEXIST) && (rename(fn_temp, fn) < 0)) {
|
||||||
dropbear_log(LOG_ERR, "Failed moving key file to %s: %s", fn,
|
dropbear_log(LOG_ERR, "Failed moving key file to %s: %s", fn,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
/* XXX fallback to non-atomic copy for some filesystems? */
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user