[prev in list] [next in list] [prev in thread] [next in thread]
List: freedesktop-xorg
Subject: How to use XACE hooks properly?
From: "y2014conf () gmail ! com" <y2014conf () gmail ! com>
Date: 2023-05-14 19:05:35
Message-ID: CAHqYXJZ7HwPELxk=e1JZHYuripjEnJQEsx1+PkKZJ8NUr815mw () mail ! gmail ! com
[Download RAW message or body]
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.
[Attachment #3 (text/html)]
<div dir="ltr">Greetings!<br><br>What is the proper way to use XACE-hooks to deny \
clipboard "copy/paste" operations for a certain application?<br><br>I try \
to use XACE-hooks to deny clipboard "copy/paste" operations for \
"kwrite" text editor like this:<br><br>void \
MySelectionCallback(CallbackListPtr* /*pcbl*/, void* /*unused*/, void* \
calldata)<br>{<br> XaceSelectionAccessRec* rec = \
(XaceSelectionAccessRec*)calldata;<br> // GetAppName is my function<br> if \
(rec && DixReadAccess == rec->access_mode && \
!strcmp(GetAppName(rec), "kwrite")) {<br> rec->status = \
BadAccess;<br> }<br>}<br><br>void MyPropertyCallback(CallbackListPtr* /*pcbl*/, \
void* /*unused*/, void* calldata)<br>{<br> XacePropertyAccessRec* rec = \
(XacePropertyAccessRec*)calldata;<br> if (rec && !strcmp(GetAppName(rec), \
"kwrite")) {<br> rec->status = BadAccess;<br> \
}<br>}<br><br>But right after "paste" some text inside "kwrite" \
text editor X-server crashes:<br><br>[ 499.730] (EE) <br>[ 499.730] (EE) \
Backtrace:<br>[ 499.732] (EE) 0: /usr/lib/xorg/Xorg (OsLookupColor+0x139) \
[0x5571b4800939]<br>[ 499.733] (EE) 1: /lib/x86_64-linux-gnu/libc.so.6 \
(__sigaction+0x50) [0x7f99a3a42520]<br>[ 499.734] (EE) 2: \
/lib/x86_64-linux-gnu/libc.so.6 (pthread_kill+0x12c) [0x7f99a3a96a7c]<br>[ \
499.734] (EE) 3: /lib/x86_64-linux-gnu/libc.so.6 (raise+0x16) [0x7f99a3a42476]<br>[ \
499.735] (EE) 4: /lib/x86_64-linux-gnu/libc.so.6 (abort+0xd3) [0x7f99a3a287f3]<br>[ \
499.736] (EE) 5: /lib/x86_64-linux-gnu/libc.so.6 (__fsetlocking+0x426) \
[0x7f99a3a896f6]<br>[ 499.736] (EE) 6: /lib/x86_64-linux-gnu/libc.so.6 \
(__fortify_fail+0x2a) [0x7f99a3b3676a]<br>[ 499.737] (EE) 7: \
/lib/x86_64-linux-gnu/libc.so.6 (__stack_chk_fail+0x16) [0x7f99a3b36736]<br>[ \
499.737] (EE) 8: /usr/lib/xorg/Xorg (XaceHookSelectionAccess+0x6c) \
[0x5571b47380ec]<br>[ 499.738] (EE) 9: /usr/lib/xorg/Xorg \
(dixLookupSelection+0x5a) [0x5571b46b2e5a]<br>[ 499.738] (EE) 10: \
/usr/lib/xorg/Xorg (DeleteClientFromAnySelections+0x4ff) [0x5571b46b349f]<br>[ \
499.738] (EE) 11: /usr/lib/xorg/Xorg (SendErrorToClient+0x365) [0x5571b468a4c5]<br>[ \
499.738] (EE) 12: /usr/lib/xorg/Xorg (InitFonts+0x3c4) [0x5571b468e544]<br>[ \
499.739] (EE) 13: /lib/x86_64-linux-gnu/libc.so.6 (__libc_init_first+0x90) \
[0x7f99a3a29d90]<br>[ 499.740] (EE) 14: /lib/x86_64-linux-gnu/libc.so.6 \
(__libc_start_main+0x80) [0x7f99a3a29e40]<br>[ 499.740] (EE) 15: \
/usr/lib/xorg/Xorg (_start+0x25) [0x5571b4677605]<br>[ 499.740] (EE) <br>[ \
499.740] (EE) <br>Fatal server error:<br>[ 499.740] (EE) Caught signal 6 \
(Aborted). Server aborting<br>[ 499.740] (EE) <br><br>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.<br><br>I use virtual machine with Ubuntu \
guest:<br><br>Distributor ID: Ubuntu<br>Description: Ubuntu 22.04.2 \
LTS<br>Release: 22.04<br>Codename: jammy<br><br>X.Org X Server 1.21.1.4<br>X Protocol \
Version 11, Revision 0<br><br>xorg-server 2:21.1.4-2ubuntu1.7~22.04.1<br>Current \
version of pixman: 0.40.0<br><br>Thanks.<br><div><br></div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic