mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-26 07:52:07 +00:00
policycoreutils/gui: py3 support for modules that changed name
StringIO moved to io and commands moved to subprocess Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
This commit is contained in:
parent
4d340e467a
commit
05d1cead3d
@ -31,7 +31,11 @@ import semanagePage
|
|||||||
INSTALLPATH = '/usr/share/system-config-selinux'
|
INSTALLPATH = '/usr/share/system-config-selinux'
|
||||||
sys.path.append(INSTALLPATH)
|
sys.path.append(INSTALLPATH)
|
||||||
|
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
ENFORCING = 0
|
ENFORCING = 0
|
||||||
PERMISSIVE = 1
|
PERMISSIVE = 1
|
||||||
DISABLED = 2
|
DISABLED = 2
|
||||||
@ -182,7 +186,7 @@ class booleansPage:
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage boolean -d %s" % boolean)
|
(rc, out) = getstatusoutput("semanage boolean -d %s" % boolean)
|
||||||
|
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
@ -233,7 +237,7 @@ class booleansPage:
|
|||||||
self.store.set_value(iter, ACTIVE, not val)
|
self.store.set_value(iter, ACTIVE, not val)
|
||||||
self.wait()
|
self.wait()
|
||||||
setsebool = "/usr/sbin/setsebool -P %s %d" % (key, not val)
|
setsebool = "/usr/sbin/setsebool -P %s %d" % (key, not val)
|
||||||
rc, out = commands.getstatusoutput(setsebool)
|
rc, out = getstatusoutput(setsebool)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
self.load(self.filter)
|
self.load(self.filter)
|
||||||
@ -242,7 +246,7 @@ class booleansPage:
|
|||||||
def on_revert_clicked(self, button):
|
def on_revert_clicked(self, button):
|
||||||
self.wait()
|
self.wait()
|
||||||
setsebool = "semanage boolean --deleteall"
|
setsebool = "semanage boolean --deleteall"
|
||||||
commands.getstatusoutput(setsebool)
|
getstatusoutput(setsebool)
|
||||||
self.load(self.filter)
|
self.load(self.filter)
|
||||||
self.ready()
|
self.ready()
|
||||||
|
|
||||||
|
@ -20,7 +20,11 @@ import string
|
|||||||
import gtk
|
import gtk
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
import os
|
import os
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import sys
|
import sys
|
||||||
import seobject
|
import seobject
|
||||||
@ -124,7 +128,7 @@ class domainsPage(semanagePage):
|
|||||||
domain = store.get_value(iter, 0)
|
domain = store.get_value(iter, 0)
|
||||||
try:
|
try:
|
||||||
self.wait()
|
self.wait()
|
||||||
status, output = commands.getstatusoutput("semanage permissive -d %s_t" % domain)
|
status, output = getstatusoutput("semanage permissive -d %s_t" % domain)
|
||||||
self.ready()
|
self.ready()
|
||||||
if status != 0:
|
if status != 0:
|
||||||
self.error(output)
|
self.error(output)
|
||||||
@ -149,7 +153,7 @@ class domainsPage(semanagePage):
|
|||||||
domain = store.get_value(iter, 0)
|
domain = store.get_value(iter, 0)
|
||||||
try:
|
try:
|
||||||
self.wait()
|
self.wait()
|
||||||
status, output = commands.getstatusoutput("semanage permissive -a %s_t" % domain)
|
status, output = getstatusoutput("semanage permissive -a %s_t" % domain)
|
||||||
self.ready()
|
self.ready()
|
||||||
if status != 0:
|
if status != 0:
|
||||||
self.error(output)
|
self.error(output)
|
||||||
|
@ -21,7 +21,11 @@ import gtk.glade
|
|||||||
import os
|
import os
|
||||||
import gobject
|
import gobject
|
||||||
import seobject
|
import seobject
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
from semanagePage import *
|
from semanagePage import *
|
||||||
|
|
||||||
SPEC_COL = 0
|
SPEC_COL = 0
|
||||||
@ -179,7 +183,7 @@ class fcontextPage(semanagePage):
|
|||||||
fspec = store.get_value(iter, SPEC_COL)
|
fspec = store.get_value(iter, SPEC_COL)
|
||||||
ftype = store.get_value(iter, FTYPE_COL)
|
ftype = store.get_value(iter, FTYPE_COL)
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage fcontext -d -f '%s' '%s'" % (ftype, fspec))
|
(rc, out) = getstatusoutput("semanage fcontext -d -f '%s' '%s'" % (ftype, fspec))
|
||||||
self.ready()
|
self.ready()
|
||||||
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
@ -197,7 +201,7 @@ class fcontextPage(semanagePage):
|
|||||||
list_model = self.fcontextFileTypeCombo.get_model()
|
list_model = self.fcontextFileTypeCombo.get_model()
|
||||||
active = self.fcontextFileTypeCombo.get_active()
|
active = self.fcontextFileTypeCombo.get_active()
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, ftype[active], fspec))
|
(rc, out) = getstatusoutput("semanage fcontext -a -t %s -r %s -f '%s' '%s'" % (type, mls, ftype[active], fspec))
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
@ -216,7 +220,7 @@ class fcontextPage(semanagePage):
|
|||||||
iter = self.fcontextFileTypeCombo.get_active_iter()
|
iter = self.fcontextFileTypeCombo.get_active_iter()
|
||||||
ftype = list_model.get_value(iter, 0)
|
ftype = list_model.get_value(iter, 0)
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage fcontext -m -t %s -r %s -f '%s' '%s'" % (type, mls, ftype, fspec))
|
(rc, out) = getstatusoutput("semanage fcontext -m -t %s -r %s -f '%s' '%s'" % (type, mls, ftype, fspec))
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
|
@ -30,7 +30,10 @@ import htmllib
|
|||||||
import formatter as Formatter
|
import formatter as Formatter
|
||||||
import string
|
import string
|
||||||
from types import *
|
from types import *
|
||||||
import StringIO
|
try:
|
||||||
|
from io import StringIO
|
||||||
|
except ImportError:
|
||||||
|
from StringIO import StringIO
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -127,7 +130,7 @@ def unescape_html(s):
|
|||||||
|
|
||||||
def html_to_text(html, maxcol=80):
|
def html_to_text(html, maxcol=80):
|
||||||
try:
|
try:
|
||||||
buffer = StringIO.StringIO()
|
buffer = StringIO()
|
||||||
formatter = Formatter.AbstractFormatter(TextWriter(buffer, maxcol))
|
formatter = Formatter.AbstractFormatter(TextWriter(buffer, maxcol))
|
||||||
parser = HTMLParserAnchor(formatter)
|
parser = HTMLParserAnchor(formatter)
|
||||||
parser.feed(html)
|
parser.feed(html)
|
||||||
|
@ -22,7 +22,11 @@ import gtk.glade
|
|||||||
import os
|
import os
|
||||||
import gobject
|
import gobject
|
||||||
import sys
|
import sys
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
import seobject
|
import seobject
|
||||||
from semanagePage import *
|
from semanagePage import *
|
||||||
|
|
||||||
@ -135,7 +139,7 @@ class loginsPage(semanagePage):
|
|||||||
raise ValueError(_("Login '%s' is required") % login)
|
raise ValueError(_("Login '%s' is required") % login)
|
||||||
|
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage login -d %s" % login)
|
(rc, out) = getstatusoutput("semanage login -d %s" % login)
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
@ -154,7 +158,7 @@ class loginsPage(semanagePage):
|
|||||||
iter = self.loginsSelinuxUserCombo.get_active_iter()
|
iter = self.loginsSelinuxUserCombo.get_active_iter()
|
||||||
seuser = list_model.get_value(iter, 0)
|
seuser = list_model.get_value(iter, 0)
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage login -a -s %s -r %s %s" % (seuser, serange, target))
|
(rc, out) = getstatusoutput("semanage login -a -s %s -r %s %s" % (seuser, serange, target))
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
@ -174,7 +178,7 @@ class loginsPage(semanagePage):
|
|||||||
iter = self.loginsSelinuxUserCombo.get_active_iter()
|
iter = self.loginsSelinuxUserCombo.get_active_iter()
|
||||||
seuser = list_model.get_value(iter, 0)
|
seuser = list_model.get_value(iter, 0)
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage login -m -s %s -r %s %s" % (seuser, serange, target))
|
(rc, out) = getstatusoutput("semanage login -m -s %s -r %s %s" % (seuser, serange, target))
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
|
@ -20,7 +20,11 @@ import string
|
|||||||
import gtk
|
import gtk
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
import os
|
import os
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import sys
|
import sys
|
||||||
import seobject
|
import seobject
|
||||||
@ -121,7 +125,7 @@ class modulesPage(semanagePage):
|
|||||||
module = store.get_value(iter, 0)
|
module = store.get_value(iter, 0)
|
||||||
try:
|
try:
|
||||||
self.wait()
|
self.wait()
|
||||||
status, output = commands.getstatusoutput("semodule -r %s" % module)
|
status, output = getstatusoutput("semodule -r %s" % module)
|
||||||
self.ready()
|
self.ready()
|
||||||
if status != 0:
|
if status != 0:
|
||||||
self.error(output)
|
self.error(output)
|
||||||
@ -137,10 +141,10 @@ class modulesPage(semanagePage):
|
|||||||
try:
|
try:
|
||||||
self.wait()
|
self.wait()
|
||||||
if self.audit_enabled:
|
if self.audit_enabled:
|
||||||
status, output = commands.getstatusoutput("semodule -DB")
|
status, output = getstatusoutput("semodule -DB")
|
||||||
button.set_label(_("Disable Audit"))
|
button.set_label(_("Disable Audit"))
|
||||||
else:
|
else:
|
||||||
status, output = commands.getstatusoutput("semodule -B")
|
status, output = getstatusoutput("semodule -B")
|
||||||
button.set_label(_("Enable Audit"))
|
button.set_label(_("Enable Audit"))
|
||||||
self.ready()
|
self.ready()
|
||||||
|
|
||||||
@ -153,7 +157,7 @@ class modulesPage(semanagePage):
|
|||||||
def disable_audit(self, button):
|
def disable_audit(self, button):
|
||||||
try:
|
try:
|
||||||
self.wait()
|
self.wait()
|
||||||
status, output = commands.getstatusoutput("semodule -B")
|
status, output = getstatusoutput("semodule -B")
|
||||||
self.ready()
|
self.ready()
|
||||||
if status != 0:
|
if status != 0:
|
||||||
self.error(output)
|
self.error(output)
|
||||||
@ -186,7 +190,7 @@ class modulesPage(semanagePage):
|
|||||||
def add(self, file):
|
def add(self, file):
|
||||||
try:
|
try:
|
||||||
self.wait()
|
self.wait()
|
||||||
status, output = commands.getstatusoutput("semodule -i %s" % file)
|
status, output = getstatusoutput("semodule -i %s" % file)
|
||||||
self.ready()
|
self.ready()
|
||||||
if status != 0:
|
if status != 0:
|
||||||
self.error(output)
|
self.error(output)
|
||||||
|
@ -35,7 +35,11 @@ except ValueError as e:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
import sepolicy.interface
|
import sepolicy.interface
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -43,7 +47,7 @@ import re
|
|||||||
def get_all_modules():
|
def get_all_modules():
|
||||||
try:
|
try:
|
||||||
all_modules = []
|
all_modules = []
|
||||||
rc, output = commands.getstatusoutput("semodule -l 2>/dev/null")
|
rc, output = getstatusoutput("semodule -l 2>/dev/null")
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
l = output.split("\n")
|
l = output.split("\n")
|
||||||
for i in l:
|
for i in l:
|
||||||
|
@ -23,7 +23,11 @@ import os
|
|||||||
import gobject
|
import gobject
|
||||||
import sys
|
import sys
|
||||||
import seobject
|
import seobject
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
from semanagePage import *
|
from semanagePage import *
|
||||||
|
|
||||||
##
|
##
|
||||||
@ -186,7 +190,7 @@ class portsPage(semanagePage):
|
|||||||
protocol = store.get_value(iter, 1)
|
protocol = store.get_value(iter, 1)
|
||||||
try:
|
try:
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage port -d -p %s %s" % (protocol, port))
|
(rc, out) = getstatusoutput("semanage port -d -p %s %s" % (protocol, port))
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
return self.error(out)
|
return self.error(out)
|
||||||
@ -209,7 +213,7 @@ class portsPage(semanagePage):
|
|||||||
iter = self.ports_protocol_combo.get_active_iter()
|
iter = self.ports_protocol_combo.get_active_iter()
|
||||||
protocol = list_model.get_value(iter, 0)
|
protocol = list_model.get_value(iter, 0)
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage port -a -p %s -r %s -t %s %s" % (protocol, mls, target, port_number))
|
(rc, out) = getstatusoutput("semanage port -a -p %s -r %s -t %s %s" % (protocol, mls, target, port_number))
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
@ -229,7 +233,7 @@ class portsPage(semanagePage):
|
|||||||
iter = self.ports_protocol_combo.get_active_iter()
|
iter = self.ports_protocol_combo.get_active_iter()
|
||||||
protocol = list_model.get_value(iter, 0)
|
protocol = list_model.get_value(iter, 0)
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage port -m -p %s -r %s -t %s %s" % (protocol, mls, target, port_number))
|
(rc, out) = getstatusoutput("semanage port -m -p %s -r %s -t %s %s" % (protocol, mls, target, port_number))
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
|
@ -28,7 +28,11 @@ import selinux
|
|||||||
INSTALLPATH = '/usr/share/system-config-selinux'
|
INSTALLPATH = '/usr/share/system-config-selinux'
|
||||||
sys.path.append(INSTALLPATH)
|
sys.path.append(INSTALLPATH)
|
||||||
|
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
ENFORCING = 1
|
ENFORCING = 1
|
||||||
PERMISSIVE = 0
|
PERMISSIVE = 0
|
||||||
DISABLED = -1
|
DISABLED = -1
|
||||||
|
@ -22,7 +22,11 @@ import gtk.glade
|
|||||||
import os
|
import os
|
||||||
import gobject
|
import gobject
|
||||||
import sys
|
import sys
|
||||||
import commands
|
try:
|
||||||
|
from subprocess import getstatusoutput
|
||||||
|
except ImportError:
|
||||||
|
from commands import getstatusoutput
|
||||||
|
|
||||||
import seobject
|
import seobject
|
||||||
from semanagePage import *
|
from semanagePage import *
|
||||||
|
|
||||||
@ -114,7 +118,7 @@ class usersPage(semanagePage):
|
|||||||
roles = self.selinuxRolesEntry.get_text()
|
roles = self.selinuxRolesEntry.get_text()
|
||||||
|
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage user -a -R '%s' -r %s %s" % (roles, range, user))
|
(rc, out) = getstatusoutput("semanage user -a -R '%s' -r %s %s" % (roles, range, user))
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
@ -130,7 +134,7 @@ class usersPage(semanagePage):
|
|||||||
roles = self.selinuxRolesEntry.get_text()
|
roles = self.selinuxRolesEntry.get_text()
|
||||||
|
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage user -m -R '%s' -r %s %s" % (roles, range, user))
|
(rc, out) = getstatusoutput("semanage user -m -R '%s' -r %s %s" % (roles, range, user))
|
||||||
self.ready()
|
self.ready()
|
||||||
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
@ -146,7 +150,7 @@ class usersPage(semanagePage):
|
|||||||
raise ValueError(_("SELinux user '%s' is required") % user)
|
raise ValueError(_("SELinux user '%s' is required") % user)
|
||||||
|
|
||||||
self.wait()
|
self.wait()
|
||||||
(rc, out) = commands.getstatusoutput("semanage user -d %s" % user)
|
(rc, out) = getstatusoutput("semanage user -d %s" % user)
|
||||||
self.ready()
|
self.ready()
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
self.error(out)
|
self.error(out)
|
||||||
|
Loading…
Reference in New Issue
Block a user