Terminate at.at() stdin with a trailing newline#69768
Open
ggiesen wants to merge 1 commit into
Open
Conversation
at.at() piped the command to `at` without a trailing newline. Distro-patched `at` on Fedora/RHEL/CentOS (Fedora at-3.2.2-shell.patch, BZ 486844) writes its job delimiter immediately after the last stdin byte, so with no trailing newline the delimiter concatenates onto the final command (e.g. `shutdown -r nowmarcinDELIMITER7f94e9f4`), producing a job that never runs. Append a single newline after building stdin, covering both the tagged and untagged branches. This matches the newline a normal `echo cmd | at now` pipe already sends, so it is benign on Debian/Ubuntu/BSD. Fixes saltstack#58510
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?
at.at()builds the command string it pipes toatviacmd.run(..., stdin=stdin, python_shell=False)but never terminates it with a newline. This PR appends a single trailing newline after the stdin is assembled, covering both the tagged (tag=) and untagged branches in one place.What issues does this PR fix or reference?
Fixes #58510
Previous Behavior
On distributions that ship the Fedora-patched
at(Fedora/RHEL/CentOS; Fedoraat-3.2.2-shell.patch, Red Hat BZ 486844 / BZ 2070450),atwrites its job delimiter withfprintf(fp, "marcinDELIMITER%08lx\n", i)immediately after the last byte of stdin. Because Salt sent no trailing newline, the delimiter concatenated onto the final command, e.g.shutdown -r nowmarcinDELIMITER7f94e9f4, producing an invalid job that silently never executed. Reproduced by the maintainer and by a baresubprocessrepro in the issue thread.New Behavior
A trailing newline is appended to the stdin, so the delimiter lands on its own line and the command runs. This matches the newline a normal
echo cmd | at nowshell pipe already sends, so behaviour is unchanged on Debian/Ubuntu/BSD and on any non-patchedat.Merge requirements satisfied?
changelog/58510.fixed.md)at.at('12:05am', '/sbin/reboot', tag='reboot')), an inverse test asserting the command payload is preserved and not double-newlined (passes with and without the fix), and peripheral coverage of the command-list andrunas/python_shellhandling.[NOTE] Please review Salt's Contributing Guide for best practices.
Commits signed with GPG?: No