diff options
author | Enrico Weigelt, metux IT consult <info@metux.net> | 2024-05-17 15:17:27 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-06-23 21:07:48 +0000 |
commit | 47d6c3ad750f7dd645de0c7e11b5575a7b8a1e67 (patch) | |
tree | a06c0fe2461ca4b2c7af4bafb233e564b17b8c63 | |
parent | 0f6bb23bc22e7111f64f3adf5f1c3d0c4b672f1e (diff) |
xace: typesafe hook function for XACE_SERVER_ACCESS
he generic XaceHook() call isn't typesafe (und unnecessarily slow).
Better add an explicit function, just like we already have for others.
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1556>
-rw-r--r-- | Xext/xace.c | 15 | ||||
-rw-r--r-- | Xext/xace.h | 1 | ||||
-rw-r--r-- | dix/dispatch.c | 2 | ||||
-rw-r--r-- | dix/dixfonts.c | 8 | ||||
-rw-r--r-- | os/access.c | 2 | ||||
-rw-r--r-- | os/connection.c | 2 | ||||
-rw-r--r-- | xkb/xkb.c | 2 |
7 files changed, 16 insertions, 16 deletions
diff --git a/Xext/xace.c b/Xext/xace.c index f0c70553e..9c5e9ddd4 100644 --- a/Xext/xace.c +++ b/Xext/xace.c @@ -108,13 +108,19 @@ int XaceHookExtAccess(ClientPtr client, ExtensionEntry *ext) return rec.status; } +int XaceHookServerAccess(ClientPtr client, Mask access_mode) +{ + XaceServerAccessRec rec = { client, access_mode, Success }; + CallCallbacks(&XaceHooks[XACE_SERVER_ACCESS], &rec); + return rec.status; +} + /* Entry point for hook functions. Called by Xserver. */ int XaceHook(int hook, ...) { union { - XaceServerAccessRec server; XaceScreenAccessRec screen; XaceAuthAvailRec auth; XaceKeyAvailRec key; @@ -133,13 +139,6 @@ XaceHook(int hook, ...) * sets calldata directly to a single argument (with no return result) */ switch (hook) { - case XACE_SERVER_ACCESS: - u.server.client = va_arg(ap, ClientPtr); - u.server.access_mode = va_arg(ap, Mask); - - u.server.status = Success; /* default allow */ - prv = &u.server.status; - break; case XACE_SCREEN_ACCESS: case XACE_SCREENSAVER_ACCESS: u.screen.client = va_arg(ap, ClientPtr); diff --git a/Xext/xace.h b/Xext/xace.h index 1a88cab92..0de4a6355 100644 --- a/Xext/xace.h +++ b/Xext/xace.h @@ -90,6 +90,7 @@ int XaceHookSendAccess(ClientPtr client, DeviceIntPtr dev, WindowPtr win, int XaceHookReceiveAccess(ClientPtr client, WindowPtr win, xEventPtr ev, int count); int XaceHookClientAccess(ClientPtr client, ClientPtr target, Mask access_mode); int XaceHookExtAccess(ClientPtr client, ExtensionEntry *ext); +int XaceHookServerAccess(ClientPtr client, Mask access_mode); /* Register a callback for a given hook. diff --git a/dix/dispatch.c b/dix/dispatch.c index 4b339fc56..290534618 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -3288,7 +3288,7 @@ ProcListHosts(ClientPtr client) REQUEST_SIZE_MATCH(xListHostsReq); /* untrusted clients can't list hosts */ - result = XaceHook(XACE_SERVER_ACCESS, client, DixReadAccess); + result = XaceHookServerAccess(client, DixReadAccess); if (result != Success) return result; diff --git a/dix/dixfonts.c b/dix/dixfonts.c index 914ceb7a3..b85c5d282 100644 --- a/dix/dixfonts.c +++ b/dix/dixfonts.c @@ -812,7 +812,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, if (length > XLFDMAXFONTNAMELEN) return BadAlloc; - i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + i = XaceHookServerAccess(client, DixGetAttrAccess); if (i != Success) return i; @@ -1058,7 +1058,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, if (length > XLFDMAXFONTNAMELEN) return BadAlloc; - i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + i = XaceHookServerAccess(client, DixGetAttrAccess); if (i != Success) return i; @@ -1681,7 +1681,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) int SetFontPath(ClientPtr client, int npaths, unsigned char *paths) { - int err = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + int err = XaceHookServerAccess(client, DixManageAccess); if (err != Success) return err; @@ -1769,7 +1769,7 @@ GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result) int len; FontPathElementPtr fpe; - i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + i = XaceHookServerAccess(client, DixGetAttrAccess); if (i != Success) return i; diff --git a/os/access.c b/os/access.c index 546c78675..7d5e3b911 100644 --- a/os/access.c +++ b/os/access.c @@ -1299,7 +1299,7 @@ AuthorizedClient(ClientPtr client) return Success; /* untrusted clients can't change host access */ - rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + rc = XaceHookServerAccess(client, DixManageAccess); if (rc != Success) return rc; diff --git a/os/connection.c b/os/connection.c index 0f0f882fc..9047d7fc7 100644 --- a/os/connection.c +++ b/os/connection.c @@ -866,7 +866,7 @@ OnlyListenToOneClient(ClientPtr client) { int rc; - rc = XaceHook(XACE_SERVER_ACCESS, client, DixGrabAccess); + rc = XaceHookServerAccess(client, DixGrabAccess); if (rc != Success) return rc; @@ -6959,7 +6959,7 @@ ProcXkbSetDebuggingFlags(ClientPtr client) REQUEST(xkbSetDebuggingFlagsReq); REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq); - rc = XaceHook(XACE_SERVER_ACCESS, client, DixDebugAccess); + rc = XaceHookServerAccess(client, DixDebugAccess); if (rc != Success) return rc; |