Skip to content

fix(connectors.ssh): invoke shell properly for "Match exec" - #2124

Open
lotheac wants to merge 1 commit into
pyinfra-dev:3.xfrom
lotheac:push-tnqlptrrquks
Open

lotheac wants to merge 1 commit into
pyinfra-dev:3.xfrom
lotheac:push-tnqlptrrquks

Conversation

@lotheac

@lotheac lotheac commented Nov 30, 2026 •

Copy link
Copy Markdown

FakeInvoke was running "Match exec" commands like [os.environ["SHELL"], cmd], but that invocation needs a -c to work: otherwise a config with eg. "Match exec true" hits errors like this (depending on $SHELL):

/bin/sh: line 0: can't open true: no such file

delegate invoking the shell to gevent.subprocess with shell=True (but have it use SHELL from environment, since openssh does that too)

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)
  • Pull request title follows the
    conventional commits format

@wowi42 wowi42 added bug Label for all kind of bugs. connectors Connector issues - builtin integrations with other tools. operations Issues with operations. labels Nov 30, 2026

@wowi42 wowi42 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The -c fix is needed, but this version bypasses the user's configured shell. I left the blocker inline.

FakeInvoke was running "Match exec" commands like [os.environ["SHELL"],
cmd], but that invocation needs a `-c` to work: otherwise a config with
eg. "Match exec true" hits errors like this (depending on $SHELL):

	/bin/sh: line 0: can't open true: no such file

delegate invoking the shell to gevent.subprocess with shell=True (but
have it use SHELL from environment, since openssh does that too)

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

bug Label for all kind of bugs. connectors Connector issues - builtin integrations with other tools. operations Issues with operations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants