Skip to content

v0.7.0 - Critical Bug Fix for Sudo Operations

Choose a tag to compare

@elazar elazar released this 01 Nov 14:25
· 12 commits to main since this release

What's Fixed

This is a critical bug fix release that resolves issues preventing sudo operations from working correctly.

Critical Fixes

  • PyInfra argument handling bug - The connector now correctly checks for PyInfra's underscore-prefixed arguments (_sudo, _sudo_user) in addition to non-prefixed versions
  • Single-bit StringCommand sudo wrapping - Fixed "command not found" errors when using sudo with complex shell commands containing operators like ||, &&, pipes, or timeout

Impact

v0.6.0 was broken - All sudo operations would fail because:

  1. PyInfra passes _sudo=True but the connector only checked for sudo
  2. Single-bit commands with shell operators would fail with "command not found"

v0.7.0 fixes both issues - All sudo operations now work correctly with PyInfra.

Affected Methods (All Fixed)

  • run_shell_command() - Now checks both _sudo/sudo and _sudo_user/sudo_user
  • put_file() - Now checks both _sudo/sudo and _sudo_user/sudo_user
  • get_file() - Now checks both _sudo/sudo and _sudo_user/sudo_user

Installation

pip install pyinfra-orbstack==0.7.0
# or
uv pip install pyinfra-orbstack==0.7.0

Technical Details

Bug #1: Underscore-Prefixed Arguments

PyInfra's convention is to pass operation arguments with underscore prefixes:

# PyInfra passes:
arguments = {'_sudo': True, '_sudo_user': 'postgres'}

# v0.6.0 only checked:
sudo = arguments.get("sudo", False)  # Would always be False!

# v0.7.0 correctly checks both:
sudo = arguments.get("sudo", arguments.get("_sudo", False))

Bug #2: Single-Bit StringCommand Wrapping

Complex commands like timeout 60 bash -c '...' || true would fail with "command not found" because:

v0.6.0 (broken):

bits = ["timeout 60 bash -c '...' || true"]
bits = ["sudo", "-H"] + bits  # Now 2 elements
cmd.extend(bits)  # Result: sudo -H "complex || command" ❌

v0.7.0 (fixed):

bits = ["timeout 60 bash -c '...' || true"]
if len(bits) == 1:  # Check BEFORE adding sudo
    quoted = shlex.quote(bits[0])
    cmd.extend(["sh", "-c", f"sudo -H sh -c {quoted}"])  # ✅