mirror of
https://github.com/X11Libre/xserver.git
synced 2026-11-15 05:23:40 +00:00
Some checks failed
Build X servers / ubuntu-fetch-pkg (push) Has been cancelled
Build X servers / xserver-build-ubuntu-no-gbm (push) Has been cancelled
Build X servers / xserver-build-ubuntu (push) Has been cancelled
Build X servers / abi-changes-check (push) Has been cancelled
Build X servers / xserver-build-ubuntu-debug (push) Has been cancelled
Build X servers / xserver-build-ubuntu-valgrind (push) Has been cancelled
Build X servers / ubuntu-deps-image (push) Has been cancelled
Build X servers / build-sdk-image (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-elographics:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-evdev:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-joystick:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-keyboard:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-libinput:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-mouse:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-synaptics:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-vmmouse:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-void:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (input-wacom:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-amdgpu:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-apm:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-ark:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-ast:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-ati:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-chips:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-cirrus:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-dummy:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-fbdev:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-freedreno:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-geode:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-i128:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-i740:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-intel:25.0.1) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-mach64:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-mga:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-neomagic:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-nested:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-nouveau:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-nv:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-omap:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-qxl:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-r128:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-rendition:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-s3virge:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-savage:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-siliconmotion:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-sis:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-sisusb:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-suncg14:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-suncg3:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-suncg6:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-sunffb:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-sunleo:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-suntcx:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-tdfx:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-trident:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-v4l:25.0.1) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-vbox:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-vesa:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-vmware:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-voodoo:25.0.0) (push) Has been cancelled
Build X servers / drivers-build-ubuntu (video-xgi:25.0.0) (push) Has been cancelled
Build X servers / xserver-build-mingw32-ubuntu (push) Has been cancelled
Build X servers / xserver-build-macos (push) Has been cancelled
Build X servers / xserver-build-freebsd (push) Has been cancelled
Build X servers / xserver-build-dragonflybsd (push) Has been cancelled
Build X servers / xserver-build-netbsd (push) Has been cancelled
Build X servers / xserver-build-solaris (push) Has been cancelled
Build X servers / xserver-build-openbsd (push) Has been cancelled
Build X servers / xserver-build-hurd (push) Has been cancelled
Build X servers / xserver-build-alpine (push) Has been cancelled
Build X servers / gentoo-deps-image (push) Has been cancelled
Build X servers / xserver-build-gentoo (push) Has been cancelled
Build X servers / xserver-build-rhel (10) (push) Has been cancelled
Build X servers / xserver-build-rhel (9) (push) Has been cancelled
Build X servers / xserver-build-cygwin (push) Has been cancelled
Build X servers / xserver-build-arch (push) Has been cancelled
Build X servers / Check Signed-Off-By (push) Has been cancelled
Build X servers / Release pushed tag (push) Has been cancelled
check PRs for merge conflicts / notify (push) Has been cancelled
XF86-BigFont lets local clients share font-metrics arrays via SysV shared memory (and compresses them for remote clients) -- a local-only optimization dating back to ancient XFree86. It hasn't been built by default for really long time. Enabling it in our CI immediately exposed that the code has bit-rotted on 7 non-Linux CI lanes (macOS/BSD: including a nonexistent Linux-only header; Solaris: an ARRAY_SIZE redefinition pulled in via its system headers; mingw32: implicit geteuid()/getegid() plus an unused variable). Concrete evidence that this extension currently has no real users exercising it, since none of that breakage was ever noticed. Therefore no practical need for carrying it around any longer. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
341 lines
11 KiB
C
341 lines
11 KiB
C
/***********************************************************
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
the above copyright notice appear in all copies and that both that
|
|
copyright notice and this permission notice appear in supporting
|
|
documentation.
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
All Rights Reserved
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
documentation for any purpose and without fee is hereby granted,
|
|
provided that the above copyright notice appear in all copies and that
|
|
both that copyright notice and this permission notice appear in
|
|
supporting documentation, and that the name of Digital not be
|
|
used in advertising or publicity pertaining to distribution of the
|
|
software without specific, written prior permission.
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
SOFTWARE.
|
|
|
|
******************************************************************/
|
|
|
|
#include <dix-config.h>
|
|
|
|
#include <X11/X.h>
|
|
#include <X11/Xproto.h>
|
|
|
|
#include "dix/dix_priv.h"
|
|
#include "dix/extension_priv.h"
|
|
#include "dix/registry_priv.h"
|
|
#include "dix/request_priv.h"
|
|
#include "include/misc.h"
|
|
#include "os/mathx_priv.h"
|
|
|
|
#include "dixstruct.h"
|
|
#include "extnsionst.h"
|
|
#include "gcstruct.h"
|
|
#include "scrnintstr.h"
|
|
#include "dispatch.h"
|
|
#include "privates.h"
|
|
#include "xace.h"
|
|
|
|
#define LAST_ERROR 255
|
|
|
|
CallbackListPtr ExtensionAccessCallback = NULL;
|
|
CallbackListPtr ExtensionDispatchCallback = NULL;
|
|
|
|
static ExtensionEntry **extensions = (ExtensionEntry **) NULL;
|
|
|
|
int lastEvent = EXTENSION_EVENT_BASE;
|
|
static int lastError = FirstExtensionError;
|
|
static unsigned int NumExtensions = RESERVED_EXTENSIONS;
|
|
|
|
static struct { const char *name; int id; } reservedExt[] = {
|
|
{ "BIG-REQUESTS", EXTENSION_MAJOR_BIG_REQUESTS },
|
|
{ "Apple-WM", EXTENSION_MAJOR_APPLE_WM },
|
|
{ "Apple-DRI", EXTENSION_MAJOR_APPLE_DRI },
|
|
{ "Composite", EXTENSION_MAJOR_COMPOSITE },
|
|
{ "DAMAGE", EXTENSION_MAJOR_DAMAGE },
|
|
{ "DOUBLE-BUFFER", EXTENSION_MAJOR_DOUBLE_BUFFER },
|
|
{ "DPMS", EXTENSION_MAJOR_DPMS },
|
|
{ "DRI2", EXTENSION_MAJOR_DRI2 },
|
|
{ "DRI3", EXTENSION_MAJOR_DRI3 },
|
|
{ "Generic Event Extension", EXTENSION_MAJOR_GENERIC_EVENT },
|
|
{ "GLX", EXTENSION_MAJOR_GLX },
|
|
{ "MIT-SCREEN-SAVER", EXTENSION_MAJOR_MIT_SCREEN_SAVER },
|
|
{ "NAMESPACE", EXTENSION_MAJOR_NAMESPACE },
|
|
{ "Present", EXTENSION_MAJOR_PRESENT },
|
|
{ "RANDR", EXTENSION_MAJOR_RANDR },
|
|
{ "RECORD", EXTENSION_MAJOR_RECORD },
|
|
{ "RENDER", EXTENSION_MAJOR_RENDER },
|
|
{ "SECURITY", EXTENSION_MAJOR_SECURITY },
|
|
{ "SELinux", EXTENSION_MAJOR_SELINUX },
|
|
{ "SHAPE", EXTENSION_MAJOR_SHAPE },
|
|
{ "MIT-SHM", EXTENSION_MAJOR_SHM },
|
|
{ "SYNC", EXTENSION_MAJOR_SYNC },
|
|
{ "Windows-DRI", EXTENSION_MAJOR_WINDOWS_DRI },
|
|
{ "XFIXES", EXTENSION_MAJOR_XFIXES },
|
|
{ "XFree86-DGA", EXTENSION_MAJOR_XF86_DGA },
|
|
{ "XFree86-DRI", EXTENSION_MAJOR_XF86_DRI },
|
|
{ "XFree86-VidModeExtension", EXTENSION_MAJOR_XF86_VIDMODE },
|
|
{ "XC-MISC", EXTENSION_MAJOR_XC_MISC },
|
|
{ "XInputExtension", EXTENSION_MAJOR_XINPUT },
|
|
{ "XINERAMA", EXTENSION_MAJOR_XINERAMA },
|
|
{ "XKEYBOARD", EXTENSION_MAJOR_XKEYBOARD },
|
|
{ "X-Resource", EXTENSION_MAJOR_XRESOURCE },
|
|
{ "XTEST", EXTENSION_MAJOR_XTEST },
|
|
{ "XVideo", EXTENSION_MAJOR_XVIDEO },
|
|
{ "XVideo-MotionCompensation", EXTENSION_MAJOR_XVMC },
|
|
};
|
|
|
|
static int checkReserved(const char* name)
|
|
{
|
|
for (int i=0; i<ARRAY_SIZE(reservedExt); i++) {
|
|
if (strcmp(name, reservedExt[i].name) == 0) {
|
|
if (reservedExt[i].id < (RESERVED_EXTENSIONS + EXTENSION_BASE))
|
|
return reservedExt[i].id;
|
|
FatalError("BUG: RESERVED_EXTENSIONS too small for %d\n", reservedExt[i].id);
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
ExtensionEntry *
|
|
AddExtension(const char *name, int NumEvents, int NumErrors,
|
|
int (*MainProc) (ClientPtr c1),
|
|
int (*SwappedMainProc) (ClientPtr c2),
|
|
void (*CloseDownProc) (ExtensionEntry * e),
|
|
unsigned short (*MinorOpcodeProc) (ClientPtr c3))
|
|
{
|
|
if (!extensions)
|
|
extensions = calloc(NumExtensions, sizeof(ExtensionEntry*));
|
|
if (!extensions)
|
|
return NULL;
|
|
|
|
if (!MainProc || !SwappedMainProc || !MinorOpcodeProc)
|
|
return ((ExtensionEntry *) NULL);
|
|
if ((lastEvent + NumEvents > MAXEVENTS) ||
|
|
(unsigned) (lastError + NumErrors > LAST_ERROR)) {
|
|
LogMessage(X_ERROR, "Not enabling extension %s: maximum number of "
|
|
"events or errors exceeded.\n", name);
|
|
return ((ExtensionEntry *) NULL);
|
|
}
|
|
|
|
ExtensionEntry *ext = calloc(1, sizeof(ExtensionEntry));
|
|
if (!ext)
|
|
return NULL;
|
|
if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION))
|
|
goto badalloc;
|
|
ext->name = strdup(name);
|
|
if (!ext->name)
|
|
goto badalloc;
|
|
|
|
int i = checkReserved(ext->name);
|
|
if (i == -1) {
|
|
i = NumExtensions;
|
|
ExtensionEntry **newexts = reallocarray(extensions, i + 1, sizeof(ExtensionEntry *));
|
|
if (!newexts)
|
|
goto badalloc;
|
|
|
|
NumExtensions++;
|
|
extensions = newexts;
|
|
} else {
|
|
i = i - EXTENSION_BASE;
|
|
}
|
|
|
|
extensions[i] = ext;
|
|
ext->index = i;
|
|
ext->base = i + EXTENSION_BASE;
|
|
ext->CloseDown = CloseDownProc;
|
|
ext->MinorOpcode = MinorOpcodeProc;
|
|
ProcVector[i + EXTENSION_BASE] = MainProc;
|
|
SwappedProcVector[i + EXTENSION_BASE] = SwappedMainProc;
|
|
if (NumEvents) {
|
|
ext->eventBase = lastEvent;
|
|
ext->eventLast = lastEvent + NumEvents;
|
|
lastEvent += NumEvents;
|
|
}
|
|
else {
|
|
ext->eventBase = 0;
|
|
ext->eventLast = 0;
|
|
}
|
|
if (NumErrors) {
|
|
ext->errorBase = lastError;
|
|
ext->errorLast = lastError + NumErrors;
|
|
lastError += NumErrors;
|
|
}
|
|
else {
|
|
ext->errorBase = 0;
|
|
ext->errorLast = 0;
|
|
}
|
|
|
|
#ifdef X_REGISTRY_REQUEST
|
|
RegisterExtensionNames(ext);
|
|
#endif
|
|
return ext;
|
|
|
|
badalloc:
|
|
if (ext) {
|
|
free((char*)ext->name);
|
|
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
|
|
free(ext);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* CheckExtension returns the extensions[] entry for the requested
|
|
* extension name. Maybe this could just return a Bool instead?
|
|
*/
|
|
ExtensionEntry *
|
|
CheckExtension(const char *extname)
|
|
{
|
|
if (!extensions)
|
|
return NULL;
|
|
|
|
for (int i = 0; i < NumExtensions; i++) {
|
|
if (extensions[i] &&
|
|
extensions[i]->name &&
|
|
strcmp(extensions[i]->name, extname) == 0) {
|
|
return extensions[i];
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/*
|
|
* Added as part of Xace.
|
|
*/
|
|
ExtensionEntry *
|
|
GetExtensionEntry(int major)
|
|
{
|
|
if ((major < EXTENSION_BASE) || !extensions)
|
|
return NULL;
|
|
major -= EXTENSION_BASE;
|
|
if (major >= NumExtensions)
|
|
return NULL;
|
|
return extensions[major];
|
|
}
|
|
|
|
unsigned short
|
|
StandardMinorOpcode(ClientPtr client)
|
|
{
|
|
return ((xReq *) client->requestBuffer)->data;
|
|
}
|
|
|
|
void
|
|
CloseDownExtensions(void)
|
|
{
|
|
if (!extensions)
|
|
return;
|
|
|
|
for (int i = NumExtensions - 1; i >= 0; i--) {
|
|
if (!extensions[i])
|
|
continue;
|
|
if (extensions[i]->CloseDown)
|
|
extensions[i]->CloseDown(extensions[i]);
|
|
NumExtensions = i;
|
|
free((void *) extensions[i]->name);
|
|
dixFreePrivates(extensions[i]->devPrivates, PRIVATE_EXTENSION);
|
|
free(extensions[i]);
|
|
extensions[i] = NULL;
|
|
}
|
|
free(extensions);
|
|
extensions = (ExtensionEntry **) NULL;
|
|
NumExtensions = RESERVED_EXTENSIONS;
|
|
lastEvent = EXTENSION_EVENT_BASE;
|
|
lastError = FirstExtensionError;
|
|
}
|
|
|
|
static Bool
|
|
ExtensionAvailable(ClientPtr client, ExtensionEntry *ext)
|
|
{
|
|
if (!ext)
|
|
return FALSE;
|
|
|
|
ExtensionAccessCallbackParam rec = { client, ext, DixGetAttrAccess, Success };
|
|
CallCallbacks(&ExtensionAccessCallback, &rec);
|
|
if (rec.status != Success)
|
|
return FALSE;
|
|
|
|
if (!ext->base)
|
|
return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
int
|
|
ProcQueryExtension(ClientPtr client)
|
|
{
|
|
X_REQUEST_HEAD_AT_LEAST(xQueryExtensionReq);
|
|
X_REQUEST_FIELD_CARD16(nbytes);
|
|
REQUEST_FIXED_SIZE(xQueryExtensionReq, stuff->nbytes);
|
|
|
|
xQueryExtensionReply reply = { 0 };
|
|
|
|
if (NumExtensions && extensions) {
|
|
char extname[PATH_MAX] = { 0 };
|
|
strncpy(extname, (char *) &stuff[1], MIN(stuff->nbytes, sizeof(extname)-1));
|
|
ExtensionEntry *extEntry = CheckExtension(extname);
|
|
|
|
if (extEntry && ExtensionAvailable(client, extEntry)) {
|
|
reply.present = xTrue;
|
|
reply.major_opcode = extEntry->base;
|
|
reply.first_event = extEntry->eventBase;
|
|
reply.first_error = extEntry->errorBase;
|
|
}
|
|
}
|
|
|
|
return X_SEND_REPLY_SIMPLE(client, reply);
|
|
}
|
|
|
|
int
|
|
ProcListExtensions(ClientPtr client)
|
|
{
|
|
REQUEST_SIZE_MATCH(xReq);
|
|
|
|
xListExtensionsReply reply = { 0 };
|
|
|
|
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
|
|
|
if (NumExtensions && extensions) {
|
|
for (int i = 0; i < NumExtensions; i++) {
|
|
if (!ExtensionAvailable(client, extensions[i]))
|
|
continue;
|
|
|
|
int len = strlen(extensions[i]->name);
|
|
|
|
reply.nExtensions++;
|
|
|
|
/* write a pascal string */
|
|
x_rpcbuf_write_CARD8(&rpcbuf, len);
|
|
x_rpcbuf_write_CARD8s(&rpcbuf, (CARD8*)extensions[i]->name, len);
|
|
}
|
|
}
|
|
|
|
return X_SEND_REPLY_WITH_RPCBUF(client, reply, rpcbuf);
|
|
}
|