Skip saltutil runner/wheel privilege drop on invalid user (#69600) - #69609
Merged
dwoz merged 1 commit intoJul 1, 2026
Merged
Conversation
state.orchestrate overwrites __opts__["user"] with __user__ (the publishing user, salt.utils.user.get_specific_user(), which returns "sudo_<login>" when salt-run was launched under sudo). 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'" 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. Fixes saltstack#69600
2 tasks
twangboy
approved these changes
Jul 1, 2026
9 tasks
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Make
saltutil.runner/saltutil.wheelskip the master-user privilege dropwhen the configured
useris not a real account on the system, falling backto the historical in-process behavior.
What issues does this PR fix or reference?
Fixes #69600 (regression from #69240 / #67716)
Previous Behavior
Running an orchestration under
sudo-- e.g.-- whose rendered SLS called
salt.saltutil.runner('cache.grains', ...)from Jinja failed with:
state.orchestrateoverwrites__opts__["user"]with__user__(thepublishing user,
salt.utils.user.get_specific_user(), which returns"sudo_<login>"when invoked undersudo). The privilege-drop helperintroduced in #69240 read that value as the runas target and asked
chugidto switch to it, raisingKeyErrorfrompwd.getpwnam.New Behavior
_master_user_runasnow validates the candidate against the passwddatabase and returns
None(skip the drop) when it does not resolve toa real user. Orchestrations launched under
sudotherefore keepworking; the privilege drop still triggers when the master is genuinely
configured to run as a different real user (the case the original fix
intended to cover).
Merge requirements satisfied?
Commits signed with GPG?
No