1header_comment_section="""\ 2# vim: sw=4:ts=4:et 3""" 4 5base_section="""\ 6 7%define selinux_policyver VERSION 8 9Name: MODULENAME_selinux 10Version: 1.0 11Release: 1%{?dist} 12Summary: SELinux policy module for MODULENAME 13 14Group: System Environment/Base 15License: GPLv2+ 16# This is an example. You will need to change it. 17URL: http://HOSTNAME 18Source0: MODULENAME.pp 19Source1: MODULENAME.if 20Source2: DOMAINNAME_selinux.8 21Source3: DOMAINNAME_u 22 23Requires: policycoreutils, libselinux-utils 24Requires(post): selinux-policy-base >= %{selinux_policyver}, policycoreutils 25Requires(postun): policycoreutils 26""" 27 28mid_section="""\ 29BuildArch: noarch 30 31%description 32This package installs and sets up the SELinux policy security module for MODULENAME. 33 34%install 35install -d %{buildroot}%{_datadir}/selinux/packages 36install -m 644 %{SOURCE0} %{buildroot}%{_datadir}/selinux/packages 37install -d %{buildroot}%{_datadir}/selinux/devel/include/contrib 38install -m 644 %{SOURCE1} %{buildroot}%{_datadir}/selinux/devel/include/contrib/ 39install -d %{buildroot}%{_mandir}/man8/ 40install -m 644 %{SOURCE2} %{buildroot}%{_mandir}/man8/DOMAINNAME_selinux.8 41install -d %{buildroot}/etc/selinux/targeted/contexts/users/ 42install -m 644 %{SOURCE3} %{buildroot}/etc/selinux/targeted/contexts/users/DOMAINNAME_u 43 44%post 45semodule -n -i %{_datadir}/selinux/packages/MODULENAME.pp 46if /usr/sbin/selinuxenabled ; then 47 /usr/sbin/load_policy 48 %relabel_files 49 /usr/sbin/semanage user -a -R DOMAINNAME_r DOMAINNAME_u 50fi; 51exit 0 52 53%postun 54if [ $1 -eq 0 ]; then 55 semodule -n -r MODULENAME 56 if /usr/sbin/selinuxenabled ; then 57 /usr/sbin/load_policy 58 %relabel_files 59 /usr/sbin/semanage user -d DOMAINNAME_u 60 fi; 61fi; 62exit 0 63 64%files 65%attr(0600,root,root) %{_datadir}/selinux/packages/MODULENAME.pp 66%{_datadir}/selinux/devel/include/contrib/MODULENAME.if 67%{_mandir}/man8/DOMAINNAME_selinux.8.* 68/etc/selinux/targeted/contexts/users/DOMAINNAME_u 69 70%changelog 71* TODAYSDATE YOUR NAME <YOUR@EMAILADDRESS> 1.0-1 72- Initial version 73 74""" 75 76define_relabel_files_begin ="""\ 77\n 78%define relabel_files() \\ 79""" 80 81define_relabel_files_end ="""\ 82restorecon -R FILENAME; \\ 83""" 84