1580c87
%define distro redhat
1580c87
%define direct_initrc y
1580c87
%define monolithic n
1580c87
%define polname1 targeted
d77f56b
%define polname2 mls
d77f56b
%define polname3 strict
1580c87
%define POLICYVER 20
765f818
%define POLICYCOREUTILSVER 1.27.28-3
765f818
%define CHECKPOLICYVER 1.27.17-7
1580c87
Summary: SELinux policy configuration
1580c87
Name: selinux-policy
a033620
Version: 2.0.6
a033620
Release: 1
1580c87
License: GPL
1580c87
Group: System Environment/Base
1580c87
Source: serefpolicy-%{version}.tgz
1580c87
patch: policy-20051114.patch
d77f56b
Source1: modules-%{polname1}.conf
d77f56b
Source2: booleans-%{polname1}.conf
d77f56b
Source3: seusers-%{polname1}
d77f56b
Source4: setrans-%{polname1}.conf
d77f56b
Source5: modules-%{polname2}.conf
d77f56b
Source6: booleans-%{polname2}.conf
d77f56b
Source7: seusers-%{polname2}
d77f56b
Source8: setrans-%{polname2}.conf
3e930b8
1580c87
Url: http://serefpolicy.sourceforge.net
1580c87
BuildRoot: %{_tmppath}/serefpolicy-buildroot
1580c87
BuildArch: noarch
1580c87
BuildRequires: checkpolicy >= %{CHECKPOLICYVER} m4 policycoreutils >= %{POLICYCOREUTILSVER}
1580c87
Requires: policycoreutils >= %{POLICYCOREUTILSVER}
1580c87
Obsoletes: policy 
1580c87
46e7261
%package %{polname1}
46e7261
Summary: SELinux %{polname1} base policy
46e7261
Group: System Environment/Base
46e7261
Provides: selinux-policy-base
46e7261
Obsoletes: selinux-policy-%{polname1}-sources
46e7261
46e7261
%description %{polname1}
46e7261
SELinux Reference policy targeted base module.
46e7261
1580c87
%define installCmds() \
3e930b8
cp -f ${RPM_SOURCE_DIR}/modules-%1.conf  ./policy/modules.conf \
3e930b8
cp -f ${RPM_SOURCE_DIR}/booleans-%1.conf ./policy/booleans.conf \
3e930b8
make NAME=%1 TYPE=%2 DISTRO=%{distro} DIRECT_INITRC=%3 MONOLITHIC=%{monolithic} base.pp \
3e930b8
make NAME=%1 TYPE=%2 DISTRO=%{distro} DIRECT_INITRC=%3 MONOLITHIC=%{monolithic} modules \
1580c87
%{__mkdir} -p $RPM_BUILD_ROOT/%{_usr}/share/selinux/%1/ \
1580c87
%{__cp} *.pp $RPM_BUILD_ROOT/%{_usr}/share/selinux/%1/ \
1580c87
%{__mkdir} -p $RPM_BUILD_ROOT/%{_sysconfdir}/selinux/%1/policy \
1580c87
%{__mkdir} -p $RPM_BUILD_ROOT/%{_sysconfdir}/selinux/%1/modules/active \
1580c87
%{__mkdir} -p $RPM_BUILD_ROOT/%{_sysconfdir}/selinux/%1/contexts/files \
d77f56b
make NAME=%1 TYPE=%2 DISTRO=%{distro} DIRECT_INITRC=%3 MONOLITHIC=y DESTDIR=$RPM_BUILD_ROOT install-appconfig \
598be15
semodule_expand $RPM_BUILD_ROOT/usr/share/selinux/%1/base.pp $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/policy/policy.%{POLICYVER} \
1580c87
rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/booleans \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/config \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/seusers \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/contexts/files/file_contexts \
1580c87
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/contexts/files/homedir_template \
3e930b8
touch $RPM_BUILD_ROOT%{_sysconfdir}/selinux/%1/contexts/files/file_contexts.homedirs \
3e930b8
install -m0644 ${RPM_SOURCE_DIR}/seusers-%1 ${RPM_BUILD_ROOT}%{_sysconfdir}/selinux/%1/modules/active/seusers \
3e930b8
install -m0644 ${RPM_SOURCE_DIR}/setrans-%1.conf ${RPM_BUILD_ROOT}%{_sysconfdir}/selinux/%1/setrans.conf \
3e930b8
%nil
1580c87
1580c87
%define fileList() \
1580c87
%defattr(-,root,root) \
1580c87
%dir %{_usr}/share/selinux \
1580c87
%dir %{_usr}/share/selinux/%1 \
1580c87
%config %{_usr}/share/selinux/%1/base.pp \
1580c87
%dir %{_sysconfdir}/selinux \
1580c87
%ghost %config(noreplace) %{_sysconfdir}/selinux/config \
1580c87
%dir %{_sysconfdir}/selinux/%1 \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/setrans.conf \
1580c87
%ghost %{_sysconfdir}/selinux/%1/seusers \
1580c87
%dir %{_sysconfdir}/selinux/%1/modules \
21dea1c
%attr(700,root,root) %dir %{_sysconfdir}/selinux/%1/modules/active \
21dea1c
%verify(not md5 size mtime) %attr(600,root,root) %config(noreplace) %{_sysconfdir}/selinux/%1/modules/active/seusers \
1580c87
%dir %{_sysconfdir}/selinux/%1/policy/ \
21dea1c
%verify(not md5 size mtime) %attr(600,root,root) %config(noreplace) %{_sysconfdir}/selinux/%1/policy/policy.%{POLICYVER} \
1580c87
%dir %{_sysconfdir}/selinux/%1/contexts \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/customizable_types \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/dbus_contexts \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/default_contexts \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/default_type \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/failsafe_context \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/initrc_context \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/removable_context \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/contexts/userhelper_context \
1580c87
%dir %{_sysconfdir}/selinux/%1/contexts/files \
1580c87
%ghost %config %{_sysconfdir}/selinux/%1/contexts/files/file_contexts \
1580c87
%ghost %config %{_sysconfdir}/selinux/%1/contexts/files/homedir_template \
1580c87
%ghost %config %{_sysconfdir}/selinux/%1/contexts/files/file_contexts.homedirs \
1580c87
%config %{_sysconfdir}/selinux/%1/contexts/files/media
1580c87
1580c87
%define saveFileContext() \
1580c87
. %{_sysconfdir}/selinux/config; \
1580c87
FILE_CONTEXT=%{_sysconfdir}/selinux/%1/contexts/files/file_contexts; \
1580c87
if [ "${SELINUXTYPE}" == %1 -a -f ${FILE_CONTEXT} ]; then \
1580c87
	cp -f ${FILE_CONTEXT} ${FILE_CONTEXT}.pre; \
1580c87
fi 
1580c87
1580c87
%define rebuildpolicy() \
1580c87
semodule -b /usr/share/selinux/%1/base.pp -s %1 \
1580c87
for file in $(ls /usr/share/selinux/%1 | grep -v base.pp) \
1580c87
do \
1580c87
	semodule -i /usr/share/selinux/%1/$file -s %1;\
598be15
done; \
598be15
rm -f %{_sysconfdir}/selinux/%1/policy/policy.*.rpmnew
1580c87
1580c87
%define relabel() \
1580c87
. %{_sysconfdir}/selinux/config; \
1580c87
FILE_CONTEXT=%{_sysconfdir}/selinux/%1/contexts/files/file_contexts; \
1580c87
if [ "${SELINUXTYPE}" == %1 -a -f ${FILE_CONTEXT}.pre ]; then \
1580c87
	fixfiles -C ${FILE_CONTEXT}.pre restore; \
1580c87
	rm -f ${FILE_CONTEXT}.pre; \
1580c87
fi; 
1580c87
1580c87
%description
1580c87
SELinux Reference Policy - modular.
1580c87
3e930b8
%prep 
1580c87
%setup -q -n serefpolicy-%{version}
3e930b8
%patch0 -p1 
3e930b8
	
1580c87
%install
e568731
e568731
# Build targeted policy
3e930b8
make conf
1580c87
%{__rm} -fR $RPM_BUILD_ROOT
d77f56b
%installCmds %{polname1} targeted-mcs %{direct_initrc}
3e930b8
e568731
# Build mls policy
3e930b8
make clean
3e930b8
make conf
d77f56b
%installCmds %{polname2} strict-mls n
d77f56b
3e930b8
d77f56b
# Build strict policy
d77f56b
# Commented out because only targeted ref policy currently builds
d77f56b
# make clean
d77f56b
# make conf
d77f56b
#%#installCmds %{polname3} strict-mcs %{direct_initrc}
1580c87
1580c87
%clean
1580c87
%{__rm} -fR $RPM_BUILD_ROOT
1580c87
af60908
%files %{polname1}
af60908
%fileList %{polname1}
af60908
af60908
%pre %{polname1}
af60908
%saveFileContext %{polname1}
af60908
af60908
%post %{polname1}
af60908
if [ ! -s /etc/selinux/config ]; then
af60908
	#
af60908
	#	New install so we will default to targeted policy
af60908
	#
af60908
	echo "
af60908
# This file controls the state of SELinux on the system.
af60908
# SELINUX= can take one of these three values:
af60908
#	enforcing - SELinux security policy is enforced.
af60908
#	permissive - SELinux prints warnings instead of enforcing.
af60908
#	disabled - No SELinux policy is loaded.
af60908
SELINUX=enforcing
af60908
# SELINUXTYPE= can take one of these two values:
af60908
#	targeted - Only targeted network daemons are protected.
af60908
#	strict - Full SELinux protection.
af60908
#	mls - Multi Level Security protection.
af60908
SELINUXTYPE=targeted 
af60908
# SETLOCALDEFS= Check local definition changes
af60908
SETLOCALDEFS=0 
af60908
af60908
" > /etc/selinux/config
af60908
af60908
	ln -sf /etc/selinux/config /etc/sysconfig/selinux 
af60908
	restorecon /etc/selinux/config 2> /dev/null
af60908
else
af60908
	# if first time update booleans.local needs to be copied to sandbox
af60908
	[ -f /etc/selinux/%{polname1}/booleans.local ] && mv /etc/selinux/%{polname1}/booleans.local /etc/selinux/%{polname1}/modules/active/
af60908
	[ -f /etc/selinux/%{polname1}/seusers ] && cp -f /etc/selinux/%{polname1}/seusers /etc/selinux/%{polname1}/modules/active/seusers
af60908
	grep -q "^SETLOCALDEFS" /etc/selinux/config || echo -n "
af60908
# SETLOCALDEFS= Check local definition changes
af60908
SETLOCALDEFS=0 
af60908
">> /etc/selinux/config
af60908
fi
af60908
%rebuildpolicy %{polname1}
af60908
%relabel %{polname1}
af60908
af60908
%triggerpostun %{polname1} -- selinux-policy-%{polname1} <= 2.0.0
af60908
%rebuildpolicy %{polname1}
af60908
1580c87
%package %{polname2} 
1580c87
Summary: SELinux %{polname2} base policy
1580c87
Group: System Environment/Base
1580c87
Provides: selinux-policy-base
be926ab
Obsoletes: selinux-policy-%{polname2}-sources
1580c87
1580c87
%description %{polname2} 
1580c87
SELinux Reference policy %{polname2} base module.
1580c87
1580c87
%pre %{polname2} 
1580c87
%saveFileContext %{polname2}
1580c87
1580c87
%post %{polname2} 
1580c87
%rebuildpolicy %{polname2} 
d77f56b
%relabel %{polname2}
1580c87
1580c87
%triggerpostun %{polname2} -- %{polname2} <= 2.0.0
1580c87
%{rebuildpolicy} %{polname2} 
1580c87
1580c87
%files %{polname2}
d77f56b
%fileList %{polname2}
3e930b8
d77f56b
%if 0
3e930b8
%package %{polname3} 
3e930b8
Summary: SELinux %{polname3} base policy
3e930b8
Group: System Environment/Base
3e930b8
Provides: selinux-policy-base
3e930b8
Obsoletes: selinux-policy-%{polname3}-sources
3e930b8
3e930b8
%description %{polname3} 
3e930b8
SELinux Reference policy %{polname3} base module.
3e930b8
3e930b8
%pre %{polname3} 
3e930b8
%saveFileContext %{polname3}
3e930b8
3e930b8
%post %{polname3} 
3e930b8
%rebuildpolicy %{polname3} 
d77f56b
%relabel %{polname3}
3e930b8
3e930b8
%triggerpostun %{polname3} -- %{polname3} <= 2.0.0
3e930b8
%{rebuildpolicy} %{polname3} 
3e930b8
3e930b8
%files %{polname3}
d77f56b
#%#fileList %{polname3}
d77f56b
%endif
3e930b8
3e930b8
1580c87
%changelog
c1b0228
* Wed Nov 23 2003 Dan Walsh <dwalsh@redhat.com> 2.0.5-4
21dea1c
- Cleanup pegasus and named 
21dea1c
- Fix spec file
c1b0228
- Fix up passwd changing applications
21dea1c
e38dc41
* Tue Nov 21 2003 Dan Walsh <dwalsh@redhat.com> 2.0.5-1
e38dc41
-Update to latest from upstream
e38dc41
b33f08f
* Tue Nov 21 2003 Dan Walsh <dwalsh@redhat.com> 2.0.4-1
765f818
- Add rules for pegasus and avahi
765f818
a32f665
* Mon Nov 21 2003 Dan Walsh <dwalsh@redhat.com> 2.0.2-2
a32f665
- Start building MLS Policy
a32f665
1a0a256
* Fri Nov 18 2003 Dan Walsh <dwalsh@redhat.com> 2.0.2-1
1a0a256
- Update to upstream
1a0a256
205d3ff
* Wed Nov 9 2003 Dan Walsh <dwalsh@redhat.com> 2.0.1-2
205d3ff
- Turn on bash
205d3ff
205d3ff
* Wed Nov 9 2003 Dan Walsh <dwalsh@redhat.com> 2.0.1-1
1580c87
- Initial version