-
Notifications
You must be signed in to change notification settings - Fork 11
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
Use semodule -lfull --checksum
instead of the datastore
#81
base: main
Are you sure you want to change the base?
Conversation
thanks I'll review this week (unless someone else is quicker) I think the 8.6 requirement is fine, I'm not aware of anyone using selinuxd on other distros and OCP is using 8.6 these days. |
@bachradsusi are there any plans on having the semodule utilities be actual standalone library components? Currently they all depend on the binaries being there and that's not ideal. I'd much rather have selinuxd make function calls instead of calling binaries that have to exist in the container/OS. That being said, I think this is a good approach. Let's make sure this PR passes the linting and tests. |
Currently, there's no such plan. Back in January I was experiencing with a patch which would allow to configure libsemanage so that it would not exec load_policy, setfiles and sefcontext_compile - SELinuxProject/selinux@3320e44 As it's described in the commit message it's even possible right now but it's kind of a hack and requires a system configuration change. The reason for using exec() on these tools is to allow policy admin to specify transitions to domains which are allowed to manage selinux, e.g. useradd doesn't need to be allowed to use 'load_policy' permission on 'security' class because useradd_t domain is allowed to transition to load_policy_t domain via exec() on /sbin/load_policy |
The patch is obviously incomplete. Please wait with the review. |
796d2c3
to
264b068
Compare
264b068
to
361e709
Compare
btw even version bumpgs trigger CI failures these days, we gotta look into that first I guess: https://github.com/containers/selinuxd/actions/runs/3589427595/jobs/6041847578 |
(in case that wasn't clear, that link is from another PR) |
0335b27
to
428749f
Compare
428749f
to
d1cd201
Compare
} | ||
|
||
if cs != module.Checksum { | ||
http.Error(w, "Installed policy "+module.Name+" does not much policy file "+policyFile, http.StatusNotFound) |
Check warning
Code scanning / CodeQL
Reflected cross-site scripting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is a false positive.
Could you please take a look at failing test and explain me what is wrong? |
The reason makes a lot of sense. I wonder though if it would be possible to specify a macro to make the functionality optional. I understand why it would be a lot easier to maintain and use making binaries like |
I believe this should be already feasible without changing libsemanage. Given that it usually runs in its own image, the image could be built with modified E.g. to avoid exec() on
|
this is already a little tricky since we mount the host's |
I knew I forgot about some important detail. |
@bachradsusi seems to me that the tests themselves is broken which is an issue unrelated to this PR 😕 this is happening also for simple dependency upgrades |
semodule -lfull --checksum
instead of the datastoresemodule -lfull --checksum
instead of the datastore
So it's possible to avoid
|
@bachradsusi can you review #83 so I can merge it and then rebase this PR on top of that? I think #83 will make the tests pass again. |
d1cd201
to
1ad35e5
Compare
Rebased. But if I read #83 correctly, it changes just github actions while tests fail also running |
Hey, sorry for the delay in review. I think the tests are wrong and relied on the DS being there and in particular the first install returning an error from the DS put. Now that doesn't happen, we always get back a mock sha from testhandler.go which always returns the sha so we always think the module was installed already. I'll adjust the tests (hopefully) tomorrow. |
1ad35e5
to
4757ff7
Compare
SELinux userspace release 3.4 introduced a new command line option [-m|--checksum] to `semodule` which adds sha256 checksum of modules to its output. It can be used to check whether the same module is already installed or not. Given that selinuxd installed modules use priority 350 we can use semodule checksum and priority 350 as an indicator whether a module was already installed by selinuxd or not and therefore there's no need to track the state of modules in a separate datastore. `semodule --checksum` is supported since Red Hat Enterprise Linux 8.6 Signed-off-by: Petr Lautrbach <[email protected]>
4757ff7
to
4743d42
Compare
Thanks for the hint. I've fixed The current version is without "Should skip policy installation if it's already installed" as it uses datastore. All other tests passed. |
Great, thank you. I'll try to get to the PR when I'm back from the Christmas break. Sorry about the constant delays - we had several SPO blockers that took way longer to resolve than I expected. |
SELinux userspace release 3.4 introduced a new command line option [-m|--checksum] to
semodule
which adds sha256 checksum of modules to its output. It can be used to check whether the same module is already installed or not. Given that selinuxd installed modules use priority 350 we can use semodule checksum and priority 350 as an indicator whether a module was already installed by selinuxd or not and therefore there's no need to track the state of modules in a separate datastore.semodule --checksum
is supported since Red Hat Enterprise Linux 8.6Signed-off-by: Petr Lautrbach [email protected]