Skip to content

agent: let the application open the agent channel - #1230

Open
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:ccb-phase2-4a
Open

agent: let the application open the agent channel#1230
ejohnstown wants to merge 2 commits into
wolfSSL:masterfrom
ejohnstown:ccb-phase2-4a

Conversation

@ejohnstown

Copy link
Copy Markdown
Contributor

The one server-side site that opens auth-agent@openssh.com sits inside
wolfSSH_accept(), so an application driving its own channels cannot reach
it: the session records the request and no channel follows.

  • Add wolfSSH_AGENT_ChannelOpen(), the same open lifted out of accept(),
    which still calls it.
  • It reports WS_BAD_ARGUMENT until the peer asks and is idempotent
    afterward, so an application can poll it.
  • Publish the agent on a queued open too, so a retry after WS_WANT_WRITE
    does not open a second channel and leak the first.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new pollable API can return WS_SUCCESS on retry while output is still pending (masking WS_WANT_*), and the header comment currently understates the actual error/return surface.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR makes server-side SSH agent forwarding usable for applications that manage channel opens themselves (i.e., don’t follow the default wolfSSH_accept() channel flow), by factoring the auth-agent channel open logic into a callable API.

Changes:

  • Adds a new public API wolfSSH_AGENT_ChannelOpen() for server-side opening of auth-agent@openssh.com once the peer requested it.
  • Updates wolfSSH_accept() to call the new API instead of embedding the channel-open logic inline.
  • Adjusts agent-channel open behavior to be idempotent and to “publish” the agent even when the open is queued due to WS_WANT_WRITE/WS_WANT_READ.
File summaries
File Description
wolfssh/agent.h Declares the new server-side agent-channel open API and documents intended behavior.
src/ssh.c Switches wolfSSH_accept() to call the new helper API for opening the agent channel.
src/agent.c Implements wolfSSH_AGENT_ChannelOpen() and updates queuing/idempotency behavior around channel open retries.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/agent.c
Comment thread wolfssh/agent.h Outdated

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1230

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/agent.c
Comment thread src/agent.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1230

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/agent.c
Comment thread src/agent.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1230

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/agent.c
The one server-side site that opens auth-agent@openssh.com sits inside
wolfSSH_accept(), so an application driving its own channels cannot
reach it: the session records the request and no channel follows.

- add wolfSSH_AGENT_ChannelOpen(), the same open lifted out of accept(),
  which still calls it
- it reports WS_BAD_ARGUMENT until the peer asks and on a client
  session, and is idempotent after, so an application can poll it
- publish the agent on a queued open too, so a retry after WS_WANT_WRITE
  finds it rather than opening a second channel and leaking the first
- flush what is left of a queued open on the next call, rather than
  reporting a success the peer never saw
- record ssh->error from the send alone, so neither a poll ahead of the
  request nor a failed allocation stops accept() continuing
wolfSSH_AGENT_ChannelOpen() answers a poll on a session that is over
with WS_FATAL_ERROR and WS_DISCONNECT in ssh->error, the shape every
other public sender uses: no channel opened, nothing on the wire,
RFC 4253 section 11.1. wolfSSH_accept() gates the open it drives, so
the new public entry point is the only way in.

- promote SendAfterDisconnect() to WOLFSSH_LOCAL so agent.c uses the
  same helper as every other public sender
- leave an open queued before the disconnect unflushed, the rule
  wolfSSH_shutdown() applies to all but its own disconnect
- keep WS_DISCONNECT in ssh->error at the accept() call site, which
  used to overwrite it with the status the open returns
Comment thread src/agent.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1230

Scan targets checked: wolfssh-bugs, wolfssh-src

Findings: 1
1 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/agent.c
Comment thread src/agent.c
@ejohnstown
ejohnstown requested a review from philljj September 4, 2026 21:45
@ejohnstown ejohnstown assigned wolfSSL-Bot and unassigned ejohnstown Sep 4, 2026

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #1230

Scan targets checked: wolfssh-bugs, wolfssh-src

Fenrir result: Approved ✅

No new issues found in the changed files.

Advisory only — this automated result does not count as a GitHub approval.

@wolfSSL-Fenrir-bot
wolfSSL-Fenrir-bot dismissed stale reviews from themself September 5, 2026 08:57

Fenrir's latest completed scan found no issues; clearing the prior automated change request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants