python/semanage/seobject.py: Fix undefined store check
PATCH 1/1 python/semanage/seobject.py: Fix undefined store check
From: Vit Mojzis <[email protected]>
self.store is always a string (actual store name or "") because of semanageRecords.__init__. Fix check for not defined store.
--- python/semanage/seobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +1 -1
@@ -2651,7 +2651,7 @@ class booleanRecords(semanageRecords): self.current_booleans = [] ptype = None - if self.store is None or self.store == ptype: + if self.store == "" or self.store == ptype: self.modify_local = True else: self.modify_local = False
Signature · 1 line
2.17.0
Quoted 18 lines · Petr Lautrbach
From: Vit Mojzis <[email protected]>
self.store is always a string (actual store name or "") because of semanageRecords.__init__. Fix check for not defined store.
Signed-off-by Vit Mojzis <[email protected]>--- python/semanage/seobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)python/semanage/seobject.py +0
-0
python/semanage/seobject.py class booleanRecords(semanageRecords): · line 2657
Quoted 8 lines
python/semanage/seobject.py +1
-1@@ -2651,7 +2651,7 @@ class booleanRecords(semanageRecords): self.current_booleans = [] ptype = None - if self.store is None or self.store == ptype: + if self.store == "" or self.store == ptype: self.modify_local = True else: self.modify_local = False
Is there a reason you didn't use if not self.store here?
Quoted 21 lines · Stephen Smalley
Quoted 20 lines · Petr Lautrbach
From: Vit Mojzis <[email protected]>
self.store is always a string (actual store name or "") because of semanageRecords.__init__. Fix check for not defined store.
Signed-off-by Vit Mojzis <[email protected]>--- python/semanage/seobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)python/semanage/seobject.py +0
-0@@ -2651,7 +2651,7 @@ class booleanRecords(semanageRecords): self.current_booleans = [] ptype = None
Quoted 9 lines
python/semanage/seobject.py class booleanRecords(semanageRecords): · line 2657
Quoted 6 lines
python/semanage/seobject.py +1
-1- if self.store is None or self.store == ptype: + if self.store == "" or self.store == ptype: self.modify_local = True else: self.modify_local = FalseIs there a reason you didn't use if not self.store here?
There's a similar check on line 258 and this just follows the same pattern.
Quoted 32 lines · Petr Lautrbach
Quoted 21 lines · Stephen Smalley
Quoted 20 lines · Petr Lautrbach
From: Vit Mojzis <[email protected]>
self.store is always a string (actual store name or "") because of semanageRecords.__init__. Fix check for not defined store.
Signed-off-by Vit Mojzis <[email protected]>--- python/semanage/seobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)python/semanage/seobject.py +0
-0@@ -2651,7 +2651,7 @@ class booleanRecords(semanageRecords): self.current_booleans = [] ptype = NoneQuoted 9 lines
python/semanage/seobject.py class booleanRecords(semanageRecords): · line 2657
Quoted 6 lines
python/semanage/seobject.py +1
-1- if self.store is None or self.store == ptype: + if self.store == "" or self.store == ptype: self.modify_local = True else: self.modify_local = FalseIs there a reason you didn't use if not self.store here?
Quoted 1 line
There's a similar check on line 258 and this just follows the same pattern.
Ok, I don't have a strong opinion on it either way, but noticed that it was recommended to use not self.store in that bugzilla entry, comment #9, and was claimed to have been changed in comment #10. Up to you.
Quoted 33 lines · Stephen Smalley
Quoted 32 lines · Petr Lautrbach
Quoted 30 lines · Stephen Smalley
Quoted 18 lines · Petr Lautrbach
From: Vit Mojzis <[email protected]>
self.store is always a string (actual store name or "") because of semanageRecords.__init__. Fix check for not defined store.
Signed-off-by Vit Mojzis <[email protected]>--- python/semanage/seobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)python/semanage/seobject.py +0
-0python/semanage/seobject.py class booleanRecords(semanageRecords): · line 2657
Quoted 8 lines
python/semanage/seobject.py +1
-1@@ -2651,7 +2651,7 @@ class booleanRecords(semanageRecords): self.current_booleans = [] ptype = None - if self.store is None or self.store == ptype: + if self.store == "" or self.store == ptype: self.modify_local = True else: self.modify_local = FalseIs there a reason you didn't use if not self.store here?
Quoted 6 lines
Quoted 1 line
There's a similar check on line 258 and this just follows the same pattern.
Ok, I don't have a strong opinion on it either way, but noticed that it was recommended to use not self.store in that bugzilla entry, comment #9, and was claimed to have been changed in comment #10. Up to you.
I think that the important part of the message is not use self.store is "" as it has unpredictable behavior.
The check not self.store is already in __init__ on line 252:
252 if not self.store:
253 self.store = getattr(args, "store", "")
If there's no objection, I'd leave as it is now.
FYI: I'll be offline most time of the week so I won't be able to respond to emails during this time.
Stephen Smalley
AppliedQuoted 18 lines · Petr Lautrbach
From: Vit Mojzis <[email protected]>
self.store is always a string (actual store name or "") because of semanageRecords.__init__. Fix check for not defined store.
Signed-off-by Vit Mojzis <[email protected]>--- python/semanage/seobject.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)python/semanage/seobject.py +0
-0
python/semanage/seobject.py class booleanRecords(semanageRecords): · line 2657
Quoted 8 lines
python/semanage/seobject.py +1
-1@@ -2651,7 +2651,7 @@ class booleanRecords(semanageRecords): self.current_booleans = [] ptype = None - if self.store is None or self.store == ptype: + if self.store == "" or self.store == ptype: self.modify_local = True else: self.modify_local = False
Applied.