Bug 1253786 - sandbox -X is broken because of python3
sandbox -X is broken because of python3
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: policycoreutils (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Petr Lautrbach
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-08-14 13:18 EDT by Daniel Walsh
Modified: 2016-07-15 09:44 EDT (History)
7 users (show)

See Also:
Fixed In Version: 2.4-10.fc23
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-08-26 00:32:53 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Fix names for GTK 3 compatibility using the pygi-convert.sh tool (1.82 KB, patch)
2015-08-17 05:05 EDT, Petr Lautrbach
no flags Details | Diff

  None (edit)
Description Daniel Walsh 2015-08-14 13:18:55 EDT
sandbox -X evince
Traceback (most recent call last):
  File "/usr/bin/sandbox", line 500, in <module>
    rc = sandbox.main()
  File "/usr/bin/sandbox", line 488, in main
    return self.__execute()
  File "/usr/bin/sandbox", line 440, in __execute
    import gtk
ImportError: No module named 'gtk'
[Exit 1]
Comment 1 Petr Lautrbach 2015-08-17 05:05:35 EDT
Created attachment 1063726 [details]
Fix names for GTK 3 compatibility using the pygi-convert.sh tool

This patch should fix gtk 3 and python 3 related problems in sandbox. It'll part of the next update together with other similar fixes for other policycoreutils gui components.
Comment 2 Miroslav Grepl 2015-08-17 10:20:38 EDT
I see additional issue with this patch.

$ sandbox  -X -t sandbox_web_t firefox
/usr/bin/sandbox:440: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk
Traceback (most recent call last):
  File "/usr/share/sandbox/start", line 2, in <module>
    import gtk, subprocess, sys
ImportError: No module named 'gtk'
Comment 3 Miroslav Grepl 2015-08-17 11:14:16 EDT
(In reply to Miroslav Grepl from comment #2)
> I see additional issue with this patch.
> 
> $ sandbox  -X -t sandbox_web_t firefox
> /usr/bin/sandbox:440: PyGIWarning: Gtk was imported without specifying a
> version first. Use gi.require_version('Gtk', '3.0') before import to ensure
> that the right version gets loaded.
>   from gi.repository import Gtk
> Traceback (most recent call last):
>   File "/usr/share/sandbox/start", line 2, in <module>
>     import gtk, subprocess, sys
> ImportError: No module named 'gtk'

With fixes I see

$ sandbox -X -t sandbox_web_t firefox
sand
/usr/bin/sandbox:442: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk
Unable to init server: Could not connect: Connection refused
/usr/share/sandbox/start:2: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gt
Comment 4 Fedora Update System 2015-08-22 12:24:28 EDT
policycoreutils-2.4-10.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.\nIf you want to test the update, you can install it with \n su -c 'yum --enablerepo=updates-testing update policycoreutils'. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-13922
Comment 5 Fedora Update System 2015-08-26 00:32:47 EDT
policycoreutils-2.4-10.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.
Comment 6 Joachim Frieben 2016-05-28 16:51:46 EDT
Issue affects current Fedora 25 (rawhide) including package policycoreutils-2.5-9.fc25:

$ sandbox -X /usr/bin/firefox
Traceback (most recent call last):
  File "/usr/bin/sandbox", line 514, in <module>
    rc = sandbox.main()
  File "/usr/bin/sandbox", line 502, in main
    return self.__execute()
  File "/usr/bin/sandbox", line 454, in __execute
    import gtk
ImportError: No module named 'gtk'
Comment 7 Kahlil Hodgson 2016-07-04 21:05:10 EDT
Just did a DNF upgrade from 23 to 24 and am getting the same result as Joachim but with the older policycoreutils-2.5-5.fc24.x86_64:

<floki:~> sandbox -X -t sandbox_web_t firefox
Traceback (most recent call last):
  File "/usr/bin/sandbox", line 514, in <module>
    rc = sandbox.main()
  File "/usr/bin/sandbox", line 502, in main
    return self.__execute()
  File "/usr/bin/sandbox", line 454, in __execute
    import gtk
ImportError: No module named 'gtk'


Maybe an issue with the upgrade path?
Comment 8 w.chimiak 2016-07-15 09:44:38 EDT
I had the same problem.  I even tried just running the 
Fedora-Workstation-Live
and the same error comes up.  Putting in the changes from gtk to
Gtk still produced those errors.
With the change
#import gtk
                #dpi = str(gtk.settings_get_default().props.gtk_xft_dpi / 1024)
                #added  
                from gi.repository import Gtk
                import Gtk
                dpi = str(Gtk.settings_get_default().props.gtk_xft_dpi / 1024)
The error is
$ sandbox -X xterm
/usr/bin/sandbox:458: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk
Traceback (most recent call last):
  File "/usr/bin/sandbox", line 519, in <module>
    rc = sandbox.main()
  File "/usr/bin/sandbox", line 507, in main
    return self.__execute()
  File "/usr/bin/sandbox", line 459, in __execute
    import Gtk
ImportError: No module named 'Gtk'


With the original

                import gtk
                dpi = str(gtk.settings_get_default().props.gtk_xft_dpi / 1024)
I get 
$ sandbox -X xterm
Traceback (most recent call last):
  File "/usr/bin/sandbox", line 519, in <module>
    rc = sandbox.main()
  File "/usr/bin/sandbox", line 507, in main
    return self.__execute()
  File "/usr/bin/sandbox", line 455, in __execute
    import gtk
ImportError: No module named 'gtk'

With the FC23 code:
              from gi.repository import Gtk
              dpi = str(Gtk.Settings.get_default().props.gtk_xft_dpi/1024)
I get
./sandbox -X xterm
./sandbox:437: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import Gtk

Note You need to log in before you can comment on or make changes to this bug.