2018-05-15 07:51:02 +00:00
diff --git selinux-python-2.8-rc3/semanage/semanage.8 selinux-python-2.8-rc3/semanage/semanage.8
2017-08-07 15:13:28 +00:00
index 0bdb90f..0cdcfcc 100644
2018-05-15 07:51:02 +00:00
--- selinux-python-2.8-rc3/semanage/semanage.8
+++ selinux-python-2.8-rc3/semanage/semanage.8
2017-08-07 15:13:28 +00:00
@@ -57,9 +57,8 @@ to SELinux user identities (which controls the initial security context
assigned to Linux users when they login and bounds their authorized role set)
as well as security context mappings for various kinds of objects, such
as network ports, interfaces, infiniband pkeys and endports, and nodes (hosts)
-as well as the file context mapping. See the EXAMPLES section below for some
-examples of common usage. Note that the semanage login command deals with the
-mapping from Linux usernames (logins) to SELinux user identities,
+as well as the file context mapping. Note that the semanage login command deals
+with the mapping from Linux usernames (logins) to SELinux user identities,
while the semanage user command deals with the mapping from SELinux
user identities to authorized role sets. In most cases, only the
former mapping needs to be adjusted by the administrator; the latter
2018-05-15 07:51:02 +00:00
diff --git selinux-python-2.8-rc3/sepolicy/sepolicy/__init__.py selinux-python-2.8-rc3/sepolicy/sepolicy/__init__.py
2018-04-23 12:30:40 +00:00
index 89346ab..24e3526 100644
2018-05-15 07:51:02 +00:00
--- selinux-python-2.8-rc3/sepolicy/sepolicy/__init__.py
+++ selinux-python-2.8-rc3/sepolicy/sepolicy/__init__.py
2018-04-23 12:30:40 +00:00
@@ -1160,27 +1160,14 @@ def boolean_desc(boolean):
2017-08-07 15:13:28 +00:00
def get_os_version():
- os_version = ""
- pkg_name = "selinux-policy"
+ system_release = ""
try:
- try:
- from commands import getstatusoutput
- except ImportError:
- from subprocess import getstatusoutput
- rc, output = getstatusoutput("rpm -q '%s'" % pkg_name)
- if rc == 0:
- os_version = output.split(".")[-2]
- except:
- os_version = ""
-
- if os_version[0:2] == "fc":
- os_version = "Fedora" + os_version[2:]
- elif os_version[0:2] == "el":
- os_version = "RHEL" + os_version[2:]
- else:
- os_version = ""
+ with open('/etc/system-release') as f:
+ system_release = f.readline().rstrip()
+ except IOError:
+ system_release = "Misc"
- return os_version
+ return system_release
def reinit():
2018-05-15 07:51:02 +00:00
diff --git selinux-python-2.8-rc3/sepolicy/sepolicy/manpage.py selinux-python-2.8-rc3/sepolicy/sepolicy/manpage.py
2018-04-23 12:30:40 +00:00
index ed8cb71..8121e5c 100755
2018-05-15 07:51:02 +00:00
--- selinux-python-2.8-rc3/sepolicy/sepolicy/manpage.py
+++ selinux-python-2.8-rc3/sepolicy/sepolicy/manpage.py
2018-04-23 12:30:40 +00:00
@@ -126,8 +126,33 @@ def gen_domains():
2017-08-07 15:13:28 +00:00
domains.sort()
return domains
-types = None
+exec_types = None
+
+def _gen_exec_types():
+ global exec_types
+ if exec_types is None:
+ exec_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "exec_type"))["types"]
+ return exec_types
+
+entry_types = None
+
+def _gen_entry_types():
+ global entry_types
+ if entry_types is None:
+ entry_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "entry_type"))["types"]
+ return entry_types
+
+mcs_constrained_types = None
+
+def _gen_mcs_constrained_types():
+ global mcs_constrained_types
+ if mcs_constrained_types is None:
2018-03-13 13:43:27 +00:00
+ mcs_constrained_types = next(sepolicy.info(sepolicy.ATTRIBUTE, "mcs_constrained_type"))
2017-08-07 15:13:28 +00:00
+ return mcs_constrained_types
+
+
+types = None
def _gen_types():
global types
2018-04-23 12:30:40 +00:00
@@ -150,10 +175,6 @@ def prettyprint(f, trim):
2017-08-07 15:13:28 +00:00
manpage_domains = []
manpage_roles = []
-fedora_releases = ["Fedora17", "Fedora18"]
-rhel_releases = ["RHEL6", "RHEL7"]
-
-
def get_alphabet_manpages(manpage_list):
alphabet_manpages = dict.fromkeys(string.ascii_letters, [])
for i in string.ascii_letters:
2018-04-23 12:30:40 +00:00
@@ -183,7 +204,7 @@ def convert_manpage_to_html(html_manpage, manpage):
2017-08-07 15:13:28 +00:00
class HTMLManPages:
"""
- Generate a HHTML Manpages on an given SELinux domains
+ Generate a HTML Manpages on an given SELinux domains
"""
def __init__(self, manpage_roles, manpage_domains, path, os_version):
2018-04-23 12:30:40 +00:00
@@ -191,9 +212,9 @@ class HTMLManPages:
2017-08-07 15:13:28 +00:00
self.manpage_domains = get_alphabet_manpages(manpage_domains)
self.os_version = os_version
self.old_path = path + "/"
- self.new_path = self.old_path + self.os_version + "/"
+ self.new_path = self.old_path
2018-04-23 12:30:40 +00:00
- if self.os_version in fedora_releases or self.os_version in rhel_releases:
2017-08-07 15:13:28 +00:00
+ if self.os_version:
self.__gen_html_manpages()
else:
print("SELinux HTML man pages can not be generated for this %s" % os_version)
2018-04-23 12:30:40 +00:00
@@ -202,7 +223,6 @@ class HTMLManPages:
2017-08-07 15:13:28 +00:00
def __gen_html_manpages(self):
self._write_html_manpage()
self._gen_index()
- self._gen_body()
self._gen_css()
def _write_html_manpage(self):
2018-04-23 12:30:40 +00:00
@@ -220,67 +240,21 @@ class HTMLManPages:
2017-08-07 15:13:28 +00:00
convert_manpage_to_html((self.new_path + r.rsplit("_selinux", 1)[0] + ".html"), self.old_path + r)
def _gen_index(self):
- index = self.old_path + "index.html"
- fd = open(index, 'w')
- fd.write("""
-<html>
-<head>
- <link rel=stylesheet type="text/css" href="style.css" title="style">
- <title>SELinux man pages online</title>
-</head>
-<body>
-<h1>SELinux man pages</h1>
-<br></br>
-Fedora or Red Hat Enterprise Linux Man Pages.</h2>
-<br></br>
-<hr>
-<h3>Fedora</h3>
-<table><tr>
-<td valign="middle">
-</td>
-</tr></table>
-<pre>
-""")
- for f in fedora_releases:
- fd.write("""
-<a href=%s/%s.html>%s</a> - SELinux man pages for %s """ % (f, f, f, f))
-
- fd.write("""
-</pre>
-<hr>
-<h3>RHEL</h3>
-<table><tr>
-<td valign="middle">
-</td>
-</tr></table>
-<pre>
-""")
- for r in rhel_releases:
- fd.write("""
-<a href=%s/%s.html>%s</a> - SELinux man pages for %s """ % (r, r, r, r))
-
- fd.write("""
-</pre>
- """)
- fd.close()
2018-04-23 12:30:40 +00:00
- print("%s has been created" % index)
2017-08-07 15:13:28 +00:00
-
- def _gen_body(self):
html = self.new_path + self.os_version + ".html"
fd = open(html, 'w')
fd.write("""
<html>
<head>
- <link rel=stylesheet type="text/css" href="../style.css" title="style">
- <title>Linux man-pages online for Fedora18</title>
+ <link rel=stylesheet type="text/css" href="style.css" title="style">
+ <title>SELinux man pages</title>
</head>
<body>
-<h1>SELinux man pages for Fedora18</h1>
+<h1>SELinux man pages for %s</h1>
<hr>
<table><tr>
<td valign="middle">
<h3>SELinux roles</h3>
-""")
+""" % self.os_version)
for letter in self.manpage_roles:
if len(self.manpage_roles[letter]):
fd.write("""
2018-04-23 12:30:40 +00:00
@@ -424,6 +398,9 @@ class ManPage:
2017-08-07 15:13:28 +00:00
self.all_file_types = sepolicy.get_all_file_types()
self.role_allows = sepolicy.get_all_role_allows()
self.types = _gen_types()
+ self.exec_types = _gen_exec_types()
+ self.entry_types = _gen_entry_types()
+ self.mcs_constrained_types = _gen_mcs_constrained_types()
if self.source_files:
self.fcpath = self.root + "file_contexts"
2018-04-23 12:30:40 +00:00
@@ -736,10 +713,13 @@ Default Defined Ports:""")
2017-08-07 15:13:28 +00:00
def _file_context(self):
flist = []
+ flist_non_exec = []
mpaths = []
for f in self.all_file_types:
if f.startswith(self.domainname):
flist.append(f)
+ if not f in self.exec_types or not f in self.entry_types:
+ flist_non_exec.append(f)
if f in self.fcdict:
mpaths = mpaths + self.fcdict[f]["regex"]
if len(mpaths) == 0:
2018-04-23 12:30:40 +00:00
@@ -791,19 +771,20 @@ SELinux %(domainname)s policy is very flexible allowing users to setup their %(d
2017-08-07 15:13:28 +00:00
.PP
""" % {'domainname': self.domainname, 'equiv': e, 'alt': e.split('/')[-1]})
- self.fd.write(r"""
+ if flist_non_exec:
+ self.fd.write(r"""
.PP
.B STANDARD FILE CONTEXT
SELinux defines the file context types for the %(domainname)s, if you wanted to
store files with these types in a diffent paths, you need to execute the semanage command to sepecify alternate labeling and then use restorecon to put the labels on disk.
-.B semanage fcontext -a -t %(type)s '/srv/%(domainname)s/content(/.*)?'
+.B semanage fcontext -a -t %(type)s '/srv/my%(domainname)s_content(/.*)?'
.br
.B restorecon -R -v /srv/my%(domainname)s_content
Note: SELinux often uses regular expressions to specify labels that match multiple files.
-""" % {'domainname': self.domainname, "type": flist[0]})
+""" % {'domainname': self.domainname, "type": flist_non_exec[-1]})
self.fd.write(r"""
.I The following file types are defined for %(domainname)s:
2018-04-23 12:30:40 +00:00
@@ -974,11 +955,7 @@ All executeables with the default executable label, usually stored in /usr/bin a
2017-08-07 15:13:28 +00:00
%s""" % ", ".join(paths))
def _mcs_types(self):
2018-04-23 12:30:40 +00:00
- try:
- mcs_constrained_type = next(sepolicy.info(sepolicy.ATTRIBUTE, "mcs_constrained_type"))
- except StopIteration:
- return
2017-08-07 15:13:28 +00:00
- if self.type not in mcs_constrained_type['types']:
+ if self.type not in self.mcs_constrained_types['types']:
return
self.fd.write ("""
.SH "MCS Constrained"