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