Discussion:
[PATCH] gui/semanagePage: Close "edit" and "add" dialogues when successfull
Vit Mojzis
2018-02-22 13:29:33 UTC
Permalink
"Edit" and "add" dialogues weren't closed after successful transaction
("add" and "edit" methods return "None" if successful).

Signed-off-by: Vit Mojzis <***@redhat.com>
---
gui/semanagePage.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gui/semanagePage.py b/gui/semanagePage.py
index 560ec077..4127804f 100644
--- a/gui/semanagePage.py
+++ b/gui/semanagePage.py
@@ -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:
--
2.14.3
Stephen Smalley
2018-02-26 14:51:32 UTC
Permalink
Post by 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
Post by Vit Mojzis
---
gui/semanagePage.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gui/semanagePage.py b/gui/semanagePage.py
index 560ec077..4127804f 100644
--- a/gui/semanagePage.py
+++ b/gui/semanagePage.py
continue
break
self.dialog.set_position(Gtk.WindowPosition.MOUSE)
continue
break
Vit Mojzis
2018-03-01 10:59:42 UTC
Permalink
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.
Vit Mojzis
2018-03-01 10:59:43 UTC
Permalink
From: Yuli Khodorkovskiy <***@gmail.com>

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.

Signed-off-by: Yuli Khodorkovskiy <***@gmail.com>
---
secilc/docs/Makefile | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/secilc/docs/Makefile b/secilc/docs/Makefile
index c0fa6b7f..6b07ce7f 100644
--- a/secilc/docs/Makefile
+++ b/secilc/docs/Makefile
@@ -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
--
2.14.3
Vit Mojzis
2018-03-01 11:03:45 UTC
Permalink
Sorry, wrong patch, please ignore this.
Post by Vit Mojzis
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(-)
diff --git a/secilc/docs/Makefile b/secilc/docs/Makefile
index c0fa6b7f..6b07ce7f 100644
--- a/secilc/docs/Makefile
+++ b/secilc/docs/Makefile
@@ -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
$(TMPDIR)/%.md: %.md | $(TMPDIR)
cp -f $< $(TMPDIR)/
@# Substitute markdown links for conversion into PDF links
$(TMPDIR)/policy.cil: $(TESTDIR)/policy.cil
@# add a title for the TOC to policy.cil. This is needed to play nicely with the PDF conversion.
html: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
Vit Mojzis
2018-03-01 11:03:06 UTC
Permalink
This ensures that user cannot leave the object class selection blank.

Signed-off-by: Vit Mojzis <***@redhat.com>
---
gui/fcontextPage.py | 1 +
1 file changed, 1 insertion(+)

diff --git a/gui/fcontextPage.py b/gui/fcontextPage.py
index a6577ef7..370bbee4 100644
--- a/gui/fcontextPage.py
+++ b/gui/fcontextPage.py
@@ -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")
--
2.14.3
Stephen Smalley
2018-03-01 14:49:02 UTC
Permalink
Post by Vit Mojzis
This ensures that user cannot leave the object class selection blank.
Thanks, applied both your previous gui/semanagePage patch and this one.
Post by Vit Mojzis
---
gui/fcontextPage.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/gui/fcontextPage.py b/gui/fcontextPage.py
index a6577ef7..370bbee4 100644
--- a/gui/fcontextPage.py
+++ b/gui/fcontextPage.py
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")
Loading...