Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Changes how pulp-selinux RPM decides when to run restorecon statements #2839

Merged
merged 1 commit into from Nov 16, 2016

Conversation

dkliban
Copy link
Member

@dkliban dkliban commented Nov 16, 2016

RHEL 7.3 was experiencing an bug that was preventing the pulp-selinux RPM from using semodule -l to
figure out the installed version of pulp-selinux policies during upgrades.

The other change is in relabel.sh. This change fixed version comparison to account for the fact that
2.10.0 is greater than 2.2.0.

closes #2434
https://pulp.plan.io/issues/2424

@mention-bot
Copy link

@dkliban, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bowlofeggs, @jortel and @beav to be potential reviewers.

else
return 1
fi
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bash does the implicit return thing, sorta like ruby, so this can just be

function version_less_than {
# Determines if the version passed in as the first argument is less than the version in the second
# argument.
    [[ $(echo -e $1'\n'$2|sort -V|head -n 1) != $2 ]]
}

oldversion=$(semodule -l | grep pulp-server)
echo ${oldversion:12} > %{_localstatedir}/lib/rpm-state/%{name}/old-version
oldversion=$(rpm -qa pulp-selinux)
echo ${oldversion:13} > %{_localstatedir}/lib/rpm-state/%{name}/old-version
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 971 takes a string that looks like 'pulp-selinux-2.10.0-0.1' and writes just '2.10.0-0.1' to a file called old-verion. This is done before the uninstalling the pulp-selinux package. The content of that file is then used in the post install step as the argument for the relabel.sh script.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank makes sense, thanks

@@ -1,7 +1,13 @@
#!/usr/bin/env bash

function version_less_than {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability can this become:

function version_less_than () {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@bmbouter
Copy link
Member

@dkliban What testing was done with this?

function version_less_than {
# Determines if the version passed in as the first argument is less than the version in the second
# argument.
[[ $(echo -e $1'\n'$2|sort -V|head -n 1) != $2 ]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did several comparisons locally, and I think this statement is exactly what we need.

@dkliban
Copy link
Member Author

dkliban commented Nov 16, 2016

I tested all the lines of code individually. I created a copy of the relabel.sh file, but replaced all the restorecon statements with echo statements. I also checked that the statements that use rpm -qa pulp-selinux produce the correct version string.

I did not build an RPM and try to install it.

Copy link
Member

@bmbouter bmbouter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dkliban this is great work, thanks.

Can you also post a test plan on the bug and send a note to pulp-qe-list identifying that this issue needs manual testing.

Thank you!

RHEL 7.3 was experiencing a bug that was preventing the pulp-selinux RPM from using semodule -l to
figure out the installed version of pulp-selinux policies during upgrades. This patch switched to
using rpm -qa for determining the version of previously installed SELinux policy.

The version comparison logic in relabel.sh only worked for version strings <= 1.9.z. This patch
improves this code to make sure upgrades to 2.10.2 don't accidently run unnecesary restorecon
statements.

closes pulp#2434
https://pulp.plan.io/issues/2424
@dkliban dkliban merged commit 9ae941c into pulp:2.10-dev Nov 16, 2016
@dkliban dkliban deleted the version-comp-restorecon branch November 16, 2016 17:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants