Skip to contentSkip to conversation

python/semanage/seobject.py: Fix undefined store check

PATCH Applied Petr Lautrbach 2 participants 6 messages May 4, 2018 – May 8, 2018 SELinux security module

lore
Share & tools
lore
#0 lore raw

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
index ac310ea6..c76dce85 100644
@@ -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
#1 lore raw
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.

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +0 -0
index ac310ea6..c76dce85 100644

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?

#2 lore raw
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.

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +0 -0
index ac310ea6..c76dce85 100644
@@ -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 = False

Is 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.

#3 lore raw
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.

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +0 -0
index ac310ea6..c76dce85 100644
@@ -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 = False

Is 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.

#4 lore raw
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.

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +0 -0
index ac310ea6..c76dce85 100644

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 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.

#5 lore raw
In reply to Petr Lautrbach
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.

---
 python/semanage/seobject.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
python/semanage/seobject.py +0 -0
index ac310ea6..c76dce85 100644

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.