fclose(wfp);
- rename(tmpfilename, filename);
+ if (rename(tmpfilename, filename) < 0) {
+ char *msg = dupprintf("Unable to store host key: rename(\"%s\",\"%s\")"
+ " returned '%s'", tmpfilename, filename,
+ strerror(errno));
+ nonfatal(msg);
+ }
sfree(tmpfilename);
sfree(filename);
sfree(dir);
fd = open(fname, O_CREAT | O_WRONLY, 0600);
- if (errno != ENOENT) {
+ if (fd < 0) {
char *msg = dupprintf("Unable to write random seed: open(\"%s\") "
"returned '%s'", fname, strerror(errno));
nonfatal(msg);