Skip to content

fix: run plugin host scripts under sh when the login shell is fish - #1806

Open
ZacharyZcR wants to merge 1 commit into
Termix-SSH:mainfrom
ZacharyZcR:fix/script-shell-fish
Open

ZacharyZcR wants to merge 1 commit into
Termix-SSH:mainfrom
ZacharyZcR:fix/script-shell-fish

Conversation

@ZacharyZcR

Copy link
Copy Markdown
Member

Fixes #1801.

scriptShell() returns the SSH command plugins use to run a script sent on stdin. It was POSIX shell code:

export PATH="$PATH:/usr/sbin:/sbin:/usr/local/sbin"; export …; if [ "$(id -u)" = "0" ]; then exec bash -s; else exec sudo -n env PATH="$PATH" … bash -s; fi

SSH hands that string to the user's login shell. On a host where the login shell is fish (or csh), it fails to parse: fish: Expected end of the statement, but found keyword 'exec'. Every plugin that runs host scripts through it (Samba, Users and others) is affected.

The command is now that same code, quoted with the SDK's shellQuote for sh -c '…'. Any login shell runs it as a single plain command, and fish accepts the '\'' quoting too. Inside the quotes, $PATH and $(id -u) reach sh untouched, so behaviour on bash/zsh hosts is unchanged. passwordSudoScript() uses scriptShell("plain") as its command and is fixed by the same change. The plugin SDK is a host-provided external for plugin backends, so plugins pick this up with the core release without being rebuilt.

Validation: new tests check that every mode is a single sh -c '…' command, which fails before the change, and that the plain shell still runs a script from stdin through sh with the prelude applied. Full suite: 4639 passed, 1 skipped. tsc -b, eslint, prettier and the SDK guide check pass. Not tested against a real fish host.

scriptShell() returned POSIX shell code (if [ ... ]; then exec bash -s; fi)
as the SSH command, which the host hands to the user's login shell. fish and
csh cannot parse it, so plugins such as Samba and Users failed on those
hosts with a syntax error.

The command is now that code quoted for sh -c, which any login shell runs as
a plain command. passwordSudoScript() uses the same command and is fixed
with it.

Fixes Termix-SSH#1801
@termix-triage-bot

Copy link
Copy Markdown

AI review | Needs changes

Wraps the POSIX shell command returned by scriptShell() in sh -c '...' so it executes correctly on hosts with non-POSIX login shells like fish or csh. Adds tests to verify the command format and runtime behavior.

  • major Core PRs should target the current dev-* branch, not main. If no dev-* branch exists yet, ignore this.

Reviewed 6a696b5. AI can be wrong, a maintainer still decides. Comment /termix review to run it again.

This branch has not been deployed

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

Labels

None yet

Projects

Status: Open PRs

Development

Successfully merging this pull request may close these issues.

some plugins not working on fish shell

1 participant