Skip to content

profile: only run resize on interactive non-SSH logins (WinSCP fix) - #143

Merged
mcfbytes merged 1 commit into
masterfrom
fix/profile-resize-ssh
Sep 4, 2026
Merged

profile: only run resize on interactive non-SSH logins (WinSCP fix)#143
mcfbytes merged 1 commit into
masterfrom
fix/profile-resize-ssh

Conversation

@mcfbytes

@mcfbytes mcfbytes commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Fixes #142 — forum report: https://misterfpga.org/viewtopic.php?p=113698#p113698 (WinSCP could not open a shell window on v2026.09.02-beta; PuTTY was fine).

What

One-line guard in the rootfs overlay's /etc/profile:

[ "$PS1" ] && [ -z "$SSH_CONNECTION" ] && resize >/dev/null

plus an explanatory comment in the file and a second documented deviation in the /etc/profile row of docs/init-parity.md.

Why

resize is the BusyBox applet. It writes a cursor-position escape query to stderr and scanfs the reply from stdin with a 3 s alarm. WinSCP's SCP mode and its terminal window open the login shell without a pty, so nothing answers: the escape bytes hit WinSCP's stderr and WinSCP's first command is eaten as the "reply". WinSCP reports Error skipping startup message. Your shell is probably incompatible with the application.

Over SSH resize is redundant anyway (sshd propagates the client's window size through the pty). It only does real work on the serial console, which the guard preserves. SSH_CONNECTION is used rather than SSH_TTY because sshd sets it for every session, pty or not; a first attempt with SSH_TTY did not fix WinSCP.

Stock parity

Stock has the identical line and the identical BusyBox applet (checked on release_20250402's linux.img; its own armhf busybox run under qemu-arm on a pty emits the same bytes and swallows the next input line). So this is inherited, and the change is recorded as a deliberate deviation.

Verification (on a DE10-nano running 260902, change applied live)

  • ssh -T no-pty login shell, two commands fed: both echo back, no escape bytes (before: escape bytes, first command lost).
  • ssh -tt pty login shell: clean prompt.
  • bash -l as login shell, no pty: clean.
  • Simulated console login (interactive, SSH vars cleared): resize still runs.
  • Plain scp and sftp unchanged.

Not touched: root's login shell stays BusyBox sh (stock uses bash); it is not part of this failure.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vq3yLoYntjiJ1wUaAdruLU

Stock's /etc/profile ends with a bare `resize >/dev/null`. That is the
BusyBox applet: it writes a cursor-position query to stderr and reads the
terminal's reply from stdin under a 3 s alarm. Clients that open the login
shell without a pty (WinSCP's SCP mode and its terminal window) get the
escape bytes on stderr and lose their first command to resize's scanf,
which WinSCP surfaces as "Error skipping startup message. Your shell is
probably incompatible with the application". SFTP, PuTTY and command-line
scp were unaffected. Reported on the forum against v2026.09.02-beta:
https://misterfpga.org/viewtopic.php?p=113698#p113698

Stock has the identical defect (verified on release_20250402's linux.img
by running its own busybox under qemu-arm on a pty). Deliberate deviation:
guard the call so it only runs for an interactive shell outside SSH, i.e.
the serial console, the one place nothing else reports the window size.
SSH_CONNECTION rather than SSH_TTY because sshd sets it for every session,
pty or not.

Verified on a board: no-pty login shell, pty login shell and `bash -l`
are clean; a simulated console login still runs resize.

Fixes #142

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vq3yLoYntjiJ1wUaAdruLU
Copilot AI lite review requested due to automatic review settings September 3, 2026 14:51

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.

🟢 Approval recommended

The change is a minimal, well-scoped guard in /etc/profile with corresponding documentation, and it directly addresses the confirmed no-PTY SSH failure mode without affecting console behavior.

Pull request overview

This PR fixes WinSCP SCP-mode / “Open Terminal” failures by preventing BusyBox resize from running in SSH sessions where no PTY is allocated (which causes escape bytes on stderr and consumes the first stdin line). The change is implemented in the rootfs overlay’s /etc/profile and documented as an additional intentional stock deviation in docs/init-parity.md.

Changes:

  • Guard /etc/profile’s trailing resize so it runs only for interactive, non-SSH logins ([ "$PS1" ] && [ -z "$SSH_CONNECTION" ]).
  • Add an explanatory comment in /etc/profile describing the WinSCP no-PTY failure mode and rationale.
  • Update docs/init-parity.md to record the new /etc/profile deviation (now 2 deviations).
File summaries
File Description
board/mister/de10nano/rootfs-overlay/etc/profile Adds a guard and documentation to avoid running resize in SSH/no-PTY sessions (WinSCP fix) while preserving serial-console behavior.
docs/init-parity.md Updates the /etc/profile parity row to document the new intentional deviation from stock.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

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.

🟢 Approval recommended

The focused guard addresses the reported failure and is consistent with the documented verification.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@mcfbytes
mcfbytes merged commit 8115a32 into master Sep 4, 2026
8 checks passed
@mcfbytes
mcfbytes deleted the fix/profile-resize-ssh branch September 4, 2026 01:03
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.

WinSCP SCP mode / terminal fails: /etc/profile runs BusyBox resize on non-tty SSH logins

2 participants