ad41e9
%global debug_package   %{nil}
ad41e9
ad41e9
# container-selinux
ad41e9
%global git0 https://github.com/projectatomic/%{name}
79ad56
%global commit0 ac032a647ad22bd51ce4e23ce04934647bb6f3f8
ad41e9
%global shortcommit0 %(c=%{commit0}; echo ${c:0:7})
ad41e9
ad41e9
# container-selinux stuff (prefix with ds_ for version/release etc.)
ad41e9
# Some bits borrowed from the openstack-selinux package
ad41e9
%global selinuxtype targeted
ad41e9
%global moduletype services
ad41e9
%global modulenames container
ad41e9
ad41e9
# Usage: _format var format
ad41e9
# Expand 'modulenames' into various formats as needed
ad41e9
# Format must contain '$x' somewhere to do anything useful
ad41e9
%global _format() export %1=""; for x in %{modulenames}; do %1+=%2; %1+=" "; done;
ad41e9
ad41e9
# Relabel files
509769
%global relabel_files() %{_sbindir}/restorecon -R %{_bindir}/*podman* %{_bindir}/*runc* %{_bindir}/*crio %{_bindir}/docker* %{_localstatedir}/run/containerd.sock %{_localstatedir}/run/docker.sock %{_localstatedir}/run/docker.pid %{_sysconfdir}/docker %{_sysconfdir}/crio %{_localstatedir}/log/docker %{_localstatedir}/log/lxc %{_localstatedir}/lock/lxc %{_unitdir}/docker.service %{_unitdir}/docker-containerd.service %{_unitdir}/docker-latest.service %{_unitdir}/docker-latest-containerd.service %{_sysconfdir}/docker %{_libexecdir}/docker* &> /dev/null || :
ad41e9
ad41e9
# Version of SELinux we were using
46055a
%global selinux_policyver 3.13.1-216.el7
ad41e9
ad41e9
Name: container-selinux
ad41e9
Epoch: 2
79ad56
Version: 2.74
79ad56
Release: 1%{?dist}
ad41e9
License: GPLv2
ad41e9
URL: %{git0}
ad41e9
Summary: SELinux policies for container runtimes
ad41e9
Source0: %{git0}/archive/%{commit0}/%{name}-%{shortcommit0}.tar.gz
ad41e9
BuildArch: noarch
ad41e9
BuildRequires: git
ad41e9
BuildRequires: pkgconfig(systemd)
ad41e9
BuildRequires: selinux-policy >= %{selinux_policyver}
ad41e9
BuildRequires: selinux-policy-devel >= %{selinux_policyver}
ad41e9
# RE: rhbz#1195804 - ensure min NVR for selinux-policy
ad41e9
Requires: selinux-policy >= %{selinux_policyver}
ad41e9
Requires(post): selinux-policy-base >= %{selinux_policyver}
ad41e9
Requires(post): selinux-policy-targeted >= %{selinux_policyver}
ad41e9
Requires(post): policycoreutils >= 2.5-11
ad41e9
79ad56
%if 0%{?rhel} > 7 || 0%{?fedora}
ad41e9
Requires(post): policycoreutils-python-utils
ad41e9
%else
ad41e9
Requires(post): policycoreutils-python
ad41e9
%endif
ad41e9
Requires(post): libselinux-utils
807e6b
Requires(post): sed
ad41e9
Obsoletes: %{name} <= 2:1.12.5-14
ad41e9
Obsoletes: docker-selinux <= 2:1.12.4-28
ad41e9
Provides: docker-selinux = %{epoch}:%{version}-%{release}
ad41e9
Provides: docker-engine-selinux = %{epoch}:%{version}-%{release}
ad41e9
ad41e9
%description
ad41e9
SELinux policy modules for use with container runtimes.
ad41e9
ad41e9
%prep
f528e4
%autosetup -Sgit  -n %{name}-%{commit0}
ad41e9
ad41e9
%build
ad41e9
make
ad41e9
ad41e9
%install
ad41e9
# install policy modules
ad41e9
%_format MODULES $x.pp.bz2
ad41e9
install -d %{buildroot}%{_datadir}/selinux/packages
ad41e9
install -d -p %{buildroot}%{_datadir}/selinux/devel/include/services
ad41e9
install -p -m 644 %{modulenames}.if %{buildroot}%{_datadir}/selinux/devel/include/services
ad41e9
install -m 0644 $MODULES %{buildroot}%{_datadir}/selinux/packages
ad41e9
ad41e9
# remove spec file
ad41e9
rm -rf %{name}.spec
ad41e9
ad41e9
%check
ad41e9
ad41e9
%post
ad41e9
# Install all modules in a single transaction
ad41e9
if [ $1 -eq 1 ]; then
ad41e9
    %{_sbindir}/setsebool -P -N virt_use_nfs=1 virt_sandbox_use_all_caps=1
ad41e9
fi
ad41e9
%_format MODULES %{_datadir}/selinux/packages/$x.pp.bz2
ad41e9
%{_sbindir}/semodule -n -s %{selinuxtype} -r container 2> /dev/null
ad41e9
%{_sbindir}/semodule -n -s %{selinuxtype} -d docker 2> /dev/null
ad41e9
%{_sbindir}/semodule -n -s %{selinuxtype} -d gear 2> /dev/null
ad41e9
%{_sbindir}/semodule -n -X 200 -s %{selinuxtype} -i $MODULES > /dev/null
ad41e9
if %{_sbindir}/selinuxenabled ; then
ad41e9
    %{_sbindir}/load_policy
ad41e9
    %relabel_files
ad41e9
    if [ $1 -eq 1 ]; then
ad41e9
	restorecon -R %{_sharedstatedir}/docker &> /dev/null || :
ad41e9
    fi
ad41e9
fi
807e6b
. %{_sysconfdir}/selinux/config
807e6b
sed -e "\|container_file_t|h; \${x;s|container_file_t||;{g;t};a\\" -e "container_file_t" -e "}" -i /etc/selinux/${SELINUXTYPE}/contexts/customizable_types
46055a
matchpathcon -qV %{_sharedstatedir}/containers || restorecon -R %{_sharedstatedir}/containers &> /dev/null || :
ad41e9
ad41e9
%postun
ad41e9
if [ $1 -eq 0 ]; then
ad41e9
%{_sbindir}/semodule -n -r %{modulenames} docker &> /dev/null || :
ad41e9
if %{_sbindir}/selinuxenabled ; then
ad41e9
%{_sbindir}/load_policy
ad41e9
%relabel_files
ad41e9
fi
ad41e9
fi
ad41e9
ad41e9
#define license tag if not already defined
ad41e9
%{!?_licensedir:%global license %doc}
ad41e9
ad41e9
%files
ad41e9
%doc README.md
ad41e9
%{_datadir}/selinux/*
ad41e9
ad41e9
%changelog
79ad56
* Fri Oct 19 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.74-1
79ad56
- Allow containers to setexec themselves
79ad56
79ad56
* Tue Sep 18 2018 Frantisek Kluknavsky <fkluknav@redhat.com> - 2:2.73-3
79ad56
- tweak macro for fedora - applies to rhel8 as well
79ad56
46055a
* Mon Sep 17 2018 Frantisek Kluknavsky <fkluknav@redhat.com> - 2:2.73-2
46055a
- moved changelog entries:
46055a
- Define spc_t as a container_domain, so that container_runtime will transition
46055a
to spc_t even when setup with nosuid.
46055a
- Allow container_runtimes to setattr on callers fifo_files
46055a
- Fix restorecon to not error on missing directory
46055a
46055a
* Thu Sep 6 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.69-3
46055a
- Make sure we pull in the latest selinux-policy
46055a
46055a
* Wed Jul 25 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.69-2
46055a
- Add map support to container-selinux for RHEL 7.5
46055a
- Dontudit attempts to write to kernel_sysctl_t
46055a
807e6b
* Mon Jul 16 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.68-1
807e6b
- Add label for /var/lib/origin
807e6b
- Add customizable_file_t to customizable_types
807e6b
807e6b
* Sun Jul 15 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.67-1
807e6b
- Add policy for container_logreader_t
807e6b
509769
* Thu Jun 14 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.66-1
509769
- Allow dnsmasq to dbus chat with spc_t
509769
509769
* Sun Jun 3 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.64-1
509769
- Allow containers to create all socket classes
509769
509769
* Thu May 24 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.62-1
509769
- Label overlay directories under /var/lib/containers/ correctly
509769
509769
* Mon May 21 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.61-1
509769
- Allow spc_t to load kernel modules from inside of container 
509769
509769
* Mon May 21 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.60-1
509769
- Allow containers to list cgroup directories
509769
- Transition for unconfined_service_t to container_runtime_t when executing container_runtime_exec_t.
509769
509769
* Mon May 21 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.58-2
509769
- Run restorecon /usr/bin/podman in postinstall
509769
509769
* Fri May 18 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.58-1
509769
- Add labels to allow podman to be run from a systemd unit file
509769
509769
* Mon May 7 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.57-1
509769
- Set the version of SELinux policy required to the latest to fix build issues.
509769
509769
* Wed Apr 11 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.56-1
509769
- Allow container_runtime_t to transition to spc_t over unlabeled files
509769
f528e4
* Mon Mar 26 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.55-1
f528e4
    Allow iptables to read container state
f528e4
    Dontaudit attempts from containers to write to /proc/self
f528e4
    Allow spc_t to change attributes on container_runtime_t fifo files
8b216f
f528e4
* Thu Mar 8 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.52-1
f528e4
- Add better support for writing custom selinux policy for customer container domains.
f528e4
f528e4
* Thu Mar 8 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.51-1
f528e4
- Allow shell_exec_t as a container_runtime_t entrypoint
f528e4
f528e4
* Wed Mar 7 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.50-1
f528e4
- Allow bin_t as a container_runtime_t entrypoint
f528e4
f528e4
* Fri Mar 2 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.49-1
f528e4
- Add support for MLS running container runtimes
f528e4
- Add missing allow rules for running systemd in a container
f528e4
f528e4
* Wed Feb 21 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.48-1
f528e4
- Update policy to match master branch
f528e4
- Remove typebounds and replace with nnp_transition and nosuid_transition calls
f528e4
f528e4
* Tue Jan 9 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.41-1
f528e4
- Add support to nnp_transition for container domains
f528e4
- Eliminates need for typebounds.
8b216f
8b216f
* Tue Jan 9 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.40-1
8b216f
- Allow container_runtime_t to use user ttys
8b216f
- Fixes bounds check for container_t
8b216f
8b216f
* Mon Jan 8 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.39-1
8b216f
- Allow container runtimes to use interited terminals.  This helps
8b216f
satisfy the bounds check of container_t versus container_runtime_t.
8b216f
8b216f
* Sat Jan 6 2018 Dan Walsh <dwalsh@fedoraproject.org> - 2.38-1
8b216f
- Allow container runtimes to mmap container_file_t devices
8b216f
- Add labeling for rhel push plugin
8b216f
8b216f
* Tue Dec 12 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.37-1
8b216f
- Allow containers to use inherited ttys
8b216f
- Allow ostree to handle labels under /var/lib/containers/ostree
8b216f
f528e4
* Mon Nov 27 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.36-1
9435f9
- Allow containers to relabelto/from all file types to container_file_t
f528e4
f528e4
* Mon Nov 27 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.35-1
9435f9
- Allow container to map chr_files labeled container_file_t
9435f9
f528e4
* Wed Nov 22 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.34-1
f528e4
- Dontaudit container processes getattr on kernel file systems
f528e4
f528e4
* Sun Nov 19 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.33-1
ad41e9
- Allow containers to read /etc/resolv.conf and /etc/hosts if volume
ad41e9
- mounted into container.
ad41e9
ad41e9
* Wed Nov 8 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.32-1
ad41e9
- Make sure users creating content in /var/lib with right labels
ad41e9
ad41e9
* Thu Oct 26 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.31-1
ad41e9
- Allow the container runtime to dbus chat with dnsmasq
ad41e9
- add dontaudit rules for container trying to write to /proc
ad41e9
f528e4
* Tue Oct 10 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.29-1
f528e4
- Add support for lxcd
f528e4
- Add support for labeling of tmpfs storage created within a container.
f528e4
f528e4
* Mon Oct 9 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.28-1
f528e4
- Allow a container to umount a container_file_t filesystem
f528e4
f528e4
* Fri Sep 22 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.27-1
f528e4
-  Allow container runtimes to work with the netfilter sockets
f528e4
-  Allow container_file_t to be an entrypoint for VM's
f528e4
-  Allow spc_t domains to transition to svirt_t
f528e4
f528e4
* Fri Sep 22 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.24-1
f528e4
-     Make sure container_runtime_t has all access of container_t
ad41e9
f528e4
* Thu Sep 7 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.23-1
f528e4
- Allow container runtimes to create sockets in tmp dirs
ad41e9
f528e4
* Tue Sep 5 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.22-1
f528e4
- Add additonal support for crio labeling.
ad41e9
f528e4
* Mon Aug 14 2017 Troy Dawson <tdawson@redhat.com> - 2.21-3
f528e4
- Fixup spec file conditionals
ad41e9
f528e4
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2:2.21-2
f528e4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
ad41e9
f528e4
* Thu Jul 6 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.21-1
f528e4
- Allow containers to execmod on container_share_t files.
ad41e9
f528e4
* Thu Jul 6 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.20-2
f528e4
- Relabel runc and crio executables
ad41e9
f528e4
* Fri Jun 30 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2.20-1
f528e4
- Allow container processes to getsession
ad41e9
ad41e9
* Wed Jun 14 2017 Lokesh Mandvekar <lsm5@redhat.com> - 2:2.19-2.1
ad41e9
- update release tag to isolate from 7.3
ad41e9
ad41e9
* Wed Jun 14 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2:2.19-1
ad41e9
- Fix mcs transition problem on stdin/stdout/stderr
ad41e9
- Add labels for CRI-O
ad41e9
- Allow containers to use tunnel sockets
ad41e9
ad41e9
* Tue Jun 06 2017 Lokesh Mandvekar <lsm5@redhat.com> - 2:2.15-1.1
ad41e9
- Resolves: #1451289
ad41e9
- rebase to v2.15
ad41e9
- built @origin/RHEL-1.12 commit 583ca40
ad41e9
ad41e9
* Mon Mar 20 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2:2.10-2.1
ad41e9
- Make sure we have a late enough version of policycoreutils
ad41e9
ad41e9
* Mon Mar 6 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2:2.10-1
ad41e9
- Update to the latest container-selinux patch from upstream
ad41e9
- Label files under /usr/libexec/lxc as container_runtime_exec_t
ad41e9
- Give container_t access to XFRM sockets
ad41e9
- Allow spc_t to dbus chat with init system
ad41e9
- Allow containers to read cgroup configuration mounted into a container
ad41e9
ad41e9
* Tue Feb 21 2017 Lokesh Mandvekar <lsm5@redhat.com> - 2:2.9-4
ad41e9
- Resolves: #1425574
ad41e9
- built commit 79a6d70
ad41e9
ad41e9
* Mon Feb 20 2017 Lokesh Mandvekar <lsm5@redhat.com> - 2:2.9-3
ad41e9
- Resolves: #1420591
ad41e9
- built @origin/RHEL-1.12 commit 8f876c4
ad41e9
ad41e9
* Mon Feb 13 2017 Lokesh Mandvekar <lsm5@redhat.com> - 2:2.9-2
ad41e9
- built @origin/RHEL-1.12 commit 33cb78b
ad41e9
ad41e9
* Fri Feb 10 2017 Lokesh Mandvekar <lsm5@redhat.com> - 2:2.8-2
ad41e9
-
ad41e9
ad41e9
* Tue Feb 07 2017 Lokesh Mandvekar <lsm5@redhat.com> - 2:2.7-1
ad41e9
- built origin/RHEL-1.12 commit 21dd37b
ad41e9
ad41e9
* Fri Jan 20 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2:2.4-2
ad41e9
- correct version-release in changelog entries
ad41e9
ad41e9
* Thu Jan 19 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2:2.4-1
ad41e9
- Add typebounds statement for container_t from container_runtime_t
ad41e9
- We should only label runc not runc*
ad41e9
ad41e9
* Tue Jan 17 2017 Dan Walsh <dwalsh@fedoraproject.org> - 2:2.3-1
ad41e9
- Fix labeling on /usr/bin/runc.*
ad41e9
- Add sandbox_net_domain access to container.te
ad41e9
- Remove containers ability to look at /etc content
ad41e9
ad41e9
* Wed Jan 11 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2:2.2-4
ad41e9
- use upstream's RHEL-1.12 branch, commit 56c32da for CentOS 7
ad41e9
ad41e9
* Tue Jan 10 2017 Jonathan Lebon <jlebon@redhat.com> - 2:2.2-3
79ad56
- properly disable docker module in %%post
ad41e9
ad41e9
* Sat Jan 07 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2:2.2-2
ad41e9
- depend on selinux-policy-targeted
ad41e9
- relabel docker-latest* files as well
ad41e9
ad41e9
* Fri Jan 06 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2:2.2-1
ad41e9
- bump to v2.2
ad41e9
- additional labeling for ocid
ad41e9
ad41e9
* Fri Jan 06 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2:2.0-2
ad41e9
- install policy at level 200
ad41e9
- From: Dan Walsh <dwalsh@redhat.com>
ad41e9
ad41e9
* Fri Jan 06 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2:2.0-1
ad41e9
- Resolves: #1406517 - bump to v2.0 (first upload to Fedora as a
ad41e9
standalone package)
ad41e9
- include projectatomic/RHEL-1.12 branch commit for building on centos/rhel
ad41e9
ad41e9
* Mon Dec 19 2016 Lokesh Mandvekar <lsm5@fedoraproject.org> - 2:1.12.4-29
ad41e9
- new package (separated from docker)