bugzilla-daemon at mindrot.org
2023-Jan-30 19:05 UTC
[Bug 3529] New: `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Bug ID: 3529
Summary: `add_host_to_hostfile` should take into consideration
that the known_hosts file isn't terminated with a
newline character.
Product: Portable OpenSSH
Version: 9.1p1
Hardware: ix86
OS: Linux
Status: NEW
Severity: enhancement
Priority: P5
Component: ssh
Assignee: unassigned-bugs at mindrot.org
Reporter: git+openssh at limpsquid.nl
If the known_hosts file isn't terminated with a newline character the
`add_host_to_hostfile` appends the new host key to the last line which
might already contain a valid host key.
--
You are receiving this mail because:
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Jan-31 23:04 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Mike <git+openssh at limpsquid.nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |git+openssh at limpsquid.nl
--
You are receiving this mail because:
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-04 06:59 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Darren Tucker <dtucker at dtucker.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |3533
CC| |dtucker at dtucker.net
Referenced Bugs:
https://bugzilla.mindrot.org/show_bug.cgi?id=3533
[Bug 3533] tracking bug for openssh-9.3
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-04 07:10 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Darren Tucker <dtucker at dtucker.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |djm at mindrot.org
Attachment #3655| |ok?(djm at mindrot.org)
Flags| |
--- Comment #1 from Darren Tucker <dtucker at dtucker.net> ---
Created attachment 3655
--> https://bugzilla.mindrot.org/attachment.cgi?id=3655&action=edit
Check for newline at end of known_hosts and add it missing
Please try this patch.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-05 09:33 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Darren Tucker <dtucker at dtucker.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #3655|0 |1
is obsolete| |
Attachment #3655|ok?(djm at mindrot.org) |
Flags| |
--- Comment #2 from Darren Tucker <dtucker at dtucker.net> ---
Created attachment 3656
--> https://bugzilla.mindrot.org/attachment.cgi?id=3656&action=edit
Check for newline at end of known_hosts and add it missing. Close FILE
* if write fails.
Please try this one instead.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-05 09:38 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Darren Tucker <dtucker at dtucker.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #3656| |ok?(djm at mindrot.org)
Flags| |
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-05 10:40 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529 --- Comment #3 from Mike <git+openssh at limpsquid.nl> --- (In reply to Darren Tucker from comment #2)> Created attachment 3656 [details] > Check for newline at end of known_hosts and add it missing. Close > FILE * if write fails. > > Please try this one instead.Patch looks good to me, I'll try it out and report back in a day or so. -- You are receiving this mail because: You are watching someone on the CC list of the bug. You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-06 10:43 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Mike <git+openssh at limpsquid.nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #3657| |ok?
Flags| |
--- Comment #4 from Mike <git+openssh at limpsquid.nl> ---
Created attachment 3657
--> https://bugzilla.mindrot.org/attachment.cgi?id=3657&action=edit
Open for reading and appending.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-06 10:44 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529 --- Comment #5 from Mike <git+openssh at limpsquid.nl> --- (In reply to Darren Tucker from comment #2)> Created attachment 3656 [details] > Check for newline at end of known_hosts and add it missing. Close > FILE * if write fails. > > Please try this one instead.I've tested it and for a file which already was terminated with a new-line it still added an extra new-line. I've changed the open mode to `a+` since that should be used for both appending and reading the file. I also had to change the initial fseek to `fseek(f, -1, SEEK_END)`. The docs (https://www.man7.org/linux/man-pages/man3/fopen.3.html) mention the following:> Open for reading and appending (writing at end of file). > The file is created if it does not exist. Output is > always appended to the end of the file. POSIX is silent > on what the initial read position is when using this mode. > For glibc, the initial file position for reading is at the > beginning of the file, but for Android/BSD/MacOS, the > initial file position for reading is at the end of the > file.The attachement was added in my previous comment. -- You are receiving this mail because: You are watching the assignee of the bug. You are watching someone on the CC list of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-06 10:47 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Mike <git+openssh at limpsquid.nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #3657|ok? |ok?(dtucker at dtucker.net)
Flags| |
--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-09 10:09 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Darren Tucker <dtucker at dtucker.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #6 from Darren Tucker <dtucker at dtucker.net> ---
Applied your version, thanks.
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Feb-10 05:11 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Damien Miller <djm at mindrot.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #3656|ok?(djm at mindrot.org) |ok+
Flags| |
--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
bugzilla-daemon at mindrot.org
2023-Mar-17 02:43 UTC
[Bug 3529] `add_host_to_hostfile` should take into consideration that the known_hosts file isn't terminated with a newline character.
https://bugzilla.mindrot.org/show_bug.cgi?id=3529
Damien Miller <djm at mindrot.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |CLOSED
--- Comment #7 from Damien Miller <djm at mindrot.org> ---
OpenSSH 9.3 has been released. Close resolved bugs
--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
Reasonably Related Threads
- [PATCH] allow user to update changed key in known_hosts
- [RFC] Preferentially TOFU certificate authorities rather than host keys
- [patch] tell user about hosts with same key
- ssh disregarding umask for creation of known_hosts (and other files?)
- [Bug 1654] New: ~/.ssh/known_hosts.d/*