View | Details | Raw Unified | Return to bug 3529 | Differences between
and this patch

Collapse All | Expand All

(-)a/hostfile.c (-1 / +9 lines)
Lines 520-528 add_host_to_hostfile(const char *filename, const char *host, Link Here
520
       if (key == NULL)
520
       if (key == NULL)
521
               return 1;       /* XXX ? */
521
               return 1;       /* XXX ? */
522
       hostfile_create_user_ssh_dir(filename, 0);
522
       hostfile_create_user_ssh_dir(filename, 0);
523
       f = fopen(filename, "a");
523
       f = fopen(filename, "a+");
524
       if (!f)
524
       if (!f)
525
               return 0;
525
               return 0;
526
       /* Make sure we have a terminating newline. */
527
       if (fseek(f, -1, SEEK_END) == 0 && fgetc(f) != '\n')
528
               if (fputc('\n', f) != '\n') {
529
                       error("Failed to add terminating newline to %s: %s",
530
                          filename, strerror(errno) );
531
                       fclose(f);
532
                       return 0;
533
               }
526
       success = write_host_entry(f, host, NULL, key, store_hash);
534
       success = write_host_entry(f, host, NULL, key, store_hash);
527
       fclose(f);
535
       fclose(f);
528
       return success;
536
       return success;
(-)a/regress/knownhosts.sh (+7 lines)
Lines 15-17 ${SSH} -ohashknownhosts=yes -o stricthostkeychecking=no $opts somehost true \ Link Here
15
15
16
trace "test hashed known hosts"
16
trace "test hashed known hosts"
17
${SSH} $opts somehost true || fail "reconnect with hashed known hosts"
17
${SSH} $opts somehost true || fail "reconnect with hashed known hosts"
18
19
trace "no newline at end of known_hosts"
20
printf "something" >$OBJ/known_hosts
21
${SSH} $opts -ostricthostkeychecking=no somehost true \
22
    || fail "hostkey update, missing newline, no strict"
23
${SSH} $opts -ostricthostkeychecking=yes somehost true \
24
    || fail "reconnect after adding with missing newline"

Return to bug 3529