HACK: DEBUG

This commit is contained in:
Enrico Weigelt, metux IT consult 2025-03-19 13:53:26 +01:00
parent 0227a463c3
commit a853080724
5 changed files with 91 additions and 4 deletions

View File

@ -34,6 +34,9 @@ hookReceive(CallbackListPtr *pcbl, void *unused, void *calldata)
if (gev->extension == EXTENSION_MAJOR_XINPUT) {
switch (gev->evtype) {
case XI_RawMotion:
XNS_HOOK_LOG("RawMotion winid=0x%0x%s\n",
param->pWin->drawable.id,
isRootWin(param->pWin) ? " (root window)" : "");
if ((!subj->ns->allowMouseMotion) || !isRootWin(param->pWin))
goto reject;
continue;

View File

@ -36,6 +36,25 @@ void hookSelectionFilter(CallbackListPtr *pcbl, void *unused, void *calldata)
if (subj->ns->superPower)
return;
const char *op = "<>";
switch (param->op) {
case SELECTION_FILTER_GETOWNER:
op = "SELECTION_FILTER_GETOWNER";
break;
case SELECTION_FILTER_SETOWNER:
op = "SELECTION_FILTER_SETOWNER";
break;
case SELECTION_FILTER_CONVERT:
op = "SELECTION_FILTER_CONVERT";
break;
case SELECTION_FILTER_EV_REQUEST:
op = "SELECTION_FILTER_EV_REQUEST";
break;
case SELECTION_FILTER_EV_CLEAR:
op = "SELECTION_FILTER_EV_CLEAR";
break;
}
const char *origSelectionName = NameForAtom(param->selection);
char selname[PATH_MAX] = { 0 };
@ -47,6 +66,11 @@ void hookSelectionFilter(CallbackListPtr *pcbl, void *unused, void *calldata)
case SELECTION_FILTER_SETOWNER:
case SELECTION_FILTER_CONVERT:
case SELECTION_FILTER_LISTEN:
XNS_HOOK_LOG("%s origsel=%s (%d) newsel=%s (%d) -- using newsel\n", op,
origSelectionName,
param->selection,
selname,
realSelection);
// TODO: check whether window really belongs to the client
param->selection = realSelection;
break;
@ -55,13 +79,30 @@ void hookSelectionFilter(CallbackListPtr *pcbl, void *unused, void *calldata)
{
// need to translate back, since we're having the ns-prefixed name here
const char *stripped = stripNS(origSelectionName);
param->selection = MakeAtom(stripped, strlen(stripped), TRUE);
ATOM strippedAtom = MakeAtom(stripped, strlen(stripped), TRUE);
XNS_HOOK_LOG("NOTIFY stripped=\"%s\" atom=%d name=\"%s\n", stripped, strippedAtom, NameForAtom(strippedAtom));
XNS_HOOK_LOG("NOTIFY origID %d origName %s transID %d transName %s strippedName %s atom %d\n",
param->selection,
origSelectionName,
realSelection,
selname,
stripped,
strippedAtom);
param->selection = strippedAtom;
break;
}
// nothing to do here: already having the client visible name
case SELECTION_FILTER_EV_REQUEST:
case SELECTION_FILTER_EV_CLEAR:
XNS_HOOK_LOG("%s origsel=%s (%d) newsel=%s (%d) -- using origsel\n", op,
NameForAtom(param->selection),
param->selection,
selname,
realSelection);
break;
default:
XNS_HOOK_LOG("unknown op: %d selection=%d\n", param->op, param->selection);
break;
}
}

View File

@ -37,16 +37,40 @@ void hookWindowProperty(CallbackListPtr *pcbl, void *unused, void *calldata)
// whitelist anything that goes to caller's own namespace
struct XnamespaceClientPriv *obj = XnsClientPriv(owner);
if (XnsClientSameNS(subj, obj))
if (XnsClientSameNS(subj, obj)) {
XNS_HOOK_LOG("same NS window property %s (atom 0x%x) window 0x%0x of client %d\n",
NameForAtom(param->property),
param->property,
param->window,
owner->index);
return;
}
// allow access to namespace virtual root
if (param->window == subj->ns->rootWindow->drawable.id)
if (param->window == subj->ns->rootWindow->drawable.id) {
XNS_HOOK_LOG("NS virtual root window property %s (atom 0x%x) window 0x%0x of client %d\n",
NameForAtom(param->property),
param->property,
param->window,
owner->index);
return;
}
// redirect root window access to namespace's virtual root
if (dixWindowIsRoot(param->window)) {
XNS_HOOK_LOG("redirect root window property %s (atom 0x%x) window 0x%0x of client %d to 0x%x\n",
NameForAtom(param->property),
param->property,
param->window,
owner->index,
subj->ns->rootWindow->drawable.id);
param->window = subj->ns->rootWindow->drawable.id;
return;
}
XNS_HOOK_LOG("foreign NS window property %s (atom 0x%x) window 0x%0x of client %d\n",
NameForAtom(param->property),
param->property,
param->window,
owner->index);
}

View File

@ -1609,6 +1609,7 @@ ProcSyncAwait(ClientPtr client)
SyncAwait *pAwait;
int status;
// not sure whether we need to filter here
REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
len = client->req_len << 2;
@ -2059,6 +2060,7 @@ ProcSyncQueryFence(ClientPtr client)
return Success;
}
// not sure whether it needs to be filtered
static int
ProcSyncAwaitFence(ClientPtr client)
{

View File

@ -162,8 +162,10 @@ ProcXISelectEvents(ClientPtr client)
rc = dixLookupWindow(&win, stuff->win, client, DixReceiveAccess);
// when access to the window is denied, just pretend everything's okay
if (rc == BadAccess)
if (rc == BadAccess) {
printf(" ==> ProcXISelectEvents() resource hook denied access to window 0x%0x\n", stuff->win);
return Success;
}
if (rc != Success)
return rc;
@ -296,6 +298,21 @@ ProcXISelectEvents(ClientPtr client)
evmask->mask_len * 4) != Success)
return BadValue;
{
CARD32 *bits = (CARD32*)&evmask[1];
printf("mask before: 0x%0x\n", *bits);
printf("subtracting: 0x%0x\n", (XI_RawKeyPressMask | XI_RawKeyReleaseMask |
XI_RawButtonPress | XI_RawButtonRelease |
XI_RawMotion | XI_RawTouchBegin | XI_RawTouchUpdate |
XI_RawTouchEnd));
// (*bits) &= ~(XI_RawKeyPressMask | XI_RawKeyReleaseMask |
// XI_RawButtonPress | XI_RawButtonRelease |
// XI_RawMotion | XI_RawTouchBegin | XI_RawTouchUpdate |
// XI_RawTouchEnd);
printf("mask after: 0x%0x\n", *bits);
}
// FIXME: possible buffer overflow ?
evmask =
(xXIEventMask *) (((unsigned char *) evmask) +
evmask->mask_len * 4);