Bug 999584

Summary: Packaged policy modules need a way to determine the selinux-policy version number
Product: [Fedora] Fedora Reporter: Juan Orti <jorti>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: bgilbert, dominick.grift, dwalsh, mgrepl, paul, rjones
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-30 01:32:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1005864, 1014408, 1020292    

Description Juan Orti 2013-08-21 15:45:26 UTC
Description of problem:
As described here: https://fedoraproject.org/wiki/SELinux_Policy_Modules_Packaging_Draft#Runtime_Dependencies , when packaging a policy module, you need to specify the version of selinux-policy used to compile it. The hack to extract the selinux-policy version doesn't work any more, because unversioned doc dirs in F20, and querying the rpm database is unreliable in chroots.

See this thread for more information:
https://lists.fedoraproject.org/pipermail/devel/2013-August/188070.html

What is requested here is a way to be able to determine the version of the selinux-policy package. It can be done placing a file with the version number, as explained in this mail: https://lists.fedoraproject.org/pipermail/devel/2013-August/188089.html

Comment 1 Paul Howarth 2013-08-21 18:49:08 UTC
A cute fix that would make the existing hack keep working would be to append a specially-formatted comment to /usr/share/selinux/devel/policyhelp, e.g.:

xdg-open file:///usr/share/doc/selinux-policy/html/index.html # /selinux-policy-%{version}/

Comment 2 Richard W.M. Jones 2013-08-23 13:36:46 UTC
A follow-on comment on the original thread suggests a better way:

  [D]rop it into /usr/lib/rpm/macros.d so it can
  be used even easier in specfiles, something like 

  echo '%%_selinux_policy_version %{version}' > \
      $RPM_BUILD_ROOT%{_rpmconfigdir}/macros.d/selinux-policy.macros

Comment 3 Paul Howarth 2013-09-02 13:30:36 UTC
(In reply to Richard W.M. Jones from comment #2)
> A follow-on comment on the original thread suggests a better way:
> 
>   [D]rop it into /usr/lib/rpm/macros.d so it can
>   be used even easier in specfiles, something like 
> 
>   echo '%%_selinux_policy_version %{version}' > \
>       $RPM_BUILD_ROOT%{_rpmconfigdir}/macros.d/selinux-policy.macros

I like this too.

Comment 4 Daniel Walsh 2013-09-04 19:08:17 UTC
Fixed in selinux-policy-3.12.1-76.fc20.noarch

Added
mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d
echo '%%_selinux_policy_version %{version}-%{release}' > %{buildroot}%{_rpmconfigdir}/macros.d/selinux-policy.macros

 cat /usr/lib/rpm/macros.d/selinux-policy.macros 
%_selinux_policy_version 3.12.1-76

Comment 5 Paul Howarth 2013-09-09 10:00:09 UTC
(In reply to Daniel Walsh from comment #4)
> Fixed in selinux-policy-3.12.1-76.fc20.noarch
> 
> Added
> mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d
> echo '%%_selinux_policy_version %{version}-%{release}' >
> %{buildroot}%{_rpmconfigdir}/macros.d/selinux-policy.macros
> 
>  cat /usr/lib/rpm/macros.d/selinux-policy.macros 
> %_selinux_policy_version 3.12.1-76

This doesn't work; I think the filename needs to start with "macros":

# rpm --eval '%_selinux_policy_version'
%_selinux_policy_version
# ls -l /usr/lib/rpm/macros.d
total 16
-rw-r--r--. 1 root root 2309 Sep  6 06:55 macros.systemd
-rw-r--r--. 1 root root   40 Sep  5 14:57 selinux-policy.macros
# cp /usr/lib/rpm/macros.d/selinux-policy.macros /usr/lib/rpm/macros.d/macros.selinux-policy
# rpm --eval '%_selinux_policy_version'
3.12.1-76.fc21

Comment 6 Paul Howarth 2013-09-17 11:04:44 UTC
This is fixed in -79 in Rawhide but I don't see any selinux-policy updates for F-20 in bodhi.

I manually downloaded -80 for F-20 from koji and that worked for me.

Comment 7 Fedora Update System 2013-09-25 20:39:49 UTC
selinux-policy-3.12.1-83.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/selinux-policy-3.12.1-83.fc20

Comment 8 Fedora Update System 2013-09-27 00:43:21 UTC
Package selinux-policy-3.12.1-83.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.12.1-83.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-17722/selinux-policy-3.12.1-83.fc20
then log in and leave karma (feedback).

Comment 9 Fedora Update System 2013-10-02 06:43:24 UTC
Package selinux-policy-3.12.1-84.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.12.1-84.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-17722/selinux-policy-3.12.1-84.fc20
then log in and leave karma (feedback).

Comment 10 Fedora End Of Life 2015-05-29 09:20:27 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 11 Richard W.M. Jones 2015-05-29 09:27:59 UTC
This seems to be fixed in at least Fedora 21 and up:

$ cat /usr/lib/rpm/macros.d/macros.selinux-policy 
%_selinux_policy_version 3.13.1-116.fc23

Comment 12 Fedora End Of Life 2015-06-30 01:32:39 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.