How to use XACE hooks properly?

y2014conf at gmail.com y2014conf at gmail.com
Sun May 14 19:05:35 UTC 2023


Greetings!

What is the proper way to use XACE-hooks to deny clipboard "copy/paste"
operations for a certain application?

I try to use XACE-hooks to deny clipboard "copy/paste" operations for
"kwrite" text editor like this:

void MySelectionCallback(CallbackListPtr* /*pcbl*/, void* /*unused*/, void*
calldata)
{
   XaceSelectionAccessRec* rec = (XaceSelectionAccessRec*)calldata;
   // GetAppName is my function
   if (rec && DixReadAccess == rec->access_mode && !strcmp(GetAppName(rec),
"kwrite")) {
      rec->status = BadAccess;
   }
}

void MyPropertyCallback(CallbackListPtr* /*pcbl*/, void* /*unused*/, void*
calldata)
{
   XacePropertyAccessRec* rec = (XacePropertyAccessRec*)calldata;
   if (rec && !strcmp(GetAppName(rec), "kwrite")) {
      rec->status = BadAccess;
   }
}

But right after "paste" some text inside "kwrite" text editor X-server
crashes:

[   499.730] (EE)
[   499.730] (EE) Backtrace:
[   499.732] (EE) 0: /usr/lib/xorg/Xorg (OsLookupColor+0x139)
[0x5571b4800939]
[   499.733] (EE) 1: /lib/x86_64-linux-gnu/libc.so.6 (__sigaction+0x50)
[0x7f99a3a42520]
[   499.734] (EE) 2: /lib/x86_64-linux-gnu/libc.so.6 (pthread_kill+0x12c)
[0x7f99a3a96a7c]
[   499.734] (EE) 3: /lib/x86_64-linux-gnu/libc.so.6 (raise+0x16)
[0x7f99a3a42476]
[   499.735] (EE) 4: /lib/x86_64-linux-gnu/libc.so.6 (abort+0xd3)
[0x7f99a3a287f3]
[   499.736] (EE) 5: /lib/x86_64-linux-gnu/libc.so.6 (__fsetlocking+0x426)
[0x7f99a3a896f6]
[   499.736] (EE) 6: /lib/x86_64-linux-gnu/libc.so.6 (__fortify_fail+0x2a)
[0x7f99a3b3676a]
[   499.737] (EE) 7: /lib/x86_64-linux-gnu/libc.so.6
(__stack_chk_fail+0x16) [0x7f99a3b36736]
[   499.737] (EE) 8: /usr/lib/xorg/Xorg (XaceHookSelectionAccess+0x6c)
[0x5571b47380ec]
[   499.738] (EE) 9: /usr/lib/xorg/Xorg (dixLookupSelection+0x5a)
[0x5571b46b2e5a]
[   499.738] (EE) 10: /usr/lib/xorg/Xorg
(DeleteClientFromAnySelections+0x4ff) [0x5571b46b349f]
[   499.738] (EE) 11: /usr/lib/xorg/Xorg (SendErrorToClient+0x365)
[0x5571b468a4c5]
[   499.738] (EE) 12: /usr/lib/xorg/Xorg (InitFonts+0x3c4) [0x5571b468e544]
[   499.739] (EE) 13: /lib/x86_64-linux-gnu/libc.so.6
(__libc_init_first+0x90) [0x7f99a3a29d90]
[   499.740] (EE) 14: /lib/x86_64-linux-gnu/libc.so.6
(__libc_start_main+0x80) [0x7f99a3a29e40]
[   499.740] (EE) 15: /usr/lib/xorg/Xorg (_start+0x25) [0x5571b4677605]
[   499.740] (EE)
[   499.740] (EE)
Fatal server error:
[   499.740] (EE) Caught signal 6 (Aborted). Server aborting
[   499.740] (EE)

If remove "rec->status = BadAccess;" from selection callback then X-server
does not crash but "copy/paste" operations are still allowed for "kwrite"
text editor.

I use virtual machine with Ubuntu guest:

Distributor ID: Ubuntu
Description: Ubuntu 22.04.2 LTS
Release: 22.04
Codename: jammy

X.Org X Server 1.21.1.4
X Protocol Version 11, Revision 0

xorg-server 2:21.1.4-2ubuntu1.7~22.04.1
Current version of pixman: 0.40.0

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.x.org/archives/xorg/attachments/20230514/cadfdc44/attachment.htm>


More information about the xorg mailing list