-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] selinux.fcontext_policy_present can fail when the filespec is a regex #65340
Comments
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
I have a similar issue relating to the same change in code. In my case, the new modify logic doesn't take in to account when a filetype is specified. For example, RHEL/CentOS Stream 9 has a default fcontext policy for /dev/log which only applies to symlinks:
Our setup puts a socket file at /dev/log rather than a symlink, so we use the following state to add the correct fcontext, which has been working fine:
But now results in the following error:
|
The proposed fix in #65341 does not work. the line executed in _fcontext_add_or_delete_policy
where filespec is filespec is generated from Problem appears to be egrep and handling the matching
the problem is the '?' - optional or at least once, hence the match is occurring since the grep is matching '/srv/ssl/ldap'
So interesting issue, I am using Centos 9 and am getting different results with grep, grep -E and egrep Either way the problem above is the regex matching is picking off the same due to that '?', and that is why the second value is not working since it matches the first, that is, The error is in the values for name defined by the user. Please consider closing this issue unless there are further details to consider. |
same egrep used inside salt and on the command line
Forced to use /bin/egrep in hacked version with debugger, but same result finding the key named line, perhaps I am not typing correctly something on the command line when I try with /bin/egrep, since it still stands, that '?' is a problem for your regex. And a helping of crow pie, believe I have found the issue, salt needs a pair of quotes, that is,
Because of when I try it on the command line, of course I use quotes for the regex 🤦 , and they are missing in the current Salt. Very simple fix, now to write the tests and changelog. Still worried about the '?' and matching to '/srv/ssl/ldap' but I will brush up on my regex to understand why the ?, and its affect on the grouping for the second name |
closing as PR is merged |
Description
A change introduced in 3006.3 to the selinux module function
_fcontext_add_or_delete_policy
checks for the presence of an existing matching context, and if one is found changes the action from "add" to "modify".In certain corner cases, where regex are used for the filespec, this detection can match other contexts - which then changes the action to "modify", however since the policy does not actually exist, the attempt to modify fails.
Setup
Use a state file
selinux.sls
containing:Steps to Reproduce the behavior
Given the above state file, and neither, fcontext policy already existing,
salt <minion_id> state.sls selinux
will create the first selinux fcontext policy but not the second.Output will be:
Expected behavior
Both states should have succeeded.
Versions Report
salt --versions-report
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)The text was updated successfully, but these errors were encountered: