make seobject.py backward compatible

Fixes: $ system-config-selinux
  Traceback (most recent call last):
    File "/usr/share/system-config-selinux/system-config-selinux.py", line 196, in <module>
      app = childWindow()
    File "/usr/share/system-config-selinux/system-config-selinux.py", line 100, in __init__
      self.add_page(booleansPage.booleansPage(xml))
    File "/usr/share/system-config-selinux/booleansPage.py", line 142, in __init__
      self.load(self.filter)
    File "/usr/share/system-config-selinux/booleansPage.py", line 212, in load
      self.booleans = seobject.booleanRecords()
  TypeError: __init__() missing 1 required positional argument: 'args'
This commit is contained in:
Petr Lautrbach 2017-12-13 18:12:23 +01:00
parent 629a62a8a9
commit 0931850ffa

View File

@ -282,30 +282,35 @@ index 0bdb90f..0cdcfcc 100644
user identities to authorized role sets. In most cases, only the user identities to authorized role sets. In most cases, only the
former mapping needs to be adjusted by the administrator; the latter former mapping needs to be adjusted by the administrator; the latter
diff --git selinux-python-2.7/semanage/seobject.py selinux-python-2.7/semanage/seobject.py diff --git selinux-python-2.7/semanage/seobject.py selinux-python-2.7/semanage/seobject.py
index 70fd192..b287594 100644 index 70fd192..99e1cd8 100644
--- selinux-python-2.7/semanage/seobject.py --- selinux-python-2.7/semanage/seobject.py
+++ selinux-python-2.7/semanage/seobject.py +++ selinux-python-2.7/semanage/seobject.py
@@ -238,21 +238,23 @@ class semanageRecords: @@ -238,21 +238,28 @@ class semanageRecords:
transaction = False transaction = False
handle = None handle = None
store = None store = None
+ args = None + args = None
- def __init__(self, store): - def __init__(self, store):
+ def __init__(self, args): + def __init__(self, args = None):
global handle global handle
- self.load = True - self.load = True
- self.sh = self.get_handle(store) - self.sh = self.get_handle(store)
+ self.args = args + if args:
+ try: + # legacy code - args was store originally
+ self.noreload = args.noreload + if type(args) == str:
+ except: + self.store = args
+ self.noreload = False + else:
+ self.sh = self.get_handle(args.store) + self.args = args
+ self.noreload = getattr(args, "noreload", False)
+ if not self.store:
+ self.store = getattr(args, "store", "")
+
+ self.sh = self.get_handle(self.store)
rc, localstore = selinux.selinux_getpolicytype() rc, localstore = selinux.selinux_getpolicytype()
- if store == "" or store == localstore: - if store == "" or store == localstore:
+ if args.store == "" or args.store == localstore: + if self.store == "" or self.store == localstore:
self.mylog = logger() self.mylog = logger()
else: else:
self.mylog = nulllogger() self.mylog = nulllogger()
@ -316,7 +321,7 @@ index 70fd192..b287594 100644
def get_handle(self, store): def get_handle(self, store):
global is_mls_enabled global is_mls_enabled
@@ -312,7 +314,8 @@ class semanageRecords: @@ -312,7 +319,8 @@ class semanageRecords:
if semanageRecords.transaction: if semanageRecords.transaction:
return return
@ -326,18 +331,18 @@ index 70fd192..b287594 100644
rc = semanage_commit(self.sh) rc = semanage_commit(self.sh)
if rc < 0: if rc < 0:
self.mylog.commit(0) self.mylog.commit(0)
@@ -328,8 +331,8 @@ class semanageRecords: @@ -328,8 +336,8 @@ class semanageRecords:
class moduleRecords(semanageRecords): class moduleRecords(semanageRecords):
- def __init__(self, store): - def __init__(self, store):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
def get_all(self): def get_all(self):
l = [] l = []
@@ -386,6 +389,8 @@ class moduleRecords(semanageRecords): @@ -386,6 +394,8 @@ class moduleRecords(semanageRecords):
print("%-25s %-9s %-5s %s" % (t[0], t[2], t[3], disabled)) print("%-25s %-9s %-5s %s" % (t[0], t[2], t[3], disabled))
def add(self, file, priority): def add(self, file, priority):
@ -346,7 +351,7 @@ index 70fd192..b287594 100644
if not os.path.exists(file): if not os.path.exists(file):
raise ValueError(_("Module does not exist: %s ") % file) raise ValueError(_("Module does not exist: %s ") % file)
@@ -398,6 +403,8 @@ class moduleRecords(semanageRecords): @@ -398,6 +408,8 @@ class moduleRecords(semanageRecords):
self.commit() self.commit()
def set_enabled(self, module, enable): def set_enabled(self, module, enable):
@ -355,7 +360,7 @@ index 70fd192..b287594 100644
for m in module.split(): for m in module.split():
rc, key = semanage_module_key_create(self.sh) rc, key = semanage_module_key_create(self.sh)
if rc < 0: if rc < 0:
@@ -416,11 +423,15 @@ class moduleRecords(semanageRecords): @@ -416,11 +428,15 @@ class moduleRecords(semanageRecords):
self.commit() self.commit()
def modify(self, file): def modify(self, file):
@ -371,40 +376,40 @@ index 70fd192..b287594 100644
rc = semanage_set_default_priority(self.sh, priority) rc = semanage_set_default_priority(self.sh, priority)
if rc < 0: if rc < 0:
raise ValueError(_("Invalid priority %d (needs to be between 1 and 999)") % priority) raise ValueError(_("Invalid priority %d (needs to be between 1 and 999)") % priority)
@@ -440,8 +451,8 @@ class moduleRecords(semanageRecords): @@ -440,8 +456,8 @@ class moduleRecords(semanageRecords):
class dontauditClass(semanageRecords): class dontauditClass(semanageRecords):
- def __init__(self, store): - def __init__(self, store):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
def toggle(self, dontaudit): def toggle(self, dontaudit):
if dontaudit not in ["on", "off"]: if dontaudit not in ["on", "off"]:
@@ -453,8 +464,8 @@ class dontauditClass(semanageRecords): @@ -453,8 +469,8 @@ class dontauditClass(semanageRecords):
class permissiveRecords(semanageRecords): class permissiveRecords(semanageRecords):
- def __init__(self, store): - def __init__(self, store):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
def get_all(self): def get_all(self):
l = [] l = []
@@ -522,8 +533,8 @@ class permissiveRecords(semanageRecords): @@ -522,8 +538,8 @@ class permissiveRecords(semanageRecords):
class loginRecords(semanageRecords): class loginRecords(semanageRecords):
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
self.oldsename = None self.oldsename = None
self.oldserange = None self.oldserange = None
self.sename = None self.sename = None
@@ -534,7 +545,7 @@ class loginRecords(semanageRecords): @@ -534,7 +550,7 @@ class loginRecords(semanageRecords):
if sename == "": if sename == "":
sename = "user_u" sename = "user_u"
@ -413,7 +418,7 @@ index 70fd192..b287594 100644
range, (rc, oldserole) = userrec.get(self.oldsename) range, (rc, oldserole) = userrec.get(self.oldsename)
range, (rc, serole) = userrec.get(sename) range, (rc, serole) = userrec.get(sename)
@@ -603,7 +614,7 @@ class loginRecords(semanageRecords): @@ -603,7 +619,7 @@ class loginRecords(semanageRecords):
if sename == "" and serange == "": if sename == "" and serange == "":
raise ValueError(_("Requires seuser or serange")) raise ValueError(_("Requires seuser or serange"))
@ -422,7 +427,7 @@ index 70fd192..b287594 100644
range, (rc, oldserole) = userrec.get(self.oldsename) range, (rc, oldserole) = userrec.get(self.oldsename)
if sename != "": if sename != "":
@@ -660,7 +671,7 @@ class loginRecords(semanageRecords): @@ -660,7 +676,7 @@ class loginRecords(semanageRecords):
def __delete(self, name): def __delete(self, name):
rec, self.oldsename, self.oldserange = selinux.getseuserbyname(name) rec, self.oldsename, self.oldserange = selinux.getseuserbyname(name)
@ -431,40 +436,40 @@ index 70fd192..b287594 100644
range, (rc, oldserole) = userrec.get(self.oldsename) range, (rc, oldserole) = userrec.get(self.oldsename)
(rc, k) = semanage_seuser_key_create(self.sh, name) (rc, k) = semanage_seuser_key_create(self.sh, name)
@@ -779,8 +790,8 @@ class loginRecords(semanageRecords): @@ -779,8 +795,8 @@ class loginRecords(semanageRecords):
class seluserRecords(semanageRecords): class seluserRecords(semanageRecords):
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
def get(self, name): def get(self, name):
(rc, k) = semanage_user_key_create(self.sh, name) (rc, k) = semanage_user_key_create(self.sh, name)
@@ -1042,8 +1053,8 @@ class portRecords(semanageRecords): @@ -1042,8 +1058,8 @@ class portRecords(semanageRecords):
except RuntimeError: except RuntimeError:
valid_types = [] valid_types = []
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
def __genkey(self, port, proto): def __genkey(self, port, proto):
if proto == "tcp": if proto == "tcp":
@@ -1317,8 +1328,8 @@ class ibpkeyRecords(semanageRecords): @@ -1317,8 +1333,8 @@ class ibpkeyRecords(semanageRecords):
except: except:
valid_types = [] valid_types = []
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
def __genkey(self, pkey, subnet_prefix): def __genkey(self, pkey, subnet_prefix):
if subnet_prefix == "": if subnet_prefix == "":
@@ -1540,9 +1551,8 @@ class ibpkeyRecords(semanageRecords): @@ -1540,9 +1556,8 @@ class ibpkeyRecords(semanageRecords):
def customized(self): def customized(self):
l = [] l = []
ddict = self.get_all(True) ddict = self.get_all(True)
@ -476,7 +481,7 @@ index 70fd192..b287594 100644
if k[0] == k[1]: if k[0] == k[1]:
l.append("-a -t %s -x %s %s" % (ddict[k][0], k[2], k[0])) l.append("-a -t %s -x %s %s" % (ddict[k][0], k[2], k[0]))
else: else:
@@ -1554,11 +1564,10 @@ class ibpkeyRecords(semanageRecords): @@ -1554,11 +1569,10 @@ class ibpkeyRecords(semanageRecords):
keys = ddict.keys() keys = ddict.keys()
if len(keys) == 0: if len(keys) == 0:
return return
@ -489,18 +494,18 @@ index 70fd192..b287594 100644
rec = "%-30s %-18s " % i rec = "%-30s %-18s " % i
rec += "%s" % ddict[i][0] rec += "%s" % ddict[i][0]
for p in ddict[i][1:]: for p in ddict[i][1:]:
@@ -1572,8 +1581,8 @@ class ibendportRecords(semanageRecords): @@ -1572,8 +1586,8 @@ class ibendportRecords(semanageRecords):
except: except:
valid_types = [] valid_types = []
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
def __genkey(self, ibendport, ibdev_name): def __genkey(self, ibendport, ibdev_name):
if ibdev_name == "": if ibdev_name == "":
@@ -1782,10 +1791,9 @@ class ibendportRecords(semanageRecords): @@ -1782,10 +1796,9 @@ class ibendportRecords(semanageRecords):
def customized(self): def customized(self):
l = [] l = []
ddict = self.get_all(True) ddict = self.get_all(True)
@ -514,7 +519,7 @@ index 70fd192..b287594 100644
return l return l
def list(self, heading=1, locallist=0): def list(self, heading=1, locallist=0):
@@ -1793,11 +1801,10 @@ class ibendportRecords(semanageRecords): @@ -1793,11 +1806,10 @@ class ibendportRecords(semanageRecords):
keys = ddict.keys() keys = ddict.keys()
if len(keys) == 0: if len(keys) == 0:
return return
@ -527,40 +532,40 @@ index 70fd192..b287594 100644
rec = "%-30s %-18s " % i rec = "%-30s %-18s " % i
rec += "%s" % ddict[i][0] rec += "%s" % ddict[i][0]
for p in ddict[i][1:]: for p in ddict[i][1:]:
@@ -1810,8 +1817,8 @@ class nodeRecords(semanageRecords): @@ -1810,8 +1822,8 @@ class nodeRecords(semanageRecords):
except RuntimeError: except RuntimeError:
valid_types = [] valid_types = []
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
self.protocol = ["ipv4", "ipv6"] self.protocol = ["ipv4", "ipv6"]
def validate(self, addr, mask, protocol): def validate(self, addr, mask, protocol):
@@ -2046,8 +2053,8 @@ class nodeRecords(semanageRecords): @@ -2046,8 +2058,8 @@ class nodeRecords(semanageRecords):
class interfaceRecords(semanageRecords): class interfaceRecords(semanageRecords):
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
def __add(self, interface, serange, ctype): def __add(self, interface, serange, ctype):
if is_mls_enabled == 1: if is_mls_enabled == 1:
@@ -2243,8 +2250,8 @@ class fcontextRecords(semanageRecords): @@ -2243,8 +2255,8 @@ class fcontextRecords(semanageRecords):
except RuntimeError: except RuntimeError:
valid_types = [] valid_types = []
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
self.equiv = {} self.equiv = {}
self.equiv_dist = {} self.equiv_dist = {}
self.equal_ind = False self.equal_ind = False
@@ -2566,10 +2573,15 @@ class fcontextRecords(semanageRecords): @@ -2566,10 +2578,15 @@ class fcontextRecords(semanageRecords):
if rc < 0: if rc < 0:
raise ValueError(_("Could not list file contexts")) raise ValueError(_("Could not list file contexts"))
@ -576,13 +581,13 @@ index 70fd192..b287594 100644
self.flist += fclocal self.flist += fclocal
ddict = {} ddict = {}
@@ -2627,8 +2639,8 @@ class fcontextRecords(semanageRecords): @@ -2627,8 +2644,8 @@ class fcontextRecords(semanageRecords):
class booleanRecords(semanageRecords): class booleanRecords(semanageRecords):
- def __init__(self, store=""): - def __init__(self, store=""):
- semanageRecords.__init__(self, store) - semanageRecords.__init__(self, store)
+ def __init__(self, args): + def __init__(self, args = None):
+ semanageRecords.__init__(self, args) + semanageRecords.__init__(self, args)
self.dict = {} self.dict = {}
self.dict["TRUE"] = 1 self.dict["TRUE"] = 1