2019-10-16 09:36:01 +00:00
|
|
|
From 7e3f0b790e59d0d296ee689b74339dda0490f829 Mon Sep 17 00:00:00 2001
|
2019-03-22 16:35:38 +00:00
|
|
|
From: Miroslav Grepl <mgrepl@redhat.com>
|
|
|
|
Date: Thu, 19 Feb 2015 17:45:15 +0100
|
|
|
|
Subject: [PATCH] Simplication of sepolicy-manpage web functionality.
|
|
|
|
system_release is no longer hardcoded and it creates only index.html and html
|
|
|
|
man pages in the directory for the system release.
|
|
|
|
|
|
|
|
---
|
|
|
|
python/sepolicy/sepolicy/__init__.py | 25 +++--------
|
|
|
|
python/sepolicy/sepolicy/manpage.py | 65 +++-------------------------
|
|
|
|
2 files changed, 13 insertions(+), 77 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/python/sepolicy/sepolicy/__init__.py b/python/sepolicy/sepolicy/__init__.py
|
2019-10-16 09:36:01 +00:00
|
|
|
index e4540977d042..ad718797ca68 100644
|
2019-03-22 16:35:38 +00:00
|
|
|
--- a/python/sepolicy/sepolicy/__init__.py
|
|
|
|
+++ b/python/sepolicy/sepolicy/__init__.py
|
2019-10-16 09:36:01 +00:00
|
|
|
@@ -1208,27 +1208,14 @@ def boolean_desc(boolean):
|
2019-03-22 16:35:38 +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()
|
|
|
|
+ except IOError:
|
|
|
|
+ system_release = "Misc"
|
|
|
|
|
|
|
|
- return os_version
|
|
|
|
+ return system_release
|
|
|
|
|
|
|
|
|
|
|
|
def reinit():
|
|
|
|
diff --git a/python/sepolicy/sepolicy/manpage.py b/python/sepolicy/sepolicy/manpage.py
|
2019-10-16 09:36:01 +00:00
|
|
|
index ec17fb145375..8c529ddb07cd 100755
|
2019-03-22 16:35:38 +00:00
|
|
|
--- a/python/sepolicy/sepolicy/manpage.py
|
|
|
|
+++ b/python/sepolicy/sepolicy/manpage.py
|
|
|
|
@@ -149,10 +149,6 @@ def prettyprint(f, trim):
|
|
|
|
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:
|
|
|
|
@@ -182,7 +178,7 @@ def convert_manpage_to_html(html_manpage, manpage):
|
|
|
|
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):
|
|
|
|
@@ -190,9 +186,9 @@ class HTMLManPages:
|
|
|
|
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
|
|
|
|
|
|
|
|
- if self.os_version in fedora_releases or self.os_version in rhel_releases:
|
|
|
|
+ if self.os_version:
|
|
|
|
self.__gen_html_manpages()
|
|
|
|
else:
|
|
|
|
print("SELinux HTML man pages can not be generated for this %s" % os_version)
|
|
|
|
@@ -201,7 +197,6 @@ class HTMLManPages:
|
|
|
|
def __gen_html_manpages(self):
|
|
|
|
self._write_html_manpage()
|
|
|
|
self._gen_index()
|
|
|
|
- self._gen_body()
|
|
|
|
self._gen_css()
|
|
|
|
|
|
|
|
def _write_html_manpage(self):
|
|
|
|
@@ -219,67 +214,21 @@ class HTMLManPages:
|
|
|
|
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()
|
|
|
|
- print("%s has been created" % index)
|
|
|
|
-
|
|
|
|
- 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 online</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("""
|
|
|
|
--
|
2019-10-16 09:36:01 +00:00
|
|
|
2.23.0
|
2019-03-22 16:35:38 +00:00
|
|
|
|