Skip to content

Skip saltutil runner/wheel privilege drop on invalid user (#69833) - #69923

Open
dwoz wants to merge 1 commit into
saltstack:3008.xfrom
dwoz:dwoz/fix/69833-master-user-runas-getpwnam
Open

Skip saltutil runner/wheel privilege drop on invalid user (#69833)#69923
dwoz wants to merge 1 commit into
saltstack:3008.xfrom
dwoz:dwoz/fix/69833-master-user-runas-getpwnam

Conversation

@dwoz

@dwoz dwoz commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Merge-forward of #69609 (landed on 3006.x/3007.x for #69600) plus a regression test for the reactor variant.

state.orchestrate overwrites __opts__["user"] with __user__ -- the reactor stamps "Reactor" there, and sudo-launched salt-run sets "sudo_<login>". Neither is a real UNIX account, so the post-#67716 privilege-drop path crashes in pwd.getpwnam inside chugid:

Failed to run 'queue.insert' as user 'Reactor':
KeyError: "getpwnam(): name not found: 'Reactor'"

_master_user_runas now validates the candidate against the passwd database and returns None when it doesn't resolve, falling back to the historical in-process behavior.

Previous Behavior

saltutil.runner/saltutil.wheel invoked from a reactor-triggered orchestration crash with KeyError from getpwnam("Reactor").

New Behavior

_master_user_runas skips the privilege drop when opts["user"] is not a real system account. Runner/wheel fall back to running in-process (the pre-#67716 behavior).

Merge Requirements Satisfied?

  • Changelog entry (changelog/69833.fixed.md, plus the merge-forwarded changelog/69600.fixed.md).
  • Regression test (test_master_user_runas_reactor_sentinel_returns_none).

Fixes #69833

state.orchestrate overwrites __opts__["user"] with __user__ (the
publishing user, which is either salt.utils.user.get_specific_user() ->
"sudo_<login>" under sudo, or the reactor's "Reactor" sentinel when the
orchestration was triggered by a reactor). The post-saltstack#67716
privilege-drop path in saltutil.runner/saltutil.wheel reads that value
as the runas target and asks chugid to switch to it, which then raises
KeyError from pwd.getpwnam wrapped in CommandExecutionError:

    Failed to run 'cache.grains' as user 'sudo_alice':
    KeyError: "getpwnam(): name not found: 'sudo_alice'"

    Failed to run 'queue.insert' as user 'Reactor':
    KeyError: "getpwnam(): name not found: 'Reactor'"

Validate the candidate against the passwd database in
_master_user_runas and skip the privilege drop when it does not
resolve to a real account, falling back to historical in-process
behavior.

Merge-forward of saltstack#69609 (which landed on 3006.x/3007.x for saltstack#69600) plus
a regression test for the reactor variant.

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

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant