ssh install tells a missing .ssh from one it cannot enter #27

Merged
clawbot merged 1 commits from issue-10-ssh-install-directory-check into next 2026-09-21 09:50:01 +02:00
Collaborator

Second pass on #10.

The first sftp connection now lists ~/.ssh before it fetches
authorized_keys, so the tool can tell a directory that is not there from one
it cannot enter — a difference sftp does not make on a fetch alone. The file
reads as empty in two cases only: sftp reports ~/.ssh itself as not there, or
the listing succeeds and the fetch then reports the file as not there. A
~/.ssh that is there but unenterable, an authorized_keys that is there but
unreadable, or a connection that never came up all fail the run and write
nothing. This closes the defect that closed
#12: a ~/.ssh whose mode shut the user
out was read as a host with no file and replaced by one holding the new key
alone.

The write connection makes ~/.ssh and sets 0700 only when the read found
none; a directory that was already there keeps its mode.

For review: the sftp wordings the parsing turns on were read off OpenSSH
9.6/10.2 against a local sftp-server, for a missing directory, a directory of
mode 000, a missing file, and a file of mode 000. The test's fake sftp stands
in an unenterable directory by mode 000, read off the mode itself so the result
does not turn on the uid the tests run as. A run that adds a line still connects
twice.

Model: opus-4-8

Second pass on https://git.eeqj.de/sneak/keyfunc/issues/10. The first sftp connection now lists `~/.ssh` before it fetches `authorized_keys`, so the tool can tell a directory that is not there from one it cannot enter — a difference sftp does not make on a fetch alone. The file reads as empty in two cases only: sftp reports `~/.ssh` itself as not there, or the listing succeeds and the fetch then reports the file as not there. A `~/.ssh` that is there but unenterable, an `authorized_keys` that is there but unreadable, or a connection that never came up all fail the run and write nothing. This closes the defect that closed https://git.eeqj.de/sneak/keyfunc/pulls/12: a `~/.ssh` whose mode shut the user out was read as a host with no file and replaced by one holding the new key alone. The write connection makes `~/.ssh` and sets `0700` only when the read found none; a directory that was already there keeps its mode. For review: the sftp wordings the parsing turns on were read off OpenSSH 9.6/10.2 against a local sftp-server, for a missing directory, a directory of mode 000, a missing file, and a file of mode 000. The test's fake sftp stands in an unenterable directory by mode 000, read off the mode itself so the result does not turn on the uid the tests run as. A run that adds a line still connects twice. Model: opus-4-8
clawbot added the needs-review label 2026-09-21 09:41:42 +02:00
clawbot self-assigned this 2026-09-21 09:41:42 +02:00
clawbot added 1 commit 2026-09-21 09:41:43 +02:00
The first sftp connection now lists ~/.ssh before it fetches
authorized_keys. The file reads as empty in just two cases: sftp reports
~/.ssh itself as not there, or the listing succeeds and the fetch then
reports the file as not there. A directory that is there but cannot be
entered, or a file that cannot be read, fails the run and writes nothing,
so a ~/.ssh whose mode shuts the user out is no longer read as a host
with no file and replaced by one holding the new key alone. The write
connection makes ~/.ssh and sets 0700 only when the read found none; an
existing directory keeps its mode.

Model: opus-4-8
Author
Collaborator

Review passed. The sftp wordings the parsing turns on were checked against the real OpenSSH 10.2 client (sftp -D sftp-server, no network) for a missing .ssh, a .ssh of mode 000, a missing file, a file of mode 000, authorized_keys as a directory, and a dangling symlink: only a missing directory and a missing file are read as absent, and every unreadable case fails the run and writes nothing.

Model: opus-4-8

Review passed. The sftp wordings the parsing turns on were checked against the real OpenSSH 10.2 client (`sftp -D` sftp-server, no network) for a missing `.ssh`, a `.ssh` of mode 000, a missing file, a file of mode 000, `authorized_keys` as a directory, and a dangling symlink: only a missing directory and a missing file are read as absent, and every unreadable case fails the run and writes nothing. Model: opus-4-8
clawbot merged commit 3d90ac87f1 into next 2026-09-21 09:50:01 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/keyfunc#27