2021-01-21 22:28:29 +00:00
|
|
|
From e39c09c55ed98490b2f73e6564abca93f36ee81c Mon Sep 17 00:00:00 2001
|
2020-10-14 23:23:12 +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
|
|
|
|
index e4540977d042..ad718797ca68 100644
|
|
|
|
--- a/python/sepolicy/sepolicy/__init__.py
|
|
|
|
+++ b/python/sepolicy/sepolicy/__init__.py
|
|
|
|
@@ -1208,27 +1208,14 @@ def boolean_desc(boolean):
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2021-01-21 22:28:29 +00:00
|
|
|
index 81333928d552..dc3e5207c57c 100755
|
2020-10-14 23:23:12 +00:00
|
|
|
--- a/python/sepolicy/sepolicy/manpage.py
|
|
|
|
+++ b/python/sepolicy/sepolicy/manpage.py
|
2021-01-21 22:28:29 +00:00
|
|
|
@@ -151,10 +151,6 @@ def prettyprint(f, trim):
|
2020-10-14 23:23:12 +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:
|
2021-01-21 22:28:29 +00:00
|
|
|
@@ -184,7 +180,7 @@ def convert_manpage_to_html(html_manpage, manpage):
|
2020-10-14 23:23:12 +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):
|
2021-01-21 22:28:29 +00:00
|
|
|
@@ -192,9 +188,9 @@ class HTMLManPages:
|
2020-10-14 23:23:12 +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
|
|
|
|
|
|
|
|
- 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)
|
2021-01-21 22:28:29 +00:00
|
|
|
@@ -203,7 +199,6 @@ class HTMLManPages:
|
2020-10-14 23:23:12 +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):
|
2021-01-21 22:28:29 +00:00
|
|
|
@@ -221,67 +216,21 @@ class HTMLManPages:
|
2020-10-14 23:23:12 +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()
|
|
|
|
- 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("""
|
|
|
|
--
|
2021-01-21 22:28:29 +00:00
|
|
|
2.30.0
|
2020-10-14 23:23:12 +00:00
|
|
|
|