Skip to contentSkip to conversation

gui/semanagePage: Close "edit" and "add" dialogues when successfull

PATCH In review Vit Mojzis 2 participants 7 messages Feb 22, 2018 – Mar 1, 2018 SELinux security module

lore
Share & tools
lore

Vit Mojzis

author
#0 lore raw

PATCH 1/1 gui/semanagePage: Close "edit" and "add" dialogues when successfull

"Edit" and "add" dialogues weren't closed after successful transaction ("add" and "edit" methods return "None" if successful).

---
 gui/semanagePage.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gui/semanagePage.py +2 -2
index 560ec077..4127804f 100644
@@ -140,7 +140,7 @@ class semanagePage:
 
         while self.dialog.run() == Gtk.ResponseType.OK:
             try:
-                if not self.add():
+                if self.add() is False:
                     continue
                 break
             except ValueError as e:
@@ -153,7 +153,7 @@ class semanagePage:
         self.dialog.set_position(Gtk.WindowPosition.MOUSE)
         while self.dialog.run() == Gtk.ResponseType.OK:
             try:
-                if not self.modify():
+                if self.modify() is False:
                     continue
                 break
             except ValueError as e:
Signature · 1 line
2.14.3
#1 lore raw
Quoted 2 lines · Vit Mojzis

"Edit" and "add" dialogues weren't closed after successful transaction ("add" and "edit" methods return "None" if successful).

I see the bug, but the behavior after applying the patch also seems to be wrong:
Traceback (most recent call last):
File "/usr/share/system-config-selinux/system-config-selinux.py", line
136, in add
self.tabs[self.notebook.get_current_page()].addDialog()
File "/usr/share/system-config-selinux/semanagePage.py", line 143, in
addDialog
if self.add() is False:
File "/usr/share/system-config-selinux/fcontextPage.py", line 192, in add
ftype = list_model.get_value(it, 0)
TypeError: Argument 1 does not allow None as a value

Quoted 29 lines
---
 gui/semanagePage.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
gui/semanagePage.py +2 -2
index 560ec077..4127804f 100644
@@ -140,7 +140,7 @@ class semanagePage:
 
         while self.dialog.run() == Gtk.ResponseType.OK:
             try:
-                if not self.add():
+                if self.add() is False:
                     continue
                 break
             except ValueError as e:
@@ -153,7 +153,7 @@ class semanagePage:
         self.dialog.set_position(Gtk.WindowPosition.MOUSE)
         while self.dialog.run() == Gtk.ResponseType.OK:
             try:
-                if not self.modify():
+                if self.modify() is False:
                     continue
                 break
             except ValueError as e:
author
#2 lore raw

The traceback was caused by leaving the object class combo box blank (therefore is not directly connected to this patch).
But I agree that is's undesirable behavior. I can either add a check that would notify the user that they left the option blank, or set a default value.

author
#3 lore raw

PATCH 1/3 secilc: Fix documentation build for OS X systems

From: Yuli Khodorkovskiy <[email protected]>

Since Darwin systems do not have GNU sed installed, the Darwin sed is missing the "regexp-extended" flag needed to modify the secilc markdown files before processing with pandoc.

A quick fix for Mac users is to brew install gnu-sed and to use gsed.

---
 secilc/docs/Makefile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
secilc/docs/Makefile +8 -2
index c0fa6b7f..6b07ce7f 100644
@@ -31,6 +31,12 @@ PANDOC_FILE_LIST = $(addprefix $(TMPDIR)/,$(FILE_LIST))
 PDF_OUT=CIL_Reference_Guide.pdf
 HTML_OUT=CIL_Reference_Guide.html
 PANDOC = pandoc
+SED ?= sed
+
+OS := $(shell uname)
+ifeq ($(OS), Darwin)
+	SED := gsed
+endif
 
 all: html pdf
 
@@ -40,12 +46,12 @@ $(TMPDIR):
 $(TMPDIR)/%.md: %.md | $(TMPDIR)
 	cp -f $< $(TMPDIR)/
 	@# Substitute markdown links for conversion into PDF links
-	sed -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@
+	$(SED) -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@
 
 $(TMPDIR)/policy.cil: $(TESTDIR)/policy.cil
 	cp -f $< $@
 	@# add a title for the TOC to policy.cil. This is needed to play nicely with the PDF conversion.
-	sed -i '1i Example Policy\n=========\n```' $@
+	$(SED) -i '1i Example Policy\n=========\n```' $@
 	echo '```' >> $@
 
 html: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
Signature · 1 line
2.14.3
author
#4 lore raw

Re: [PATCH 1/3] secilc: Fix documentation build for OS X systems

Sorry, wrong patch, please ignore this.

Quoted 45 lines · Vit Mojzis

From: Yuli Khodorkovskiy <[email protected]>

Since Darwin systems do not have GNU sed installed, the Darwin sed is missing the "regexp-extended" flag needed to modify the secilc markdown files before processing with pandoc.

A quick fix for Mac users is to brew install gnu-sed and to use gsed.

---
  secilc/docs/Makefile | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
secilc/docs/Makefile +8 -2
index c0fa6b7f..6b07ce7f 100644
@@ -31,6 +31,12 @@ PANDOC_FILE_LIST = $(addprefix $(TMPDIR)/,$(FILE_LIST))
  PDF_OUT=CIL_Reference_Guide.pdf
  HTML_OUT=CIL_Reference_Guide.html
  PANDOC = pandoc
+SED ?= sed
+
+OS := $(shell uname)
+ifeq ($(OS), Darwin)
+	SED := gsed
+endif
 
  all: html pdf
 
@@ -40,12 +46,12 @@ $(TMPDIR):
  $(TMPDIR)/%.md: %.md | $(TMPDIR)
  	cp -f $< $(TMPDIR)/
  	@# Substitute markdown links for conversion into PDF links
-	sed -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@
+	$(SED) -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@
 
  $(TMPDIR)/policy.cil: $(TESTDIR)/policy.cil
  	cp -f $< $@
  	@# add a title for the TOC to policy.cil. This is needed to play nicely with the PDF conversion.
-	sed -i '1i Example Policy\n=========\n```' $@
+	$(SED) -i '1i Example Policy\n=========\n```' $@
  	echo '```' >> $@
 
  html: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
author
#5 lore raw

PATCH 1/1 gui/fcontextPage: Set default object class in addDialog

In reply to Vit Mojzis

This ensures that user cannot leave the object class selection blank.

---
 gui/fcontextPage.py | 1 +
 1 file changed, 1 insertion(+)
gui/fcontextPage.py +1 -0
index a6577ef7..370bbee4 100644
@@ -164,6 +164,7 @@ class fcontextPage(semanagePage):
         self.fcontextEntry.set_text("")
         self.fcontextEntry.set_sensitive(True)
         self.fcontextFileTypeCombo.set_sensitive(True)
+        self.fcontextFileTypeCombo.set_active(0)
         self.fcontextTypeEntry.set_text("")
         self.fcontextMLSEntry.set_text("s0")
 
Signature · 1 line
2.14.3
#6 lore raw

Re: [PATCH] gui/fcontextPage: Set default object class in addDialog

Quoted 1 line · Vit Mojzis

This ensures that user cannot leave the object class selection blank.

Thanks, applied both your previous gui/semanagePage patch and this one.

Quoted 19 lines
---
 gui/fcontextPage.py | 1 +
 1 file changed, 1 insertion(+)
gui/fcontextPage.py +1 -0
index a6577ef7..370bbee4 100644
@@ -164,6 +164,7 @@ class fcontextPage(semanagePage):
         self.fcontextEntry.set_text("")
         self.fcontextEntry.set_sensitive(True)
         self.fcontextFileTypeCombo.set_sensitive(True)
+        self.fcontextFileTypeCombo.set_active(0)
         self.fcontextTypeEntry.set_text("")
         self.fcontextMLSEntry.set_text("s0")