xcffib icon indicating copy to clipboard operation
xcffib copied to clipboard

migrating from xpyb

Open tedx opened this issue 4 years ago • 3 comments

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.

tedx avatar Sep 14 '20 18:09 tedx

On Mon, Sep 14, 2020 at 11:06:19AM -0700, Ted X Toth wrote:

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.

Do you have the selinux extensions enabled? (i.e. what is the output of xffib.xproto.xprotoExtension(c).ListExtensions().reply().names?

tych0 avatar Sep 14 '20 21:09 tych0

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 avatar Sep 14 '20 22:09 tedx

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

tedx avatar Sep 15 '20 14:09 tedx