Update selinux-sepolgengui to be compatible with Gtk3, Python 3
Hi,
The following set of patches update polgengui.py, rename polgen.glade to polgen.ui, convert it to new format, and fix some other sepolicy Python 3 related issues.
Thanks,
Petr
PATCH 1/4 gui/polgengui.py: Fix sepolicy.generate import in polgengui.py
b43991f9 added direct import of sepolicy but it forgot to import sepolicy.generate and didn't change use of generate to sepolicy.generate
Fixes:
Traceback (most recent call last):
File "/usr/bin/selinux-polgengui", line 778, in <module>
app = childWindow()
File "/usr/bin/selinux-polgengui", line 205, in __init__
self.all_types = sepolicy.generate.get_all_types()
AttributeError: 'module' object has no attribute 'generate'
Traceback (most recent call last):
File "/usr/share/system-config-selinux/polgengui.py", line 365, in forward
if self.on_in_net_page_next():
File "/usr/share/system-config-selinux/polgengui.py", line 701, in on_in_net_page_next
generate.verify_ports(self.in_tcp_entry.get_text())
NameError: global name 'generate' is not defined
--- gui/polgengui.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
gui/polgengui.py +7 -5
@@ -34,7 +34,9 @@ except ValueError as e: sys.stderr.write("%s: %s\n" % (e.__class__.__name__, str(e))) sys.exit(1) +import sepolicy.generate import sepolicy.interface + try: from subprocess import getstatusoutput except ImportError:
@@ -696,16 +698,16 @@ class childWindow: def on_in_net_page_next(self, *args): try: - generate.verify_ports(self.in_tcp_entry.get_text()) - generate.verify_ports(self.in_udp_entry.get_text()) + sepolicy.generate.verify_ports(self.in_tcp_entry.get_text()) + sepolicy.generate.verify_ports(self.in_udp_entry.get_text()) except ValueError as e: self.error(e.message) return True def on_out_net_page_next(self, *args): try: - generate.verify_ports(self.out_tcp_entry.get_text()) - generate.verify_ports(self.out_udp_entry.get_text()) + sepolicy.generate.verify_ports(self.out_tcp_entry.get_text()) + sepolicy.generate.verify_ports(self.out_udp_entry.get_text()) except ValueError as e: self.error(e.message) return True
@@ -741,7 +743,7 @@ class childWindow: if exe == "": self.error(_("You must enter a executable")) return True - policy = generate.policy(name, self.get_type()) + policy = sepolicy.generate.policy(name, self.get_type()) policy.set_program(exe) policy.gen_writeable() policy.gen_symbols()
Signature · 1 line
2.16.1
PATCH 2/4 gui/polgengui.py: Convert polgen.glade to Builder format polgen.ui
In reply to Petr Lautrbach- $ gtk-builder-convert polgen.glade polgen.ui
- use get_object instead of get_widget
- use connect_signals instead of signal_connect
---
gui/Makefile | 2 +-
gui/{polgen.glade => polgen.ui} | 967 +++++++++++++++++++---------------------
gui/polgengui.py | 201 +++++----
3 files changed, 561 insertions(+), 609 deletions(-)
rename gui/{polgen.glade => polgen.ui} (81%)gui/Makefile +1 -1
@@ -12,7 +12,7 @@ fcontextPage.py \ html_util.py \ loginsPage.py \ modulesPage.py \ -polgen.glade \ +polgen.ui \ portsPage.py \ semanagePage.py \ statusPage.py \
gui/polgen.ui renamed from gui/polgen.glade +458 -509
2,791 lines not on this page · raw message
gui/polgengui.py +102 -99
201 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.16.1
Part of the diff is not shown here. View the raw message.
PATCH 3/4 python/sepolicy: Use list instead of map
In reply to Petr Lautrbachmap() returns an iterator in python3, list in python2
Fixes:
File "/usr/lib/python3.6/site-packages/sepolicy/generate.py", line 114, in get_all_users
users.remove("system_u")
AttributeError: 'map' object has no attribute 'remove'
--- python/sepolicy/sepolicy/generate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
python/sepolicy/sepolicy/generate.py +1 -1
@@ -110,7 +110,7 @@ def get_all_ports(): def get_all_users(): - users = map(lambda x: x['name'], sepolicy.info(sepolicy.USER)) + users = [x['name'] for x in sepolicy.info(sepolicy.USER)] users.remove("system_u") users.remove("root") users.sort()
Signature · 1 line
2.16.1
PATCH 4/4 python/sepolicy: Do not use types.BooleanType
In reply to Petr LautrbachIt was removed from Python 3
Fixes:
File "polgengui.py", line 390, in forward
self.generate_policy()
File "polgengui.py", line 491, in generate_policy
my_policy.set_use_syslog(self.syslog_checkbutton.get_active() == 1)
File "/home/plautrba/devel/github/bachradsusi/SELinuxProject-selinux/python/sepolicy/sepolicy/generate.py", line 468, in set_use_syslog
if not isinstance(val, types.BooleanType):
AttributeError: module 'types' has no attribute 'BooleanType'
--- python/sepolicy/sepolicy/generate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
python/sepolicy/sepolicy/generate.py +4 -4
@@ -459,25 +459,25 @@ class policy: self.out_udp = [all, False, False, verify_ports(ports)] def set_use_resolve(self, val): - if not isinstance(val, types.BooleanType): + if type(val) is not bool: raise ValueError(_("use_resolve must be a boolean value ")) self.use_resolve = val def set_use_syslog(self, val): - if not isinstance(val, types.BooleanType): + if type(val) is not bool: raise ValueError(_("use_syslog must be a boolean value ")) self.use_syslog = val def set_use_kerberos(self, val): - if not isinstance(val, types.BooleanType): + if type(val) is not bool: raise ValueError(_("use_kerberos must be a boolean value ")) self.use_kerberos = val def set_manage_krb5_rcache(self, val): - if not isinstance(val, types.BooleanType): + if type(val) is not bool: raise ValueError(_("manage_krb5_rcache must be a boolean value ")) self.manage_krb5_rcache = val
Signature · 1 line
2.16.1
Quoted 5 lines · Petr Lautrbach
Hi,
The following set of patches update
polgengui.py, rename polgen.glade to polgen.ui, convert it to new format, and fix some other sepolicy Python 3 related issues.
Hi,
I have read and tested these patches and they look good to me.
Quoted 9 lines · Nicolas Iooss
Quoted 5 lines · Petr Lautrbach
Hi,
The following set of patches update
polgengui.py, rename polgen.glade to polgen.ui, convert it to new format, and fix some other sepolicy Python 3 related issues.Hi,
I have read and tested these patches and they look good to me.
(Oops, the mail has been sent before I finished writing it...)
In order to run polgengui on my development system which uses a policy without MLS, I needed a patch in sepolicy, that I sent a few days ago ("[PATCH 1/3] python/sepolicy: Support non-MLS policy"). With this I have been able to play with polgengui and have been surprised by a warning which appears on my terminal every time I type anything in the "name" field of the form in the second tab ("Enter name of application or user role:"):
polgengui.py:778: Warning: g_value_get_int: assertion 'G_VALUE_HOLDS_INT (value)' failed
Gtk.main()
Have you got such warning on your system? Do you know where this warning comes from? For information I use Gtk3 3.22.26 with python-gobject 3.26.1.
Anyway, this looks like a harmless warning. Feel free to add "Tested-by: Nicolas Iooss <[email protected]>" to your patches.
Thanks,
Nicolas
Quoted 20 lines · Nicolas Iooss
Quoted 9 lines · Nicolas Iooss
Quoted 5 lines · Petr Lautrbach
Hi,
The following set of patches update
polgengui.py, rename polgen.glade to polgen.ui, convert it to new format, and fix some other sepolicy Python 3 related issues.Hi,
I have read and tested these patches and they look good to me.(Oops, the mail has been sent before I finished writing it...)
In order to run polgengui on my development system which uses a policy without MLS, I needed a patch in sepolicy, that I sent a few days ago ("[PATCH 1/3] python/sepolicy: Support non-MLS policy"). With this I have been able to play with polgengui and have been surprised by a warning which appears on my terminal every time I type anything in the "name" field of the form in the second tab ("Enter name of application or user role:"):
Quoted 7 lines
polgengui.py:778: Warning:
g_value_get_int: assertion 'G_VALUE_HOLDS_INT(value)' failed
Gtk.main()Have you got such warning on your system? Do you know where this warning comes from? For information I use Gtk3 3.22.26 with python-gobject 3.26.1.
I see it as well. I'll try to find the problem and sent a patch for that.
Quoted 4 lines
Anyway, this looks like a harmless warning. Feel free to add "Tested-by: Nicolas Iooss <[email protected]>" to your patches.
Thanks!
Quoted 25 lines · Petr Lautrbach
Quoted 24 lines · Nicolas Iooss
Quoted 9 lines · Nicolas Iooss
Quoted 5 lines · Petr Lautrbach
Hi,
The following set of patches update
polgengui.py, rename polgen.glade to polgen.ui, convert it to new format, and fix some other sepolicy Python 3 related issues.Hi,
I have read and tested these patches and they look good to me.(Oops, the mail has been sent before I finished writing it...)
In order to run polgengui on my development system which uses a policy without MLS, I needed a patch in sepolicy, that I sent a few days ago ("[PATCH 1/3] python/sepolicy: Support non-MLS policy"). With this I have been able to play with polgengui and have been surprised by a warning which appears on my terminal every time I type anything in the "name" field of the form in the second tab ("Enter name of application or user role:"):
polgengui.py:778: Warning:
g_value_get_int: assertion 'G_VALUE_HOLDS_INT(value)' failed
Gtk.main()
Quoted 6 lines
Quoted 3 lines
Have you got such warning on your system? Do you know where this warning comes from? For information I use Gtk3 3.22.26 with python-gobject 3.26.1.
I see it as well. I'll try to find the problem and sent a patch for that.
It's caused by line 624 in polgengui.py
624 self.name_entry.connect("insert_text", self.on_name_entry_changed)
According to [2][3] it's long term known problem. There's a suggested fix in [1] but I don't know how to apply it at this moment.
Given that it's not fatal and doesn't have a real impact on the code - you can't insert " " into Name value, I'd leave as it is for now.
[1] https://stackoverflow.com/questions/38815694/gtk-3-position-attribute-on-insert-text-signal-from-gtk-entry-is-always-0
[2] https://bugzilla.gnome.org/show_bug.cgi?id=644927
[3] https://gitlab.gnome.org/GNOME/pygobject/issues/12
There's another deprecation warning:
/usr/share/system-config-selinux/polgengui.py:679: PyGIDeprecationWarning: Deprecated, please use stop_emission_by_name.
entry.emit_stop_by_name("insert_text")
which seems to be easy to fix
gui/polgengui.py +1 -1
@@ -674,7 +674,7 @@ class childWindow: def on_name_entry_changed(self, entry, text, size, position): if text.find(" ") >= 0: - entry.emit_stop_by_name("insert_text") + entry.stop_emission_by_name("insert-text") def on_focus_out_event(self, entry, third): name = entry.get_text()
I'll send a patch for that.
Quoted 6 lines
Quoted 4 lines
Anyway, this looks like a harmless warning. Feel free to add "Tested-by: Nicolas Iooss <[email protected]>" to your patches.
Thanks!
Quoted 68 lines · Petr Lautrbach
Quoted 25 lines · Petr Lautrbach
Quoted 24 lines · Nicolas Iooss
Quoted 9 lines · Nicolas Iooss
Quoted 5 lines · Petr Lautrbach
Hi,
The following set of patches update
polgengui.py, rename polgen.glade to polgen.ui, convert it to new format, and fix some other sepolicy Python 3 related issues.Hi,
I have read and tested these patches and they look good to me.(Oops, the mail has been sent before I finished writing it...)
In order to run polgengui on my development system which uses a policy without MLS, I needed a patch in sepolicy, that I sent a few days ago ("[PATCH 1/3] python/sepolicy: Support non-MLS policy"). With this I have been able to play with polgengui and have been surprised by a warning which appears on my terminal every time I type anything in the "name" field of the form in the second tab ("Enter name of application or user role:"):
polgengui.py:778: Warning:
g_value_get_int: assertion 'G_VALUE_HOLDS_INT(value)' failed
Gtk.main()Quoted 6 lines
Quoted 3 lines
Have you got such warning on your system? Do you know where this warning comes from? For information I use Gtk3 3.22.26 with python-gobject 3.26.1.
I see it as well. I'll try to find the problem and sent a patch for that.
It's caused by line 624 in
polgengui.py624
self.name_entry.connect("insert_text", self.on_name_entry_changed)According to [2][3] it's long term known problem. There's a suggested fix in [1] but I don't know how to apply it at this moment.
Given that it's not fatal and doesn't have a real impact on the code - you can't insert " " into Name value, I'd leave as it is for now.
[1] https://stackoverflow.com/questions/38815694/gtk-3-position-attribute-on-insert-text-signal-from-gtk-entry-is-always-0
[2] https://bugzilla.gnome.org/show_bug.cgi?id=644927
[3] https://gitlab.gnome.org/GNOME/pygobject/issues/12There's another deprecation warning:
/usr/share/system-config-selinux/polgengui.py:679: PyGIDeprecationWarning: Deprecated, please usestop_emission_by_name.
entry.emit_stop_by_name("insert_text")which seems to be easy to fix
gui/polgengui.py +1
-1@@ -674,7 +674,7 @@ class childWindow: def on_name_entry_changed(self, entry, text, size, position): if text.find(" ") >= 0: - entry.emit_stop_by_name("insert_text") + entry.stop_emission_by_name("insert-text") def on_focus_out_event(self, entry, third): name = entry.get_text()
Quoted 1 line
I'll send a patch for that.
Excellent! Unfortunately I will be travelling the next ten days and I will not be able to review or test your patches before my return. The review can of course be done by another maintainer, so there is no issue.
Thanks,
Nicolas
Quoted 66 lines · Nicolas Iooss
Quoted 65 lines · Petr Lautrbach
Quoted 24 lines · Petr Lautrbach
Quoted 23 lines · Nicolas Iooss
Quoted 8 lines · Nicolas Iooss
Quoted 5 lines · Petr Lautrbach
Hi,
The following set of patches update
polgengui.py, rename polgen.glade to polgen.ui, convert it to new format, and fix some other sepolicy Python 3 related issues.Hi,
I have read and tested these patches and they look good to me.(Oops, the mail has been sent before I finished writing it...)
In order to run polgengui on my development system which uses a policy without MLS, I needed a patch in sepolicy, that I sent a few days ago ("[PATCH 1/3] python/sepolicy: Support non-MLS policy"). With this I have been able to play with polgengui and have been surprised by a warning which appears on my terminal every time I type anything in the "name" field of the form in the second tab ("Enter name of application or user role:"):
polgengui.py:778: Warning:
g_value_get_int: assertion 'G_VALUE_HOLDS_INT(value)' failed
Gtk.main()Quoted 5 lines
Quoted 3 lines
Have you got such warning on your system? Do you know where this warning comes from? For information I use Gtk3 3.22.26 with python-gobject 3.26.1.
I see it as well. I'll try to find the problem and sent a patch for that.
It's caused by line 624 in
polgengui.py624
self.name_entry.connect("insert_text", self.on_name_entry_changed)According to [2][3] it's long term known problem. There's a suggested fix in [1] but I don't know how to apply it at this moment.
Given that it's not fatal and doesn't have a real impact on the code - you can't insert " " into Name value, I'd leave as it is for now.
[1] https://stackoverflow.com/questions/38815694/gtk-3-position-attribute-on-insert-text-signal-from-gtk-entry-is-always-0
[2] https://bugzilla.gnome.org/show_bug.cgi?id=644927
[3] https://gitlab.gnome.org/GNOME/pygobject/issues/12There's another deprecation warning:
/usr/share/system-config-selinux/polgengui.py:679: PyGIDeprecationWarning: Deprecated, please usestop_emission_by_name.
entry.emit_stop_by_name("insert_text")which seems to be easy to fix
gui/polgengui.py +1
-1@@ -674,7 +674,7 @@ class childWindow: def on_name_entry_changed(self, entry, text, size, position): if text.find(" ") >= 0: - entry.emit_stop_by_name("insert_text") + entry.stop_emission_by_name("insert-text") def on_focus_out_event(self, entry, third): name = entry.get_text()
Quoted 7 lines
Quoted 1 line
I'll send a patch for that.
Excellent! Unfortunately I will be travelling the next ten days and I will not be able to review or test your patches before my return. The review can of course be done by another maintainer, so there is no issue.
Thanks, merged via https://github.com/SELinuxProject/selinux/pull/80