Skip to content

Fix logrotate.set dropping endscript on second script block (#68293)#69424

Open
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68293
Open

Fix logrotate.set dropping endscript on second script block (#68293)#69424
dwoz wants to merge 1 commit into
saltstack:3006.xfrom
dwoz:fix/issue-68293

Conversation

@dwoz

@dwoz dwoz commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fix logrotate.set corrupting stanzas that contain more than one shell
script directive. _parse_conf now recognizes prerotate /
postrotate / firstaction / lastaction / preremove and
captures the body between the directive and its endscript as opaque
multi-line content, instead of treating each shell command as a setting and
collapsing the two endscript terminators into a single dict key.
_dict_to_stanza emits the recovered blocks back with their own
endscript on rewrite.

What issues does this PR fix or reference?

Fixes #68293

Previous Behavior

Calling salt-call logrotate.set <stanza> size 21M against a config that
contained both a prerotate and a postrotate block silently dropped
the endscript terminator from the second block, producing an invalid
logrotate config.

New Behavior

Both script blocks round-trip through logrotate.set with their own
endscript preserved; embedded shell commands no longer leak into the
stanza dict as bogus setting keys.

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

Commits signed with GPG?

Yes

@dwoz dwoz requested a review from a team as a code owner June 12, 2026 00:10
@dwoz dwoz added this to the Sulphur v3006.26 milestone Jun 12, 2026
@dwoz dwoz added the test:full Run the full test suite label Jun 12, 2026
@dwoz dwoz force-pushed the fix/issue-68293 branch from 306647e to 81319af Compare June 14, 2026 02:06
logrotate stanzas may contain more than one shell-script directive
(``prerotate``/``postrotate``/``firstaction``/``lastaction``/``preremove``),
each terminated by its own ``endscript``. ``_parse_conf`` was parsing every
line inside those blocks as an ordinary ``key value`` setting, so the
embedded shell commands became bogus dict keys and the two ``endscript``
terminators collapsed into a single dict entry. When ``logrotate.set``
rewrote the stanza via ``_dict_to_stanza`` only one ``endscript`` was
emitted, leaving the second script block unterminated and the config
invalid.

Recognize the script directives explicitly: collect their body lines as
opaque shell content until ``endscript``, store them under the directive
key as a list, and emit them back as a proper script block (with their own
``endscript``) on rewrite.

Fixes saltstack#68293
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