1580c87
%define distro redhat
1580c87
%define direct_initrc y
1580c87
%define monolithic n
1580c87
%define polname1 targeted
1580c87
%define type1 targeted-mcs
1580c87
%define polname2 strict
1580c87
%define type2 strict-mcs
3e930b8
%define polname3 mls
3e930b8
%define type3 mls
1580c87
%define POLICYVER 20
be926ab
%define POLICYCOREUTILSVER 1.27.27-3
1580c87
%define CHECKPOLICYVER 1.27.17-5
1580c87
Summary: SELinux policy configuration
1580c87
Name: selinux-policy
1a0a256
Version: 2.0.2
1a0a256
Release: 1
1580c87
License: GPL
1580c87
Group: System Environment/Base
1580c87
Source: serefpolicy-%{version}.tgz
1580c87
patch: policy-20051114.patch
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 \
3e930b8
make NAME=%1 TYPE=%{type1} DISTRO=%{distro} DIRECT_INITRC=%3 MONOLITHIC=y DESTDIR=$RPM_BUILD_ROOT install-appconfig \
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/policy/policy.%{POLICYVER} \
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 \
1580c87
%dir %{_sysconfdir}/selinux/%1/modules/active \
1580c87
%config(noreplace) %{_sysconfdir}/selinux/%1/modules/active/seusers \
1580c87
%dir %{_sysconfdir}/selinux/%1/policy/ \
1580c87
%ghost %{_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;\
1580c87
done; 
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
3e930b8
%installCmds %{polname1} %{type1} %{direct_initrc}
1580c87
e568731
# Build strict policy
1580c87
# Commented out because only targeted ref policy currently builds
e568731
# make clean
e568731
# make conf
3e930b8
#%#installCmds %{polname2} %{type2} %{direct_initrc}
3e930b8
e568731
# Build mls policy
3e930b8
make clean
3e930b8
make conf
3e930b8
%installCmds %{polname3} %{type3} n
3e930b8
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
be926ab
%if 0
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} 
1580c87
%relabel %{polname1}
1580c87
1580c87
%triggerpostun %{polname2} -- %{polname2} <= 2.0.0
1580c87
%{rebuildpolicy} %{polname2} 
1580c87
1580c87
%files %{polname2}
1580c87
#%#fileList %{polname2}
be926ab
%endif
3e930b8
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} 
3e930b8
%relabel %{polname1}
3e930b8
3e930b8
%triggerpostun %{polname3} -- %{polname3} <= 2.0.0
3e930b8
%{rebuildpolicy} %{polname3} 
3e930b8
3e930b8
%files %{polname3}
3e930b8
%fileList %{polname3}
3e930b8
3e930b8
1580c87
%changelog
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