policycoreutils-2.5-0.1.rc1
Update to upstream rc1 release 2016-01-07
This commit is contained in:
parent
0f840ce127
commit
a269971399
2
.gitignore
vendored
2
.gitignore
vendored
@ -235,3 +235,5 @@ policycoreutils-2.0.83.tgz
|
|||||||
/sepolgen-1.2.1.tar.gz
|
/sepolgen-1.2.1.tar.gz
|
||||||
/sepolgen-1.2.2.tar.gz
|
/sepolgen-1.2.2.tar.gz
|
||||||
/policycoreutils-2.4.tar.gz
|
/policycoreutils-2.4.tar.gz
|
||||||
|
/sepolgen-1.2.3-rc1.tar.gz
|
||||||
|
/policycoreutils-2.5-rc1.tar.gz
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,26 +1,29 @@
|
|||||||
%global libauditver 2.1.3-4
|
%global libauditver 2.1.3-4
|
||||||
%global libsepolver 2.4-1
|
%global libsepolver 2.5-0
|
||||||
%global libsemanagever 2.4-1
|
%global libsemanagever 2.5-0
|
||||||
%global libselinuxver 2.4-1
|
%global libselinuxver 2.5-0
|
||||||
%global sepolgenver 1.2.2
|
%global sepolgenver 1.2.3
|
||||||
|
|
||||||
Summary: SELinux policy core utilities
|
Summary: SELinux policy core utilities
|
||||||
Name: policycoreutils
|
Name: policycoreutils
|
||||||
Version: 2.4
|
Version: 2.5
|
||||||
Release: 21%{?dist}
|
Release: 0.1.rc1%{?dist}
|
||||||
License: GPLv2
|
License: GPLv2
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
# https://github.com/SELinuxProject/selinux/wiki/Releases
|
# https://github.com/SELinuxProject/selinux/wiki/Releases
|
||||||
Source: https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20150202/policycoreutils-2.4.tar.gz
|
Source: https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20160107/policycoreutils-2.5-rc1.tar.gz
|
||||||
Source1:https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20150202/sepolgen-1.2.2.tar.gz
|
Source1:https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/20160107/sepolgen-1.2.3-rc1.tar.gz
|
||||||
URL: http://www.selinuxproject.org
|
URL: http://www.selinuxproject.org
|
||||||
Source2: policycoreutils_man_ru2.tar.bz2
|
Source2: policycoreutils_man_ru2.tar.bz2
|
||||||
Source3: system-config-selinux.png
|
Source3: system-config-selinux.png
|
||||||
Source4: sepolicy-icons.tgz
|
Source4: sepolicy-icons.tgz
|
||||||
# use make-rhat-patches.sh to create following patches from https://github.com/fedora-selinux/selinux/
|
# download https://raw.githubusercontent.com/fedora-selinux/scripts/master/selinux/make-fedora-selinux-patch.sh
|
||||||
# HEAD https://github.com/fedora-selinux/selinux/commit/3f154b2e8e2978ba65afbd224f4bbd64e2374a36
|
# run:
|
||||||
Patch: policycoreutils-rhat.patch
|
# $ VERSION=2.5-rc1 ./make-fedora-selinux-patch.sh policycoreutils
|
||||||
Patch1: sepolgen-rhat.patch
|
# HEAD https://github.com/fedora-selinux/selinux/commit/b1964e0607f28e9c8d6f316497c7e6428e4d3393
|
||||||
|
Patch: policycoreutils-fedora.patch
|
||||||
|
# $ VERSION=1.2.3-rc1 ./make-fedora-selinux-patch.sh sepolgen
|
||||||
|
Patch1: sepolgen-fedora.patch
|
||||||
Patch100: policycoreutils-fix-semanage-python3.patch
|
Patch100: policycoreutils-fix-semanage-python3.patch
|
||||||
Obsoletes: policycoreutils < 2.0.61-2
|
Obsoletes: policycoreutils < 2.0.61-2
|
||||||
Conflicts: filesystem < 3, selinux-policy-base < 3.13.1-138
|
Conflicts: filesystem < 3, selinux-policy-base < 3.13.1-138
|
||||||
@ -29,8 +32,8 @@ Provides: /sbin/restorecon
|
|||||||
|
|
||||||
BuildRequires: pam-devel libcgroup-devel libsepol-static >= %{libsepolver} libsemanage-static >= %{libsemanagever} libselinux-devel >= %{libselinuxver} libcap-devel audit-libs-devel >= %{libauditver} gettext
|
BuildRequires: pam-devel libcgroup-devel libsepol-static >= %{libsepolver} libsemanage-static >= %{libsemanagever} libselinux-devel >= %{libselinuxver} libcap-devel audit-libs-devel >= %{libauditver} gettext
|
||||||
BuildRequires: desktop-file-utils dbus-devel dbus-glib-devel
|
BuildRequires: desktop-file-utils dbus-devel dbus-glib-devel
|
||||||
BuildRequires: python-devel python3-devel setools-devel >= 3.3.7-14
|
BuildRequires: python-devel python3-devel setools-devel >= 3.3.8-10
|
||||||
Requires: utils-linux grep gawk diffutils rpm sed
|
Requires: util-linux grep gawk diffutils rpm sed
|
||||||
Requires: libsepol >= %{libsepolver} coreutils libselinux-utils >= %{libselinuxver}
|
Requires: libsepol >= %{libsepolver} coreutils libselinux-utils >= %{libselinuxver}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -52,20 +55,21 @@ to switch roles.
|
|||||||
%prep
|
%prep
|
||||||
# create selinux/ directory and extract %{SOURCE0} there
|
# create selinux/ directory and extract %{SOURCE0} there
|
||||||
%setup -q -c -n selinux
|
%setup -q -c -n selinux
|
||||||
%patch -p1 -b .policycoreutils-rhat
|
%patch -p0 -b .policycoreutils-fedora
|
||||||
pushd policycoreutils-%{version}
|
pushd policycoreutils-2.5-rc1
|
||||||
%patch100 -p2 -b .semanage-python3
|
%patch100 -p2 -b .semanage-python3
|
||||||
popd
|
popd
|
||||||
|
|
||||||
cp %{SOURCE3} policycoreutils-%{version}/gui/
|
cp %{SOURCE3} policycoreutils-2.5-rc1/gui/
|
||||||
tar -xvf %{SOURCE4} -C policycoreutils-%{version}/
|
tar -xvf %{SOURCE4} -C policycoreutils-2.5-rc1/
|
||||||
# extract {%SOURCE1} in selinux/ directory
|
# extract {%SOURCE1} in selinux/ directory
|
||||||
%setup -T -D -a 1 -n selinux
|
%setup -T -D -a 1 -n selinux
|
||||||
%patch1 -p1 -b .sepolgen-rhat
|
%patch1 -p0 -b .sepolgen-fedora
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
make -C policycoreutils-%{version} LSPP_PRIV=y SBINDIR="%{_sbindir}" LIBDIR="%{_libdir}" CFLAGS="%{optflags} -fPIE" LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now" SEMODULE_PATH="/usr/sbin" all
|
make -C policycoreutils-2.5-rc1 LSPP_PRIV=y SBINDIR="%{_sbindir}" LIBDIR="%{_libdir}" CFLAGS="%{optflags} -fPIE" LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now" SEMODULE_PATH="/usr/sbin" all
|
||||||
make -C sepolgen-%{sepolgenver} SBINDIR="%{_sbindir}" LSPP_PRIV=y LIBDIR="%{_libdir}" CFLAGS="%{optflags} -fPIE" LDFLAGS="-pie -Wl,-z,relro" all
|
make -C sepolgen-1.2.3-rc1 SBINDIR="%{_sbindir}" LSPP_PRIV=y LIBDIR="%{_libdir}" CFLAGS="%{optflags} -fPIE" LDFLAGS="-pie -Wl,-z,relro" all
|
||||||
|
|
||||||
%install
|
%install
|
||||||
mkdir -p %{buildroot}%{_bindir}
|
mkdir -p %{buildroot}%{_bindir}
|
||||||
@ -75,14 +79,14 @@ mkdir -p %{buildroot}%{_mandir}/man5
|
|||||||
mkdir -p %{buildroot}%{_mandir}/man8
|
mkdir -p %{buildroot}%{_mandir}/man8
|
||||||
%{__mkdir} -p %{buildroot}/%{_usr}/share/doc/%{name}/
|
%{__mkdir} -p %{buildroot}/%{_usr}/share/doc/%{name}/
|
||||||
|
|
||||||
make -C policycoreutils-%{version} LSPP_PRIV=y DESTDIR="%{buildroot}" SBINDIR="%{buildroot}%{_sbindir}" LIBDIR="%{buildroot}%{_libdir}" SEMODULE_PATH="/usr/sbin" install
|
make -C policycoreutils-2.5-rc1 LSPP_PRIV=y DESTDIR="%{buildroot}" SBINDIR="%{buildroot}%{_sbindir}" LIBDIR="%{buildroot}%{_libdir}" SEMODULE_PATH="/usr/sbin" install
|
||||||
make -C policycoreutils-%{version} PYTHON=python3 LSPP_PRIV=y DESTDIR="%{buildroot}" SBINDIR="%{buildroot}%{_sbindir}" LIBDIR="%{buildroot}%{_libdir}" SEMODULE_PATH="/usr/sbin" install
|
make -C policycoreutils-2.5-rc1 PYTHON=python3 LSPP_PRIV=y DESTDIR="%{buildroot}" SBINDIR="%{buildroot}%{_sbindir}" LIBDIR="%{buildroot}%{_libdir}" SEMODULE_PATH="/usr/sbin" install
|
||||||
|
|
||||||
# Systemd
|
# Systemd
|
||||||
rm -rf %{buildroot}/%{_sysconfdir}/rc.d/init.d/restorecond
|
rm -rf %{buildroot}/%{_sysconfdir}/rc.d/init.d/restorecond
|
||||||
|
|
||||||
make -C sepolgen-%{sepolgenver} DESTDIR="%{buildroot}" SBINDIR="%{buildroot}%{_sbindir}" LIBDIR="%{buildroot}%{_libdir}" install
|
make -C sepolgen-1.2.3-rc1 DESTDIR="%{buildroot}" SBINDIR="%{buildroot}%{_sbindir}" LIBDIR="%{buildroot}%{_libdir}" install
|
||||||
make -C sepolgen-%{sepolgenver} PYTHON=python3 DESTDIR="%{buildroot}" SBINDIR="%{buildroot}%{_sbindir}" LIBDIR="%{buildroot}%{_libdir}" install
|
make -C sepolgen-1.2.3-rc1 PYTHON=python3 DESTDIR="%{buildroot}" SBINDIR="%{buildroot}%{_sbindir}" LIBDIR="%{buildroot}%{_libdir}" install
|
||||||
|
|
||||||
tar -jxf %{SOURCE2} -C %{buildroot}/
|
tar -jxf %{SOURCE2} -C %{buildroot}/
|
||||||
rm -f %{buildroot}/usr/share/man/ru/man8/genhomedircon.8.gz
|
rm -f %{buildroot}/usr/share/man/ru/man8/genhomedircon.8.gz
|
||||||
@ -371,7 +375,7 @@ fi
|
|||||||
%{_mandir}/ru/man1/secon.1*
|
%{_mandir}/ru/man1/secon.1*
|
||||||
%{_mandir}/man8/genhomedircon.8*
|
%{_mandir}/man8/genhomedircon.8*
|
||||||
%{!?_licensedir:%global license %%doc}
|
%{!?_licensedir:%global license %%doc}
|
||||||
%license policycoreutils-%{version}/COPYING
|
%license policycoreutils-2.5-rc1/COPYING
|
||||||
%doc %{_usr}/share/doc/%{name}
|
%doc %{_usr}/share/doc/%{name}
|
||||||
|
|
||||||
%package restorecond
|
%package restorecond
|
||||||
@ -392,7 +396,7 @@ The policycoreutils-restorecond package contains the restorecond service.
|
|||||||
%{_mandir}/man8/restorecond.8*
|
%{_mandir}/man8/restorecond.8*
|
||||||
%{_mandir}/ru/man8/restorecond.8*
|
%{_mandir}/ru/man8/restorecond.8*
|
||||||
%{!?_licensedir:%global license %%doc}
|
%{!?_licensedir:%global license %%doc}
|
||||||
%license policycoreutils-%{version}/COPYING
|
%license policycoreutils-2.5-rc1/COPYING
|
||||||
|
|
||||||
%post restorecond
|
%post restorecond
|
||||||
%systemd_post restorecond.service
|
%systemd_post restorecond.service
|
||||||
|
332
sepolgen-fedora.patch
Normal file
332
sepolgen-fedora.patch
Normal file
@ -0,0 +1,332 @@
|
|||||||
|
diff --git sepolgen-1.2.3-rc1/ChangeLog sepolgen-1.2.3-rc1/ChangeLog
|
||||||
|
index 57db7a5..fc8f6a0 100644
|
||||||
|
--- sepolgen-1.2.3-rc1/ChangeLog
|
||||||
|
+++ sepolgen-1.2.3-rc1/ChangeLog
|
||||||
|
@@ -1,4 +1,6 @@
|
||||||
|
1.2.3-rc1 2016-01-07
|
||||||
|
+ * Support latest refpolicy interfaces, from Nicolas Iooss.
|
||||||
|
+ * Make sepolgen-ifgen output deterministic with Python>=3.3, from Nicolas Iooss.
|
||||||
|
* Use key function in sort(), from Petr Lautrbach.
|
||||||
|
* Reset line numbers when parsing files, from Nicolas Iooss.
|
||||||
|
* Convert cmp functions to key functions, from Robert Kuska.
|
||||||
|
diff --git sepolgen-1.2.3-rc1/src/sepolgen/access.py sepolgen-1.2.3-rc1/src/sepolgen/access.py
|
||||||
|
index 1f89ecd..7606561 100644
|
||||||
|
--- sepolgen-1.2.3-rc1/src/sepolgen/access.py
|
||||||
|
+++ sepolgen-1.2.3-rc1/src/sepolgen/access.py
|
||||||
|
@@ -90,6 +90,8 @@ class AccessVector(util.Comparison):
|
||||||
|
self.audit_msgs = []
|
||||||
|
self.type = audit2why.TERULE
|
||||||
|
self.data = []
|
||||||
|
+ self.obj_path = None
|
||||||
|
+ self.base_type = None
|
||||||
|
# when implementing __eq__ also __hash__ is needed on py2
|
||||||
|
# if object is muttable __hash__ should be None
|
||||||
|
self.__hash__ = None
|
||||||
|
@@ -128,7 +130,7 @@ class AccessVector(util.Comparison):
|
||||||
|
is represented in a list.
|
||||||
|
"""
|
||||||
|
l = [self.src_type, self.tgt_type, self.obj_class]
|
||||||
|
- l.extend(self.perms)
|
||||||
|
+ l.extend(sorted(self.perms))
|
||||||
|
return l
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
@@ -138,6 +140,29 @@ class AccessVector(util.Comparison):
|
||||||
|
return "allow %s %s:%s %s;" % (self.src_type, self.tgt_type,
|
||||||
|
self.obj_class, self.perms.to_space_str())
|
||||||
|
|
||||||
|
+ def base_file_type(self):
|
||||||
|
+ base_type_array = []
|
||||||
|
+ base_type_array = [self.base_type, self.tgt_type, self.src_type]
|
||||||
|
+ return base_type_array
|
||||||
|
+
|
||||||
|
+ def __cmp__(self, other):
|
||||||
|
+ if self.src_type != other.src_type:
|
||||||
|
+ return cmp(self.src_type, other.src_type)
|
||||||
|
+ if self.tgt_type != other.tgt_type:
|
||||||
|
+ return cmp(self.tgt_type, other.tgt_type)
|
||||||
|
+ if self.obj_class != self.obj_class:
|
||||||
|
+ return cmp(self.obj_class, other.obj_class)
|
||||||
|
+ if len(self.perms) != len(other.perms):
|
||||||
|
+ return cmp(len(self.perms), len(other.perms))
|
||||||
|
+ x = list(self.perms)
|
||||||
|
+ x.sort()
|
||||||
|
+ y = list(other.perms)
|
||||||
|
+ y.sort()
|
||||||
|
+ for pa, pb in zip(x, y):
|
||||||
|
+ if pa != pb:
|
||||||
|
+ return cmp(pa, pb)
|
||||||
|
+ return 0
|
||||||
|
+
|
||||||
|
def _compare(self, other, method):
|
||||||
|
try:
|
||||||
|
x = list(self.perms)
|
||||||
|
@@ -257,7 +282,8 @@ class AccessVectorSet:
|
||||||
|
for av in l:
|
||||||
|
self.add_av(AccessVector(av))
|
||||||
|
|
||||||
|
- def add(self, src_type, tgt_type, obj_class, perms, audit_msg=None, avc_type=audit2why.TERULE, data=[]):
|
||||||
|
+ def add(self, src_type, tgt_type, obj_class, perms, obj_path=None,
|
||||||
|
+ base_type=None, audit_msg=None, avc_type=audit2why.TERULE, data=[]):
|
||||||
|
"""Add an access vector to the set.
|
||||||
|
"""
|
||||||
|
tgt = self.src.setdefault(src_type, { })
|
||||||
|
@@ -270,7 +296,9 @@ class AccessVectorSet:
|
||||||
|
access.src_type = src_type
|
||||||
|
access.tgt_type = tgt_type
|
||||||
|
access.obj_class = obj_class
|
||||||
|
+ access.obj_path = obj_path
|
||||||
|
access.data = data
|
||||||
|
+ access.base_type = base_type
|
||||||
|
access.type = avc_type
|
||||||
|
cls[obj_class, avc_type] = access
|
||||||
|
|
||||||
|
diff --git sepolgen-1.2.3-rc1/src/sepolgen/audit.py sepolgen-1.2.3-rc1/src/sepolgen/audit.py
|
||||||
|
index 724d3ea..dad0724 100644
|
||||||
|
--- sepolgen-1.2.3-rc1/src/sepolgen/audit.py
|
||||||
|
+++ sepolgen-1.2.3-rc1/src/sepolgen/audit.py
|
||||||
|
@@ -176,6 +176,7 @@ class AVCMessage(AuditMessage):
|
||||||
|
self.exe = ""
|
||||||
|
self.path = ""
|
||||||
|
self.name = ""
|
||||||
|
+ self.ino = ""
|
||||||
|
self.accesses = []
|
||||||
|
self.denial = True
|
||||||
|
self.type = audit2why.TERULE
|
||||||
|
@@ -237,6 +238,10 @@ class AVCMessage(AuditMessage):
|
||||||
|
self.exe = fields[1][1:-1]
|
||||||
|
elif fields[0] == "name":
|
||||||
|
self.name = fields[1][1:-1]
|
||||||
|
+ elif fields[0] == "path":
|
||||||
|
+ self.path = fields[1][1:-1]
|
||||||
|
+ elif fields[0] == "ino":
|
||||||
|
+ self.ino = fields[1]
|
||||||
|
|
||||||
|
if not found_src or not found_tgt or not found_class or not found_access:
|
||||||
|
raise ValueError("AVC message in invalid format [%s]\n" % self.message)
|
||||||
|
@@ -361,7 +366,9 @@ class AuditParser:
|
||||||
|
self.path_msgs = []
|
||||||
|
self.by_header = { }
|
||||||
|
self.check_input_file = False
|
||||||
|
-
|
||||||
|
+ self.inode_dict = { }
|
||||||
|
+ self.__store_base_types()
|
||||||
|
+
|
||||||
|
# Low-level parsing function - tries to determine if this audit
|
||||||
|
# message is an SELinux related message and then parses it into
|
||||||
|
# the appropriate AuditMessage subclass. This function deliberately
|
||||||
|
@@ -499,6 +506,61 @@ class AuditParser:
|
||||||
|
|
||||||
|
return role_types
|
||||||
|
|
||||||
|
+ def __restore_path(self, name, inode):
|
||||||
|
+ import subprocess
|
||||||
|
+ import os
|
||||||
|
+ path = ""
|
||||||
|
+ # Optimizing
|
||||||
|
+ if name == "" or inode == "":
|
||||||
|
+ return path
|
||||||
|
+ for d in self.inode_dict:
|
||||||
|
+ if d == inode and self.inode_dict[d] == name:
|
||||||
|
+ return path
|
||||||
|
+ if d == inode and self.inode_dict[d] != name:
|
||||||
|
+ return self.inode_dict[d]
|
||||||
|
+ if inode not in self.inode_dict.keys():
|
||||||
|
+ self.inode_dict[inode] = name
|
||||||
|
+
|
||||||
|
+ command = "locate -b '\%s'" % name
|
||||||
|
+ try:
|
||||||
|
+ output = subprocess.check_output(command,
|
||||||
|
+ stderr=subprocess.STDOUT,
|
||||||
|
+ shell=True,
|
||||||
|
+ universal_newlines=True)
|
||||||
|
+ try:
|
||||||
|
+ ino = int(inode)
|
||||||
|
+ except ValueError:
|
||||||
|
+ pass
|
||||||
|
+ for file in output.split("\n"):
|
||||||
|
+ try:
|
||||||
|
+ if int(os.lstat(file).st_ino) == ino:
|
||||||
|
+ self.inode_dict[inode] = path = file
|
||||||
|
+ return path
|
||||||
|
+ except:
|
||||||
|
+ pass
|
||||||
|
+ except subprocess.CalledProcessError as e:
|
||||||
|
+ pass
|
||||||
|
+ return path
|
||||||
|
+
|
||||||
|
+ def __store_base_types(self):
|
||||||
|
+ import sepolicy
|
||||||
|
+ self.base_types = sepolicy.get_types_from_attribute("base_file_type")
|
||||||
|
+
|
||||||
|
+ def __get_base_type(self, tcontext, scontext):
|
||||||
|
+ import sepolicy
|
||||||
|
+ # Prevent unnecessary searching
|
||||||
|
+ if (self.old_scontext == scontext and
|
||||||
|
+ self.old_tcontext == tcontext):
|
||||||
|
+ return
|
||||||
|
+ self.old_scontext = scontext
|
||||||
|
+ self.old_tcontext = tcontext
|
||||||
|
+ for btype in self.base_types:
|
||||||
|
+ if btype == tcontext:
|
||||||
|
+ for writable in sepolicy.get_writable_files(scontext):
|
||||||
|
+ if writable.endswith(tcontext) and writable.startswith(scontext.rstrip("_t")):
|
||||||
|
+ return writable
|
||||||
|
+ return 0
|
||||||
|
+
|
||||||
|
def to_access(self, avc_filter=None, only_denials=True):
|
||||||
|
"""Convert the audit logs access into a an access vector set.
|
||||||
|
|
||||||
|
@@ -517,16 +579,23 @@ class AuditParser:
|
||||||
|
audit logs parsed by this object.
|
||||||
|
"""
|
||||||
|
av_set = access.AccessVectorSet()
|
||||||
|
+ self.old_scontext = ""
|
||||||
|
+ self.old_tcontext = ""
|
||||||
|
for avc in self.avc_msgs:
|
||||||
|
if avc.denial != True and only_denials:
|
||||||
|
continue
|
||||||
|
+ base_type = self.__get_base_type(avc.tcontext.type, avc.scontext.type)
|
||||||
|
+ if avc.path == "":
|
||||||
|
+ avc.path = self.__restore_path(avc.name, avc.ino)
|
||||||
|
if avc_filter:
|
||||||
|
if avc_filter.filter(avc):
|
||||||
|
av_set.add(avc.scontext.type, avc.tcontext.type, avc.tclass,
|
||||||
|
- avc.accesses, avc, avc_type=avc.type, data=avc.data)
|
||||||
|
+ avc.accesses, avc.path, base_type, avc,
|
||||||
|
+ avc_type=avc.type, data=avc.data)
|
||||||
|
else:
|
||||||
|
av_set.add(avc.scontext.type, avc.tcontext.type, avc.tclass,
|
||||||
|
- avc.accesses, avc, avc_type=avc.type, data=avc.data)
|
||||||
|
+ avc.accesses, avc.path, base_type, avc,
|
||||||
|
+ avc_type=avc.type, data=avc.data)
|
||||||
|
return av_set
|
||||||
|
|
||||||
|
class AVCTypeFilter:
|
||||||
|
diff --git sepolgen-1.2.3-rc1/src/sepolgen/interfaces.py sepolgen-1.2.3-rc1/src/sepolgen/interfaces.py
|
||||||
|
index 0b688bf..48ae4f2 100644
|
||||||
|
--- sepolgen-1.2.3-rc1/src/sepolgen/interfaces.py
|
||||||
|
+++ sepolgen-1.2.3-rc1/src/sepolgen/interfaces.py
|
||||||
|
@@ -341,12 +341,12 @@ class InterfaceSet:
|
||||||
|
self.output.write(str + "\n")
|
||||||
|
|
||||||
|
def to_file(self, fd):
|
||||||
|
- for iv in self.interfaces.values():
|
||||||
|
+ for iv in sorted(self.interfaces.values(), key=lambda x: x.name):
|
||||||
|
fd.write("[InterfaceVector %s " % iv.name)
|
||||||
|
- for param in iv.params.values():
|
||||||
|
+ for param in sorted(iv.params.values(), key=lambda x: x.name):
|
||||||
|
fd.write("%s:%s " % (param.name, refpolicy.field_to_str[param.type]))
|
||||||
|
fd.write("]\n")
|
||||||
|
- avl = iv.access.to_list()
|
||||||
|
+ avl = sorted(iv.access.to_list())
|
||||||
|
for av in avl:
|
||||||
|
fd.write(",".join(av))
|
||||||
|
fd.write("\n")
|
||||||
|
diff --git sepolgen-1.2.3-rc1/src/sepolgen/policygen.py sepolgen-1.2.3-rc1/src/sepolgen/policygen.py
|
||||||
|
index 34c8401..f374132 100644
|
||||||
|
--- sepolgen-1.2.3-rc1/src/sepolgen/policygen.py
|
||||||
|
+++ sepolgen-1.2.3-rc1/src/sepolgen/policygen.py
|
||||||
|
@@ -82,8 +82,9 @@ class PolicyGenerator:
|
||||||
|
self.module = refpolicy.Module()
|
||||||
|
|
||||||
|
self.dontaudit = False
|
||||||
|
-
|
||||||
|
+ self.mislabled = None
|
||||||
|
self.domains = None
|
||||||
|
+
|
||||||
|
def set_gen_refpol(self, if_set=None, perm_maps=None):
|
||||||
|
"""Set whether reference policy interfaces are generated.
|
||||||
|
|
||||||
|
@@ -153,6 +154,18 @@ class PolicyGenerator:
|
||||||
|
"""Return the generated module"""
|
||||||
|
return self.module
|
||||||
|
|
||||||
|
+ def __restore_label(self, av):
|
||||||
|
+ import selinux
|
||||||
|
+ try:
|
||||||
|
+ context = selinux.matchpathcon(av.obj_path, 0)
|
||||||
|
+ split = context[1].split(":")[2]
|
||||||
|
+ if split != av.tgt_type:
|
||||||
|
+ self.mislabled = split
|
||||||
|
+ return
|
||||||
|
+ except OSError:
|
||||||
|
+ pass
|
||||||
|
+ self.mislabled = None
|
||||||
|
+
|
||||||
|
def __add_allow_rules(self, avs):
|
||||||
|
for av in avs:
|
||||||
|
rule = refpolicy.AVRule(av)
|
||||||
|
@@ -161,6 +174,34 @@ class PolicyGenerator:
|
||||||
|
rule.comment = ""
|
||||||
|
if self.explain:
|
||||||
|
rule.comment = str(refpolicy.Comment(explain_access(av, verbosity=self.explain)))
|
||||||
|
+ # base_type[0] == 0 means there exists a base type but not the path
|
||||||
|
+ # base_type[0] == None means user isn't using base type
|
||||||
|
+ # base_type[1] contains the target context
|
||||||
|
+ # base_type[2] contains the source type
|
||||||
|
+ base_type = av.base_file_type()
|
||||||
|
+ if base_type[0] == 0 and av.type != audit2why.ALLOW:
|
||||||
|
+ rule.comment += "\n#!!!! WARNING: '%s' is a base type." % "".join(base_type[1])
|
||||||
|
+ for perm in av.perms:
|
||||||
|
+ if perm == "write" or perm == "create":
|
||||||
|
+ permission = True
|
||||||
|
+ break
|
||||||
|
+ else:
|
||||||
|
+ permission = False
|
||||||
|
+
|
||||||
|
+ # Catch perms 'write' and 'create' for base types
|
||||||
|
+ if (base_type[0] is not None and base_type[0] != 0
|
||||||
|
+ and permission and av.type != audit2why.ALLOW):
|
||||||
|
+ if av.obj_class == dir:
|
||||||
|
+ comp = "(/.*?)"
|
||||||
|
+ else:
|
||||||
|
+ comp = ""
|
||||||
|
+ rule.comment += "\n#!!!! WARNING '%s' is not allowed to write or create to %s. Change the label to %s." % ("".join(base_type[2]), "".join(base_type[1]), "".join(base_type[0]))
|
||||||
|
+ if av.obj_path != "":
|
||||||
|
+ rule.comment += "\n#!!!! $ semanage fcontext -a -t %s %s%s \n#!!!! $ restorecon -R -v %s" % ("".join(base_type[0]), "".join(av.obj_path), "".join(comp) ,"".join(av.obj_path))
|
||||||
|
+
|
||||||
|
+ self.__restore_label(av)
|
||||||
|
+ if self.mislabled is not None and av.type != audit2why.ALLOW:
|
||||||
|
+ rule.comment += "\n#!!!! The file '%s' is mislabeled on your system. \n#!!!! Fix with $ restorecon -R -v %s" % ("".join(av.obj_path), "".join(av.obj_path))
|
||||||
|
if av.type == audit2why.ALLOW:
|
||||||
|
rule.comment += "\n#!!!! This avc is allowed in the current policy"
|
||||||
|
if av.type == audit2why.DONTAUDIT:
|
||||||
|
diff --git sepolgen-1.2.3-rc1/src/sepolgen/refparser.py sepolgen-1.2.3-rc1/src/sepolgen/refparser.py
|
||||||
|
index 3132c6f..9b1d0c8 100644
|
||||||
|
--- sepolgen-1.2.3-rc1/src/sepolgen/refparser.py
|
||||||
|
+++ sepolgen-1.2.3-rc1/src/sepolgen/refparser.py
|
||||||
|
@@ -219,7 +219,7 @@ t_BAR = r'\|'
|
||||||
|
t_EXPL = r'\!'
|
||||||
|
t_EQUAL = r'\='
|
||||||
|
t_NUMBER = r'[0-9\.]+'
|
||||||
|
-t_PATH = r'/[a-zA-Z0-9)_\.\*/]*'
|
||||||
|
+t_PATH = r'/[a-zA-Z0-9)_\.\*/\$]*'
|
||||||
|
#t_IPV6_ADDR = r'[a-fA-F0-9]{0,4}:[a-fA-F0-9]{0,4}:([a-fA-F0-9]{0,4}:)*'
|
||||||
|
|
||||||
|
# Ignore whitespace - this is a special token for ply that more efficiently
|
||||||
|
@@ -417,6 +417,7 @@ def p_tunable_policy(p):
|
||||||
|
def p_ifelse(p):
|
||||||
|
'''ifelse : IFELSE OPAREN TICK IDENTIFIER SQUOTE COMMA COMMA TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi
|
||||||
|
| IFELSE OPAREN TICK IDENTIFIER SQUOTE COMMA TICK IDENTIFIER SQUOTE COMMA TICK interface_stmts SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi
|
||||||
|
+ | IFELSE OPAREN TICK IDENTIFIER SQUOTE COMMA TICK SQUOTE COMMA TICK interface_stmts SQUOTE COMMA TICK interface_stmts SQUOTE CPAREN optional_semi
|
||||||
|
'''
|
||||||
|
# x = refpolicy.IfDef(p[4])
|
||||||
|
# v = True
|
||||||
|
diff --git sepolgen-1.2.3-rc1/src/sepolgen/refpolicy.py sepolgen-1.2.3-rc1/src/sepolgen/refpolicy.py
|
||||||
|
index 737f956..31b40d8 100644
|
||||||
|
--- sepolgen-1.2.3-rc1/src/sepolgen/refpolicy.py
|
||||||
|
+++ sepolgen-1.2.3-rc1/src/sepolgen/refpolicy.py
|
||||||
|
@@ -251,10 +251,10 @@ class IdSet(set):
|
||||||
|
self.compliment = False
|
||||||
|
|
||||||
|
def to_space_str(self):
|
||||||
|
- return list_to_space_str(self)
|
||||||
|
+ return list_to_space_str(sorted(self))
|
||||||
|
|
||||||
|
def to_comma_str(self):
|
||||||
|
- return list_to_comma_str(self)
|
||||||
|
+ return list_to_comma_str(sorted(self))
|
||||||
|
|
||||||
|
class SecurityContext(Leaf):
|
||||||
|
"""An SELinux security context with optional MCS / MLS fields."""
|
2718
sepolgen-rhat.patch
2718
sepolgen-rhat.patch
File diff suppressed because it is too large
Load Diff
4
sources
4
sources
@ -1,3 +1,3 @@
|
|||||||
59d33101d57378ce69889cc078addf90 policycoreutils_man_ru2.tar.bz2
|
59d33101d57378ce69889cc078addf90 policycoreutils_man_ru2.tar.bz2
|
||||||
c7bf0999723ff7a3f1cb7a2888ef86b0 sepolgen-1.2.2.tar.gz
|
e1af957a577a6ae643fad110d4c680e6 sepolgen-1.2.3-rc1.tar.gz
|
||||||
795b05c3ad58253cba61249ec65b28ef policycoreutils-2.4.tar.gz
|
91c305a513871b1b28b2c77df61873c8 policycoreutils-2.5-rc1.tar.gz
|
||||||
|
Loading…
Reference in New Issue
Block a user