Skip to content

Commit 485b8b9

Browse files
patchback[bot]russozclaude
authored
[PR #11812/e2a7dc46 backport][stable-11] sefcontext: flush in-process matchpathcon cache (#11853)
sefcontext: flush in-process matchpathcon cache (#11812) * fix sefcontext: flush in-process matchpathcon cache after changes Fixes #888 * update changelog fragment with PR number and URL --------- (cherry picked from commit e2a7dc4) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 865c96e commit 485b8b9

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bugfixes:
2+
- sefcontext - flush the in-process ``matchpathcon`` cache after applying changes, so
3+
subsequent tasks running in the same process (for example via the Mitogen connection
4+
plugin) see the updated SELinux file context rules instead of stale cached data
5+
(https://github.com/ansible-collections/community.general/issues/888,
6+
https://github.com/ansible-collections/community.general/pull/11812).

plugins/modules/sefcontext.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ def semanage_fcontext_modify(module, result, target, ftype, setype, substitute,
279279
if module._diff and prepared_diff:
280280
result['diff'] = dict(prepared=prepared_diff)
281281

282+
if changed and not module.check_mode:
283+
# Flush the in-process matchpathcon cache
284+
selinux.matchpathcon_fini()
285+
282286
module.exit_json(changed=changed, seuser=seuser, serange=serange, **result)
283287

284288

@@ -322,6 +326,10 @@ def semanage_fcontext_delete(module, result, target, ftype, setype, substitute,
322326
if module._diff and prepared_diff:
323327
result['diff'] = dict(prepared=prepared_diff)
324328

329+
if changed and not module.check_mode:
330+
# Flush the in-process matchpathcon cache
331+
selinux.matchpathcon_fini()
332+
325333
module.exit_json(changed=changed, **result)
326334

327335

0 commit comments

Comments
 (0)