Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrating from xpyb #111

Open
tedx opened this issue Sep 14, 2020 · 3 comments
Open

migrating from xpyb #111

tedx opened this issue Sep 14, 2020 · 3 comments

Comments

@tedx
Copy link

tedx commented Sep 14, 2020

I've got some old code that used xpyb to get and set the SELinux context of some X resources that I'm looking to port to python3. I've started to looking at using xcffib. But just playing around in the interpreter I got an exception when I tried to get a windows context:

import xcffib
import xcffib.xselinux
c = xcffib.connect()
c2 = xcffib.wrap(xcffib.ffi.cast("long", c._conn))
xselinux = c2(xcffib.xselinux.key)
xselinux.GetWindowContext(0x400139)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/xcffib-0.10.1-py3.6.egg/xcffib/xselinux.py", line 246, in GetWindowContext
return self.send_request(7, buf, GetWindowContextCookie, is_checked=is_checked)
File "/usr/local/lib/python3.6/site-packages/xcffib-0.10.1-py3.6.egg/xcffib/init.py", line 391, in send_request
seq = self.conn.send_request(flags, xcb_parts + 2, xcb_req)
File "/usr/local/lib/python3.6/site-packages/xcffib-0.10.1-py3.6.egg/xcffib/init.py", line 573, in wrapper
self.invalid()
File "/usr/local/lib/python3.6/site-packages/xcffib-0.10.1-py3.6.egg/xcffib/init.py", line 559, in invalid
raise ConnectionException(err)
xcffib.ConnectionException: xcb connection shutdown because extension not supported

I'm running on a centos7 box with:
libxcb-1.13-1.el7.x86_64
libxcb-devel-1.13-1.el7.x86_64
xcb-proto-1.13-4.el7.noarch

installed.
Any pointers as to what I'm doing wrong would be appreciated.

@tych0
Copy link
Owner

tych0 commented Sep 14, 2020 via email

@tedx
Copy link
Author

tedx commented Sep 14, 2020

for ext in xcffib.xproto.xprotoExtension(c).ListExtensions().reply().names:
print(ext.name.raw)

output:
b'Apple-DRI'
b'Apple-WM'
b'Generic Event Extension'
b'SHAPE'
b'MIT-SHM'
b'XInputExtension'
b'BIG-REQUESTS'
b'SYNC'
b'XKEYBOARD'
b'XC-MISC'
b'SECURITY'
b'XINERAMA'
b'XFIXES'
b'RENDER'
b'RANDR'
b'DAMAGE'
b'MIT-SCREEN-SAVER'
b'DOUBLE-BUFFER'
b'Present'
b'X-Resource'
b'XVideo'
b'GLX'
b'SGI-GLX'

so apparently the selinux extension isn't enabled. I don't recall doing anything in the old code to enable it and I see the extension shared library in the rpm:
rpm -ql libxcb
/usr/lib64/libxcb-composite.so.0
/usr/lib64/libxcb-composite.so.0.0.0
/usr/lib64/libxcb-damage.so.0
/usr/lib64/libxcb-damage.so.0.0.0
/usr/lib64/libxcb-dpms.so.0
/usr/lib64/libxcb-dpms.so.0.0.0
/usr/lib64/libxcb-dri2.so.0
/usr/lib64/libxcb-dri2.so.0.0.0
/usr/lib64/libxcb-dri3.so.0
/usr/lib64/libxcb-dri3.so.0.0.0
/usr/lib64/libxcb-glx.so.0
/usr/lib64/libxcb-glx.so.0.0.0
/usr/lib64/libxcb-present.so.0
/usr/lib64/libxcb-present.so.0.0.0
/usr/lib64/libxcb-randr.so.0
/usr/lib64/libxcb-randr.so.0.1.0
/usr/lib64/libxcb-record.so.0
/usr/lib64/libxcb-record.so.0.0.0
/usr/lib64/libxcb-render.so.0
/usr/lib64/libxcb-render.so.0.0.0
/usr/lib64/libxcb-res.so.0
/usr/lib64/libxcb-res.so.0.0.0
/usr/lib64/libxcb-screensaver.so.0
/usr/lib64/libxcb-screensaver.so.0.0.0
/usr/lib64/libxcb-shape.so.0
/usr/lib64/libxcb-shape.so.0.0.0
/usr/lib64/libxcb-shm.so.0
/usr/lib64/libxcb-shm.so.0.0.0
/usr/lib64/libxcb-sync.so.1
/usr/lib64/libxcb-sync.so.1.0.0
/usr/lib64/libxcb-xevie.so.0
/usr/lib64/libxcb-xevie.so.0.0.0
/usr/lib64/libxcb-xf86dri.so.0
/usr/lib64/libxcb-xf86dri.so.0.0.0
/usr/lib64/libxcb-xfixes.so.0
/usr/lib64/libxcb-xfixes.so.0.0.0
/usr/lib64/libxcb-xinerama.so.0
/usr/lib64/libxcb-xinerama.so.0.0.0
/usr/lib64/libxcb-xinput.so.0
/usr/lib64/libxcb-xinput.so.0.1.0
/usr/lib64/libxcb-xkb.so.1
/usr/lib64/libxcb-xkb.so.1.0.0
/usr/lib64/libxcb-xselinux.so.0
/usr/lib64/libxcb-xselinux.so.0.0.0
/usr/lib64/libxcb-xtest.so.0
/usr/lib64/libxcb-xtest.so.0.0.0
/usr/lib64/libxcb-xv.so.0
/usr/lib64/libxcb-xv.so.0.0.0
/usr/lib64/libxcb-xvmc.so.0
/usr/lib64/libxcb-xvmc.so.0.0.0
/usr/lib64/libxcb.so.1
/usr/lib64/libxcb.so.1.1.0

Is there something I need to do to enable it?

@tedx
Copy link
Author

tedx commented Sep 15, 2020

Oops the xserver I'm querying is on my Mac not the centos box I ssh'd into :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants