f = fopen(filename, "a");
if (!f)
return 0;
/* Make sure we have a terminating newline. */
if (fseek(f, -1, SEEK_CUR) == 0 && fgetc(f) != '\n')
if (fputc('\n', f) != '\n') {
debug3_f("failed to add terminating newline");
}
success = write_host_entry(f, host, NULL, key, store_hash);
fclose(f);
return success;
trace "test hashed known hosts"
${SSH} $opts somehost true || fail "reconnect with hashed known hosts"
trace "no newline at end of known_hosts"
printf "something" >$OBJ/known_hosts
${SSH} $opts -ostricthostkeychecking=no somehost true \
|| fail "hostkey update, missing newline, no strict"
${SSH} $opts -ostricthostkeychecking=yes somehost true \
|| fail "reconnect after adding with missing newline"