Index: Mk/Uses/display.mk =================================================================== --- Mk/Uses/display.mk +++ Mk/Uses/display.mk @@ -14,7 +14,7 @@ . endif . if !defined(DISPLAY) -BUILD_DEPENDS+= Xvfb:x11-servers/xorg-vfbserver \ +BUILD_DEPENDS+= Xvfb:x11-servers/xorg-server@Xvfb \ ${LOCALBASE}/share/fonts/misc/8x13O.pcf.gz:x11-fonts/xorg-fonts-miscbitmaps \ ${LOCALBASE}/share/fonts/misc/fonts.alias:x11-fonts/font-alias \ ${LOCALBASE}/share/X11/xkb/rules/base:x11/xkeyboard-config \ Index: Mk/Uses/xorg-cat.mk =================================================================== --- Mk/Uses/xorg-cat.mk +++ Mk/Uses/xorg-cat.mk @@ -17,7 +17,6 @@ # * proto install .pc file, needs pathfix, most only needed at # build time. # * util no particular notes -# * xserver xorg x servers # # These categories has to match upstream categories. Don't invent # your own. @@ -35,7 +34,7 @@ .if !defined(_INCLUDE_USES_XORG_CAT_MK) _INCLUDE_USES_XORG_CAT_MK=yes -_XORG_CATEGORIES= app data doc driver font lib proto util xserver +_XORG_CATEGORIES= app data doc driver font lib proto util _XORG_BUILDSYSTEMS= autotools meson _XORG_CAT= # empty @@ -163,21 +162,6 @@ . elif ${_XORG_CAT} == proto .include "${USESDIR}/pathfix.mk" -. elif ${_XORG_CAT} == xserver -DISTNAME?= xorg-server-${PORTVERSION} -CFLAGS+= -Werror=uninitialized -.include "${USESDIR}/pathfix.mk" -. if ${_XORG_BUILDSYS} == meson -# put meson stuff here -. else -CONFIGURE_ARGS+= --with-xkb-path=${LOCALBASE}/share/X11/xkb \ - --with-fontrootdir=${LOCALBASE}/share/fonts -libtool_ARGS?= # empty -.include "${USESDIR}/libtool.mk" -. endif -LIB_PC_DEPENDS+= ${LOCALBASE}/libdata/pkgconfig/dri.pc:graphics/mesa-dri -USE_XORG+= fontutil - . endif # ${_XORG_CAT} == # We only need to include xorg.mk if we want USE_XORG modules Index: net/tsclient/Makefile =================================================================== --- net/tsclient/Makefile +++ net/tsclient/Makefile @@ -34,7 +34,7 @@ .endif .if ${PORT_OPTIONS:MXNEST} -RUN_DEPENDS+= Xnest:x11-servers/xorg-nestserver +RUN_DEPENDS+= Xnest:x11-servers/xorg-server@Xnest .endif .include Index: www/selenium/Makefile =================================================================== --- www/selenium/Makefile +++ www/selenium/Makefile @@ -1,5 +1,6 @@ PORTNAME= selenium PORTVERSION= 4.1.3 +PORTREVISION= 1 CATEGORIES= www devel java MASTER_SITES= https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.1.0/ DISTNAME= selenium-server-${PORTVERSION} Index: www/selenium/pkg-message =================================================================== --- www/selenium/pkg-message +++ www/selenium/pkg-message @@ -7,7 +7,7 @@ With one or more of these complementary ports: www/geckodriver -x11-servers/xorg-vfbserver +x11-servers/xorg-server@Xvfb x11-fonts/xorg-fonts x11-fonts/webfonts x11/xauth Index: x11-servers/Makefile =================================================================== --- x11-servers/Makefile +++ x11-servers/Makefile @@ -5,10 +5,7 @@ SUBDIR += x2x SUBDIR += xarcan SUBDIR += xephyr - SUBDIR += xorg-dmx - SUBDIR += xorg-nestserver SUBDIR += xorg-server - SUBDIR += xorg-vfbserver SUBDIR += xwayland SUBDIR += xwayland-devel Index: x11-servers/xephyr/Makefile =================================================================== --- x11-servers/xephyr/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -PORTNAME= xephyr -PORTREVISION= 0 - -COMMENT= X server from X.Org based on kdrive - -LICENSE= MIT - -LIB_DEPENDS+= libxcb-image.so:x11/xcb-util-image \ - libxcb-icccm.so:x11/xcb-util-wm \ - libxcb-keysyms.so:x11/xcb-util-keysyms \ - libxcb-render-util.so:x11/xcb-util-renderutil \ - libxcb-util.so:x11/xcb-util - -MASTERDIR= ${.CURDIR}/../xorg-server -DESCR= ${.CURDIR}/pkg-descr - -SLAVE_PORT= yes -USE_XORG= x11 xcb - -CONFIGURE_ARGS+=--enable-xephyr --disable-dmx --disable-xnest --disable-xvfb \ - --enable-kdrive --disable-xwayland - -PLIST_FILES= bin/Xephyr man/man1/Xephyr.1.gz - -do-install: - cd ${WRKSRC}/hw/kdrive/ephyr; DESTDIR=${STAGEDIR} ${MAKE} install - -.include "${MASTERDIR}/Makefile" Index: x11-servers/xephyr/pkg-descr =================================================================== --- /dev/null +++ x11-servers/xephyr/pkg-descr @@ -1,5 +0,0 @@ -Xephyr is a kdrive server that outputs to a window on a pre-existing -'host' X display. Think Xnest but with support for modern extensions -like composite, damage and randr. - -WWW: https://www.x.org/ Index: x11-servers/xorg-dmx/Makefile =================================================================== --- x11-servers/xorg-dmx/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# Created by: lesi@FreeBSD.org - -PORTNAME= xorg-dmx -PORTREVISION= 0 - -COMMENT= Distributed Multihead X from X.Org - -LICENSE= MIT - -MASTERDIR= ${.CURDIR}/../xorg-server -DESCR= ${.CURDIR}/pkg-descr - -SLAVE_PORT= yes -USE_XORG= dmx xorgproto x11 xaw7 xext xfixes xi xmu xpm xrender xres xt xtst - -CONFIGURE_ARGS+=--enable-dmx --disable-xephyr --disable-xnest --disable-xvfb \ - --disable-xwayland - -do-install: - cd ${WRKSRC}/hw/dmx; DESTDIR=${STAGEDIR} ${MAKE} install - -.include "${MASTERDIR}/Makefile" Index: x11-servers/xorg-dmx/pkg-descr =================================================================== --- x11-servers/xorg-dmx/pkg-descr +++ /dev/null @@ -1,6 +0,0 @@ -Xdmx is proxy X server that provides multi-head support for multiple displays -attached to different machines (each of which is running a typical X server). -When Xinerama is used with Xdmx, the multiple displays on multiple machines -are presented to the user as a single unified screen. - -WWW: https://www.x.org/ Index: x11-servers/xorg-dmx/pkg-plist =================================================================== --- x11-servers/xorg-dmx/pkg-plist +++ /dev/null @@ -1,16 +0,0 @@ -bin/Xdmx -bin/dmxaddinput -bin/dmxaddscreen -bin/dmxinfo -bin/dmxreconfig -bin/dmxresize -bin/dmxrminput -bin/dmxrmscreen -bin/dmxtodmx -bin/dmxwininfo -bin/vdltodmx -bin/xdmxconfig -man/man1/Xdmx.1.gz -man/man1/dmxtodmx.1.gz -man/man1/vdltodmx.1.gz -man/man1/xdmxconfig.1.gz Index: x11-servers/xorg-nestserver/pkg-descr =================================================================== --- /dev/null +++ x11-servers/xorg-nestserver/pkg-descr @@ -1,3 +0,0 @@ -This package contains Xnest, a nesting X Server that displays on an X Server. - -WWW: https://www.x.org/ Index: x11-servers/xorg-server/Makefile =================================================================== --- x11-servers/xorg-server/Makefile +++ x11-servers/xorg-server/Makefile @@ -1,7 +1,7 @@ # Created by: Eric Anholt -PORTNAME?= xorg-server -PORTVERSION?= 1.20.14 +PORTNAME?= xorg +PORTVERSION?= 21.1.3 PORTREVISION?= 0 PORTEPOCH?= 1 CATEGORIES= x11-servers @@ -13,31 +13,81 @@ LICENSE= MIT +FLAVORS= xorg Xnest Xephyr Xvfb +FLAVOR?= ${FLAVORS:[1]} + +EXTRA_PATCHES= ${FILESDIR}/0001-xkb-fix-XkbSetMap-when-changing-a-keysym-without-cha.patch:-p1 \ + ${FILESDIR}/0003-dix_Correctly_save_replayed_event_into_GrabInfoRec.patch:-p1 \ + ${FILESDIR}/0002-xephyr_Dont_check_for_SeatId_anymore.patch:-p1 \ + ${FILESDIR}/0004-present_Check_for_NULL_to_prevent_crash.patch:-p1 + +USES= compiler:c11 cpe gl meson pkgconfig ssl tar:xz xorg +USE_GL+= gl + +.if ${FLAVOR} == Xephyr +PORTNAME= xephyr +.elif ${FLAVOR} == xorg +PKGNAMESUFFIX= -server +.elif ${FLAVOR} == Xnest +PORTEPOCH= 2 +PKGNAMESUFFIX= -nestserver +.elif ${FLAVOR} == Xvfb +PKGNAMESUFFIX= -vfbserver +.endif + +.if ${FLAVOR} != xorg +PLIST= +PKGMESSAGE= +PLIST_FILES= bin/${FLAVOR} \ + man/man1/${FLAVOR}.1.gz +PLIST_DIRS= /var/db/xkb +.endif + +DESCR= ${.CURDIR}/pkg-descr-${FLAVOR} + +BUILD_DEPENDS+= ${LOCALBASE}/libdata/pkgconfig/dri.pc:graphics/mesa-dri RUN_DEPENDS+= xkeyboard-config>=2.5:x11/xkeyboard-config \ xkbcomp:x11/xkbcomp -SLAVE_PORT?= no +MESON_ARGS+= -Dxwin=false \ + -Dxquartz=false \ + -Ddtrace=false \ + -Dhal=false \ + -Dsystemd_logind=false \ + -Dxselinux=false \ + -Dfallback_input_driver=libinput \ + -Ddocs=false \ + -Dudev_kms=false \ + -Dxcsecurity=true \ + -Dsha1=libmd \ + -Dxkb_dir=${LOCALBASE}/share/X11/xkb \ + -Dxkb_output_dir=/var/db/xkb \ + -D${FLAVOR:tl}=true + +.for f in ${FLAVORS:N${FLAVOR}} +MESON_ARGS+= -D${f:tl}=false +.endfor + +.if ${FLAVOR} == xorg +LIB_DEPENDS+= libudev.so:devel/libudev-devd \ + libxcvt.so:x11/libxcvt +MESON_ARGS+= -Dudev=true OPTIONS_SUB= yes OPTIONS_DEFINE+= SUID -OPTIONS_RADIO= CONF -OPTIONS_RADIO_CONF= DEVD UDEV -OPTIONS_DEFAULT= SUID UDEV -OPTIONS_DEFAULT+= ${OPTIONS_DEFAULT_${OPSYS}_${OSREL:R}} SUID_DESC= Install setuid wrapper to allow startx as non-root -CONF_DESC= Backend to use for input device configuration -DEVD_DESC= Use devd for autoconfiguration of input devices -UDEV_DESC= Use udev via libudev-devd for autoconfiguration of input devices -DEVD_CONFIGURE_ENABLE= config-devd -SUID_CONFIGURE_ENABLE= suid-wrapper -SUID_CONFIGURE_ON= --libexecdir=${PREFIX}/bin # set SUID_WRAPPER_DIR -UDEV_CONFIGURE_ENABLE= config-udev -UDEV_CONFIGURE_ON= --disable-config-udev-kms -UDEV_LIB_DEPENDS= libudev.so:devel/libudev-devd +SUID_MESON_TRUE= suid_wrapper +.else +MESON_ARGS+= -Dudev=false +.endif -.include +.if ${FLAVOR} == xorg || ${FLAVOR} == Xephyr +MESON_ARGS+= -Ddrm=true +LIB_DEPENDS+= libdrm.so:graphics/libdrm \ + libepoxy.so:graphics/libepoxy +.endif FONTPATH_ROOT?= ${LOCALBASE}/share/fonts FONTPATHD?= ${PREFIX}/etc/X11/fontpath.d @@ -49,39 +99,17 @@ ${FONTPATH_ROOT}/100dpi/ \ ${FONTPATH_ROOT}/75dpi/ \ catalogue:${FONTPATHD} +MESON_ARGS+= -Ddefault_font_path=${DEFAULT_FONTPATH_LIST:ts,} PLIST_SUB+= FONTPATHD="${FONTPATHD:S,^${PREFIX}/,,}" -USES= compiler:c11 cpe gl gmake perl5 ssl tar:xz xorg xorg-cat:xserver -USE_PERL5= build USE_GL+= gl USE_XORG+= pixman xau xdmcp xfont2 xkbfile xorgproto xshmfence xtrans -CONFIGURE_ARGS+=--without-doxygen --without-xmlto --without-fop \ - --with-default-font-path="${DEFAULT_FONTPATH_LIST:ts,}" \ - --without-dtrace --disable-config-hal \ - --disable-install-setuid --disable-unit-tests \ - --with-fallback-input-driver=libinput -INSTALL_TARGET= install-strip CPE_VENDOR= x.org CPE_PRODUCT= xorg-server -.if ${SLAVE_PORT} == "no" || ${PORTNAME} == "xephyr" || ${PORTNAME} == "xwayland" -LIB_DEPENDS+= libdrm.so:graphics/libdrm \ - libepoxy.so:graphics/libepoxy -.else -BUILD_DEPENDS+= libepoxy>0:graphics/libepoxy # only for configure -.endif - -.if ${SLAVE_PORT} == "no" +.if ${FLAVOR} == xorg USE_GL+= gbm USE_XORG+= pciaccess -CONFIGURE_ARGS+=--disable-dmx --disable-xephyr --disable-xnest --disable-xvfb \ - --disable-xwayland --enable-xcsecurity -SUB_FILES= pkg-install pkg-deinstall -.else -CONFIGURE_ARGS+= --disable-xorg -OPTIONS_EXCLUDE= DEVD UDEV SUID -# Set PLIST for slave ports so they only need to set PLIST_FILES -PLIST= ${.CURDIR}/pkg-plist .endif .include @@ -103,11 +131,7 @@ PLIST_SUB+= SPARC64="@comment " .endif -post-patch: - @${REINPLACE_CMD} 's/test.*-traditional.*;/true;/' \ - ${WRKSRC}/configure - -.if ${SLAVE_PORT} == "no" +.if ${FLAVOR} == xorg post-install: # Avoid conflict with nvidia-driver, move libglx.so into .xorg directory @${MKDIR} ${STAGEDIR}${PREFIX}/lib/xorg/modules/extensions/.xorg @@ -118,6 +142,18 @@ @${MKDIR} ${STAGEDIR}${PREFIX}/share/X11/xorg.conf.d @${INSTALL_DATA} ${FILESDIR}/20-evdev-kbd.conf \ ${STAGEDIR}${PREFIX}/share/X11/xorg.conf.d -.endif # ! SLAVE_PORT + ${MKDIR} -p ${STAGEDIR}/var/db/xkb +.else +post-install: + ${RM} -r ${STAGEDIR}${PREFIX}/lib/xorg/protocol.txt + ${RMDIR} ${STAGEDIR}${PREFIX}/lib/xorg + ${RM} ${STAGEDIR}${PREFIX}/man/man1/Xserver.1 + ${MKDIR} -p ${STAGEDIR}/var/db/xkb +.endif + +post-install-SUID-on: + ${RM} ${STAGEDIR}${PREFIX}/bin/X + ${RLN} ${STAGEDIR}${PREFIX}/libexec/Xorg.wrap ${STAGEDIR}${PREFIX}/bin/X + ${MV} -f ${STAGEDIR}${PREFIX}/libexec/Xorg ${STAGEDIR}${PREFIX}/bin/Xorg .include Index: x11-servers/xorg-server/distinfo =================================================================== --- x11-servers/xorg-server/distinfo +++ x11-servers/xorg-server/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1639835065 -SHA256 (xorg/xserver/xorg-server-1.20.14.tar.xz) = 5cc5b70b9be89443e2594b93656c60bd5e82cd7f01deb4ce4faf81dcf546a16b -SIZE (xorg/xserver/xorg-server-1.20.14.tar.xz) = 5178288 +TIMESTAMP = 1656505333 +SHA256 (xorg-server-21.1.3.tar.xz) = 61d6aad5b6b47a116b960bd7f0cba4ee7e6da95d6bb0b127bde75d7d1acdebe5 +SIZE (xorg-server-21.1.3.tar.xz) = 4955948 Index: x11-servers/xorg-server/files/0001-xkb-fix-XkbSetMap-when-changing-a-keysym-without-cha.patch =================================================================== --- /dev/null +++ x11-servers/xorg-server/files/0001-xkb-fix-XkbSetMap-when-changing-a-keysym-without-cha.patch @@ -0,0 +1,87 @@ +From 0217cc6e0cf5013366105a90f5f91ccc4bab5425 Mon Sep 17 00:00:00 2001 +From: Samuel Thibault +Date: Wed, 26 Jan 2022 00:05:55 +0100 +Subject: [PATCH] xkb: fix XkbSetMap when changing a keysym without changing a + keytype + +As the comment says: + +"symsPerKey/mapWidths must be filled regardless of client-side flags" + +so we always have to call CheckKeyTypes which will notably fill mapWidths +and nTypes. That is needed for CheckKeySyms to work since it checks the +width. Without it, any request with XkbKeySymsMask but not +XkbKeyTypesMask will fail because of the missing width information, for +instance this: + + XkbDescPtr xkb; + if (!(xkb = XkbGetMap (dpy, XkbKeyTypesMask|XkbKeySymsMask, XkbUseCoreKbd))) { + fprintf (stderr, "ERROR getting map\n"); + exit(1); + } + XFlush (dpy); + XSync (dpy, False); + + XkbMapChangesRec changes = { .changed = 0 }; + int oneGroupType[XkbNumKbdGroups] = { XkbOneLevelIndex }; + + if (XkbChangeTypesOfKey(xkb, keycode, 1, XkbGroup1Mask, oneGroupType, &changes)) { + fprintf(stderr, "ERROR changing type of key\n"); + exit(1); + } + XkbKeySymEntry(xkb,keycode,0,0) = keysym; + + if (!XkbChangeMap(dpy,xkb,&changes)) { + fprintf(stderr, "ERROR changing map\n"); + exit(1); + } + + XkbFreeKeyboard (xkb, 0, TRUE); + XFlush (dpy); + XSync (dpy, False); + +This had being going under the radar since about ever until commit +de940e06f8733d87bbb857aef85d830053442cfe ("xkb: fix key type index check +in _XkbSetMapChecks") fixed checking the values of kt_index, which was +previously erroneously ignoring errors and ignoring all other checks, just +because nTypes was not set, precisely because CheckKeyTypes was not called. + +Note: yes, CheckKeyTypes is meant to be callable without XkbKeyTypesMask, it +does properly check for that and just fills nTypes and mapWidths in that +case. + +Signed-off-by: Samuel Thibault +Signed-off-by: Laurent Carlier +--- + xkb/xkb.c | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/xkb/xkb.c b/xkb/xkb.c +index bfc21de00..820cd7166 100644 +--- a/xkb/xkb.c ++++ b/xkb/xkb.c +@@ -2511,16 +2511,15 @@ _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req, + } + } + +- if (!(req->present & XkbKeyTypesMask)) { +- nTypes = xkb->map->num_types; +- } +- else if (!CheckKeyTypes(client, xkb, req, (xkbKeyTypeWireDesc **) &values, +- &nTypes, mapWidths, doswap)) { ++ /* nTypes/mapWidths/symsPerKey must be filled for further tests below, ++ * regardless of client-side flags */ ++ ++ if (!CheckKeyTypes(client, xkb, req, (xkbKeyTypeWireDesc **) &values, ++ &nTypes, mapWidths, doswap)) { + client->errorValue = nTypes; + return BadValue; + } + +- /* symsPerKey/mapWidths must be filled regardless of client-side flags */ + map = &xkb->map->key_sym_map[xkb->min_key_code]; + for (i = xkb->min_key_code; i < xkb->max_key_code; i++, map++) { + register int g, ng, w; +-- +2.35.1 + Index: x11-servers/xorg-server/files/0002-xephyr_Dont_check_for_SeatId_anymore.patch =================================================================== --- /dev/null +++ x11-servers/xorg-server/files/0002-xephyr_Dont_check_for_SeatId_anymore.patch @@ -0,0 +1,63 @@ +From 4c03b67d334b05b814239420776f2fdd4c4a98ac Mon Sep 17 00:00:00 2001 +From: nerdopolis +Date: Tue, 11 Jan 2022 18:41:42 -0500 +Subject: [PATCH] xephyr: Don't check for SeatId anymore + +After a change for the xserver to automatically determine the seat +based on the XDG_SEAT variable, xephyr stopped working. This was +because of an old feature where xephyr used to handle evdev +directly. This was dropped some time ago, and now this check is +not needed +--- + hw/kdrive/ephyr/ephyrinit.c | 34 ++++++++++++++++------------------ + 1 file changed, 16 insertions(+), 18 deletions(-) + +diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c +index 020461db2..09cd28cb3 100644 +--- a/hw/kdrive/ephyr/ephyrinit.c ++++ b/hw/kdrive/ephyr/ephyrinit.c +@@ -70,25 +70,23 @@ InitInput(int argc, char **argv) + KdKeyboardInfo *ki; + KdPointerInfo *pi; + +- if (!SeatId) { +- KdAddKeyboardDriver(&EphyrKeyboardDriver); +- KdAddPointerDriver(&EphyrMouseDriver); +- +- if (!kdHasKbd) { +- ki = KdNewKeyboard(); +- if (!ki) +- FatalError("Couldn't create Xephyr keyboard\n"); +- ki->driver = &EphyrKeyboardDriver; +- KdAddKeyboard(ki); +- } ++ KdAddKeyboardDriver(&EphyrKeyboardDriver); ++ KdAddPointerDriver(&EphyrMouseDriver); ++ ++ if (!kdHasKbd) { ++ ki = KdNewKeyboard(); ++ if (!ki) ++ FatalError("Couldn't create Xephyr keyboard\n"); ++ ki->driver = &EphyrKeyboardDriver; ++ KdAddKeyboard(ki); ++ } + +- if (!kdHasPointer) { +- pi = KdNewPointer(); +- if (!pi) +- FatalError("Couldn't create Xephyr pointer\n"); +- pi->driver = &EphyrMouseDriver; +- KdAddPointer(pi); +- } ++ if (!kdHasPointer) { ++ pi = KdNewPointer(); ++ if (!pi) ++ FatalError("Couldn't create Xephyr pointer\n"); ++ pi->driver = &EphyrMouseDriver; ++ KdAddPointer(pi); + } + + KdInitInput(); +-- +GitLab + Index: x11-servers/xorg-server/files/0003-dix_Correctly_save_replayed_event_into_GrabInfoRec.patch =================================================================== --- /dev/null +++ x11-servers/xorg-server/files/0003-dix_Correctly_save_replayed_event_into_GrabInfoRec.patch @@ -0,0 +1,98 @@ +From 6ef5c05728f8b18170fbc8415d7502495a08670b Mon Sep 17 00:00:00 2001 +From: Povilas Kanapickas +Date: Sun, 23 Jan 2022 22:18:52 +0200 +Subject: [PATCH] dix: Correctly save replayed event into GrabInfoRec + +When processing events we operate on InternalEvent pointers. They may +actually refer to a an instance of DeviceEvent, GestureEvent or any +other event that comprises the InternalEvent union. This works well in +practice because we always look into event type before doing anything, +except in the case of copying the event. + +*dst_event = *src_event would copy whole InternalEvent event and would +cause out of bounds read in case the pointed to event was not +InternalEvent but e.g. DeviceEvent. + +This regression has been introduced in +23a8b62d34344575f9df9d057fb74bfefa94a77b. + +Fixes https://gitlab.freedesktop.org/xorg/xserver/-/issues/1261 + +Signed-off-by: Povilas Kanapickas +--- + Xi/exevents.c | 2 +- + dix/events.c | 18 ++++++++++++++++-- + include/input.h | 1 + + 3 files changed, 18 insertions(+), 3 deletions(-) + +diff --git a/Xi/exevents.c b/Xi/exevents.c +index 94b9983bd..217baa956 100644 +--- a/Xi/exevents.c ++++ b/Xi/exevents.c +@@ -1524,7 +1524,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, + g = AllocGrab(devgrab); + BUG_WARN(!g); + +- *dev->deviceGrab.sync.event = *ev; ++ CopyPartialInternalEvent(dev->deviceGrab.sync.event, ev); + + /* The listener array has a sequence of grabs and then one event + * selection. Implicit grab activation occurs through delivering an +diff --git a/dix/events.c b/dix/events.c +index 341c746d4..28d7d177c 100644 +--- a/dix/events.c ++++ b/dix/events.c +@@ -467,6 +467,20 @@ WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent *ev) + return xi2mask_isset(inputMasks->xi2mask, dev, evtype); + } + ++/** ++ * When processing events we operate on InternalEvent pointers. They may actually refer to a ++ * an instance of DeviceEvent, GestureEvent or any other event that comprises the InternalEvent ++ * union. This works well in practice because we always look into event type before doing anything, ++ * except in the case of copying the event. Any copying of InternalEvent should use this function ++ * instead of doing *dst_event = *src_event whenever it's not clear whether source event actually ++ * points to full InternalEvent instance. ++ */ ++void ++CopyPartialInternalEvent(InternalEvent* dst_event, const InternalEvent* src_event) ++{ ++ memcpy(dst_event, src_event, src_event->any.length); ++} ++ + Mask + GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients * other) + { +@@ -3873,7 +3887,7 @@ void ActivateGrabNoDelivery(DeviceIntPtr dev, GrabPtr grab, + + if (grabinfo->sync.state == FROZEN_NO_EVENT) + grabinfo->sync.state = FROZEN_WITH_EVENT; +- *grabinfo->sync.event = *real_event; ++ CopyPartialInternalEvent(grabinfo->sync.event, real_event); + } + + static BOOL +@@ -4455,7 +4469,7 @@ FreezeThisEventIfNeededForSyncGrab(DeviceIntPtr thisDev, InternalEvent *event) + case FREEZE_NEXT_EVENT: + grabinfo->sync.state = FROZEN_WITH_EVENT; + FreezeThaw(thisDev, TRUE); +- *grabinfo->sync.event = *event; ++ CopyPartialInternalEvent(grabinfo->sync.event, event); + break; + } + } +diff --git a/include/input.h b/include/input.h +index b1aef3663..cdb5d5a90 100644 +--- a/include/input.h ++++ b/include/input.h +@@ -676,6 +676,7 @@ extern void GestureEmitGestureEndToOwner(DeviceIntPtr dev, GestureInfoPtr gi); + extern void ProcessGestureEvent(InternalEvent *ev, DeviceIntPtr dev); + + /* misc event helpers */ ++extern void CopyPartialInternalEvent(InternalEvent* dst_event, const InternalEvent* src_event); + extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients); + extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event); + extern Bool WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent *ev); +-- +GitLab + Index: x11-servers/xorg-server/files/0004-present_Check_for_NULL_to_prevent_crash.patch =================================================================== --- /dev/null +++ x11-servers/xorg-server/files/0004-present_Check_for_NULL_to_prevent_crash.patch @@ -0,0 +1,43 @@ +From 69774044716039fa70655b3bc6dd6a4ff4535cfd Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?B=C5=82a=C5=BCej=20Szczygie=C5=82?= +Date: Thu, 13 Jan 2022 00:47:27 +0100 +Subject: [PATCH] present: Check for NULL to prevent crash +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1275 +Signed-off-by: Błażej Szczygieł +Tested-by: Aaron Plattner +(cherry picked from commit 22d5818851967408bb7c903cb345b7ca8766094c) +--- + present/present_scmd.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/present/present_scmd.c b/present/present_scmd.c +index da836ea6b..239055bc1 100644 +--- a/present/present_scmd.c ++++ b/present/present_scmd.c +@@ -158,6 +158,9 @@ present_scmd_get_crtc(present_screen_priv_ptr screen_priv, WindowPtr window) + if (!screen_priv->info) + return NULL; + ++ if (!screen_priv->info->get_crtc) ++ return NULL; ++ + return (*screen_priv->info->get_crtc)(window); + } + +@@ -196,6 +199,9 @@ present_flush(WindowPtr window) + if (!screen_priv->info) + return; + ++ if (!screen_priv->info->flush) ++ return; ++ + (*screen_priv->info->flush) (window); + } + +-- +GitLab + Index: x11-servers/xorg-server/files/config_Makefile.am =================================================================== --- x11-servers/xorg-server/files/config_Makefile.am +++ /dev/null @@ -1,16 +0,0 @@ -* Build the devd config backend if activated -* ---- config/Makefile.am.orig 2017-03-16 05:24:43 UTC -+++ config/Makefile.am -@@ -4,6 +4,11 @@ noinst_LTLIBRARIES = libconfig.la - libconfig_la_SOURCES = config.c config-backends.h - libconfig_la_LIBADD = - -+if CONFIG_DEVD -+libconfig_la_SOURCES += devd.c -+libconfig_la_LIBADD += -lusbhid -+endif -+ - if NEED_DBUS - AM_CFLAGS += $(DBUS_CFLAGS) - libconfig_la_SOURCES += dbus-core.c Index: x11-servers/xorg-server/files/configure.ac =================================================================== --- x11-servers/xorg-server/files/configure.ac +++ /dev/null @@ -1,97 +0,0 @@ -* Plumb the devd config backend into configure -* -* define USE_DEV_IO for ARM platforms -* -* Only run pkg-config for udev if it is not disabled to prevent over-linking -* -* Automatically use systemd/logind only on Linux -* ---- configure.ac.orig 2017-03-15 18:05:25 UTC -+++ configure.ac -@@ -266,9 +266,12 @@ case $host_cpu in - esac - GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee" - ;; -- arm*) -+ arm*|aarch64*|riscv*) - ARM_VIDEO=yes - DEFAULT_INT10="stub" -+ case $host_os in -+ *freebsd*) AC_DEFINE(USE_DEV_IO) ;; -+ esac - ;; - i*86) - I386_VIDEO=yes -@@ -565,6 +568,7 @@ AC_ARG_ENABLE(xcsecurity, AS_HELP_ST - AC_ARG_ENABLE(dbe, AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes]) - AC_ARG_ENABLE(xf86bigfont, AS_HELP_STRING([--enable-xf86bigfont], [Build XF86 Big Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no]) - AC_ARG_ENABLE(dpms, AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes]) -+AC_ARG_ENABLE(config-devd, AS_HELP_STRING([--enable-config-devd], [Build devd support (default: auto)]), [CONFIG_DEVD=$enableval], [CONFIG_DEVD=auto]) - AC_ARG_ENABLE(config-udev, AS_HELP_STRING([--enable-config-udev], [Build udev support (default: auto)]), [CONFIG_UDEV=$enableval], [CONFIG_UDEV=auto]) - AC_ARG_ENABLE(config-udev-kms, AS_HELP_STRING([--enable-config-udev-kms], [Build udev kms support (default: auto)]), [CONFIG_UDEV_KMS=$enableval], [CONFIG_UDEV_KMS=auto]) - AC_ARG_ENABLE(config-hal, AS_HELP_STRING([--disable-config-hal], [Build HAL support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto]) -@@ -856,10 +860,27 @@ if test "x$CONFIG_UDEV" = xyes && test " - AC_MSG_ERROR([Hotplugging through both libudev and hal not allowed]) - fi - --PKG_CHECK_MODULES(UDEV, $LIBUDEV, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no]) --if test "x$CONFIG_UDEV" = xauto; then -- CONFIG_UDEV="$HAVE_LIBUDEV" -- AC_DEFINE(HAVE_LIBUDEV, 1, [Define to 1 if libudev is available.]) -+if test "x$CONFIG_DEVD" = xauto; then -+ case $host_os in -+ *freebsd*) -+ CONFIG_DEVD=yes -+ ;; -+ *) -+ CONFIG_DEVD=no -+ ;; -+ esac -+fi -+AM_CONDITIONAL(CONFIG_DEVD, [test "x$CONFIG_DEVD" = xyes]) -+if test "x$CONFIG_DEVD" = xyes; then -+ AC_DEFINE(CONFIG_DEVD, 1, [Use devd for input auto configuration]) -+fi -+ -+if test "x$CONFIG_UDEV" != xno; then -+ PKG_CHECK_MODULES(UDEV, $LIBUDEV, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no]) -+ if test "x$CONFIG_UDEV" = xauto; then -+ CONFIG_UDEV="$HAVE_LIBUDEV" -+ AC_DEFINE(HAVE_LIBUDEV, 1, [Define to 1 if libudev is available.]) -+ fi - fi - AM_CONDITIONAL(CONFIG_UDEV, [test "x$CONFIG_UDEV" = xyes]) - if test "x$CONFIG_UDEV" = xyes; then -@@ -907,7 +928,14 @@ AM_CONDITIONAL(CONFIG_HAL, [test "x$CONF - - if test "x$SYSTEMD_LOGIND" = xauto; then - if test "x$HAVE_DBUS" = xyes -a "x$CONFIG_UDEV" = xyes ; then -- SYSTEMD_LOGIND=yes -+ case $host_os in -+ *linux*) -+ SYSTEMD_LOGIND=yes -+ ;; -+ *) -+ SYSTEMD_LOGIND=no -+ ;; -+ esac - else - SYSTEMD_LOGIND=no - fi -@@ -2467,12 +2495,12 @@ AC_SUBST([prefix]) - - AC_CONFIG_COMMANDS([sdksyms], [touch hw/xfree86/sdksyms.dep]) - --if test "x$CONFIG_HAL" = xno && test "x$CONFIG_UDEV" = xno; then -+if test "x$CONFIG_HAL" = xno && test "x$CONFIG_UDEV" = xno && test "x$CONFIG_DEVD" = xno; then - AC_MSG_WARN([ -- *********************************************** -- Neither HAL nor udev backend will be enabled. -+ ***************************************************** -+ Neither HAL, devd, nor udev backend will be enabled. - Input device hotplugging will not be available! -- ***********************************************]) -+ *****************************************************]) - fi - - AC_CONFIG_FILES([ Index: x11-servers/xorg-server/files/hw_xfree86_Makefile.am =================================================================== --- x11-servers/xorg-server/files/hw_xfree86_Makefile.am +++ /dev/null @@ -1,14 +0,0 @@ -* Don't overwrite Xorg binary with Xorg.sh when SUID_WRAPPER_DIR == bindir -* Instead, relink bin/X to Xorg.wrap rather than to Xorg (which isn't Xorg.sh) -* ---- hw/xfree86/Makefile.am.orig 2017-03-16 05:24:43 UTC -+++ hw/xfree86/Makefile.am -@@ -114,7 +114,7 @@ endif - if SUID_WRAPPER - $(MKDIR_P) $(DESTDIR)$(SUID_WRAPPER_DIR) - mv $(DESTDIR)$(bindir)/Xorg $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg -- ${INSTALL} -m 755 Xorg.sh $(DESTDIR)$(bindir)/Xorg -+ (test ! -f $(DESTDIR)$(bindir)/Xorg && ${INSTALL} -m 755 Xorg.sh $(DESTDIR)$(bindir)/Xorg || cd $(DESTDIR)$(bindir) && rm -f X && $(LN_S) Xorg.wrap$(EXEEXT) X) - -chown 0 $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg.wrap && chmod u+s $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg.wrap - endif - Index: x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-misc-Makefile.in =================================================================== --- x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-misc-Makefile.in +++ /dev/null @@ -1,12 +0,0 @@ ---- hw/xfree86/os-support/misc/Makefile.in.orig 2015-09-23 10:21:18.470900000 +0200 -+++ hw/xfree86/os-support/misc/Makefile.in 2015-09-23 10:22:34.979974000 +0200 -@@ -543,7 +543,8 @@ - - #AM_LDFLAGS = -r - AM_CPPFLAGS = $(XORG_INCS) --AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) -+@I386_VIDEO_TRUE@I386_VIDEO_CFLAGS = -mno-sse -+AM_CFLAGS = $(I386_VIDEO_CFLAGS) $(XORG_CFLAGS) $(DIX_CFLAGS) - EXTRA_DIST = $(I386_SRCS) $(PORTIO_SRCS) - all: all-am - Index: x11-servers/xorg-server/files/patch-config_Makefile.in =================================================================== --- x11-servers/xorg-server/files/patch-config_Makefile.in +++ /dev/null @@ -1,100 +0,0 @@ -* generated from patched Makefile.am; revise and regen instead of editing -* -* Build the devd config backend if activated -* ---- config/Makefile.in.orig 2017-03-16 05:24:43 UTC -+++ config/Makefile.in -@@ -89,16 +89,18 @@ PRE_UNINSTALL = : - POST_UNINSTALL = : - build_triplet = @build@ - host_triplet = @host@ --@NEED_DBUS_TRUE@am__append_1 = $(DBUS_CFLAGS) --@NEED_DBUS_TRUE@am__append_2 = dbus-core.c --@NEED_DBUS_TRUE@am__append_3 = $(DBUS_LIBS) --@CONFIG_UDEV_TRUE@am__append_4 = $(UDEV_CFLAGS) --@CONFIG_UDEV_TRUE@am__append_5 = udev.c --@CONFIG_UDEV_TRUE@am__append_6 = $(UDEV_LIBS) --@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__append_7 = $(HAL_CFLAGS) --@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__append_8 = hal.c --@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__append_9 = $(HAL_LIBS) --@CONFIG_HAL_FALSE@@CONFIG_UDEV_FALSE@@CONFIG_WSCONS_TRUE@am__append_10 = wscons.c -+@CONFIG_DEVD_TRUE@am__append_1 = devd.c -+@CONFIG_DEVD_TRUE@am__append_2 = -lusbhid -+@NEED_DBUS_TRUE@am__append_3 = $(DBUS_CFLAGS) -+@NEED_DBUS_TRUE@am__append_4 = dbus-core.c -+@NEED_DBUS_TRUE@am__append_5 = $(DBUS_LIBS) -+@CONFIG_UDEV_TRUE@am__append_6 = $(UDEV_CFLAGS) -+@CONFIG_UDEV_TRUE@am__append_7 = udev.c -+@CONFIG_UDEV_TRUE@am__append_8 = $(UDEV_LIBS) -+@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__append_9 = $(HAL_CFLAGS) -+@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__append_10 = hal.c -+@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__append_11 = $(HAL_LIBS) -+@CONFIG_HAL_FALSE@@CONFIG_UDEV_FALSE@@CONFIG_WSCONS_TRUE@am__append_12 = wscons.c - subdir = config - ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 - am__aclocal_m4_deps = $(top_srcdir)/m4/ac_define_dir.m4 \ -@@ -126,16 +128,18 @@ am__DEPENDENCIES_1 = - @CONFIG_UDEV_TRUE@am__DEPENDENCIES_3 = $(am__DEPENDENCIES_1) - @CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__DEPENDENCIES_4 = \ - @CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@ $(am__DEPENDENCIES_1) --libconfig_la_DEPENDENCIES = $(am__DEPENDENCIES_2) \ -- $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) --am__libconfig_la_SOURCES_DIST = config.c config-backends.h dbus-core.c \ -- udev.c hal.c wscons.c --@NEED_DBUS_TRUE@am__objects_1 = dbus-core.lo --@CONFIG_UDEV_TRUE@am__objects_2 = udev.lo --@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__objects_3 = hal.lo --@CONFIG_HAL_FALSE@@CONFIG_UDEV_FALSE@@CONFIG_WSCONS_TRUE@am__objects_4 = wscons.lo -+libconfig_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ -+ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_3) \ -+ $(am__DEPENDENCIES_4) -+am__libconfig_la_SOURCES_DIST = config.c config-backends.h devd.c \ -+ dbus-core.c udev.c hal.c wscons.c -+@CONFIG_DEVD_TRUE@am__objects_1 = devd.lo -+@NEED_DBUS_TRUE@am__objects_2 = dbus-core.lo -+@CONFIG_UDEV_TRUE@am__objects_3 = udev.lo -+@CONFIG_HAL_TRUE@@CONFIG_UDEV_FALSE@am__objects_4 = hal.lo -+@CONFIG_HAL_FALSE@@CONFIG_UDEV_FALSE@@CONFIG_WSCONS_TRUE@am__objects_5 = wscons.lo - am_libconfig_la_OBJECTS = config.lo $(am__objects_1) $(am__objects_2) \ -- $(am__objects_3) $(am__objects_4) -+ $(am__objects_3) $(am__objects_4) $(am__objects_5) - libconfig_la_OBJECTS = $(am_libconfig_la_OBJECTS) - AM_V_lt = $(am__v_lt_@AM_V@) - am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -@@ -157,7 +161,7 @@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top - depcomp = $(SHELL) $(top_srcdir)/depcomp - am__maybe_remake_depfiles = depfiles - am__depfiles_remade = ./$(DEPDIR)/config.Plo ./$(DEPDIR)/dbus-core.Plo \ -- ./$(DEPDIR)/hal.Plo ./$(DEPDIR)/udev.Plo \ -+ ./$(DEPDIR)/devd.Plo ./$(DEPDIR)/hal.Plo ./$(DEPDIR)/udev.Plo \ - ./$(DEPDIR)/wscons.Plo - am__mv = mv -f - COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ -@@ -593,12 +597,14 @@ target_alias = @target_alias@ - top_build_prefix = @top_build_prefix@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ --AM_CFLAGS = $(DIX_CFLAGS) $(am__append_1) $(am__append_4) \ -- $(am__append_7) -+AM_CFLAGS = $(DIX_CFLAGS) $(am__append_3) $(am__append_6) \ -+ $(am__append_9) - noinst_LTLIBRARIES = libconfig.la --libconfig_la_SOURCES = config.c config-backends.h $(am__append_2) \ -- $(am__append_5) $(am__append_8) $(am__append_10) --libconfig_la_LIBADD = $(am__append_3) $(am__append_6) $(am__append_9) -+libconfig_la_SOURCES = config.c config-backends.h $(am__append_1) \ -+ $(am__append_4) $(am__append_7) $(am__append_10) \ -+ $(am__append_12) -+libconfig_la_LIBADD = $(am__append_2) $(am__append_5) $(am__append_8) \ -+ $(am__append_11) - @CONFIG_UDEV_TRUE@@XORG_TRUE@xorgconfddir = $(datadir)/X11/$(XF86CONFIGDIR) - @CONFIG_UDEV_TRUE@@XORG_TRUE@xorgconfd_DATA = 10-quirks.conf - EXTRA_DIST = x11-input.fdi fdi2iclass.py 10-quirks.conf -@@ -658,6 +664,7 @@ distclean-compile: - - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Plo@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus-core.Plo@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/devd.Plo@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hal.Plo@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udev.Plo@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wscons.Plo@am__quote@ # am--include-marker Index: x11-servers/xorg-server/files/patch-config_config-backends.h =================================================================== --- x11-servers/xorg-server/files/patch-config_config-backends.h +++ /dev/null @@ -1,12 +0,0 @@ -* Define required functions for devd config backend -* ---- config/config-backends.h.orig 2017-03-15 18:05:25 UTC -+++ config/config-backends.h -@@ -43,4 +43,7 @@ void config_hal_fini(void); - #elif defined(CONFIG_WSCONS) - int config_wscons_init(void); - void config_wscons_fini(void); -+#elif defined(CONFIG_DEVD) -+int config_devd_init(void); -+void config_devd_fini(void); - #endif Index: x11-servers/xorg-server/files/patch-config_config.c =================================================================== --- x11-servers/xorg-server/files/patch-config_config.c +++ /dev/null @@ -1,23 +0,0 @@ -* Call the devd config backend functions if activated -* ---- config/config.c.orig 2017-03-15 18:05:25 UTC -+++ config/config.c -@@ -55,6 +55,9 @@ config_init(void) - #elif defined(CONFIG_WSCONS) - if (!config_wscons_init()) - ErrorF("[config] failed to initialise wscons\n"); -+#elif defined(CONFIG_DEVD) -+ if (!config_devd_init()) -+ ErrorF("[config] failed to initialise devd\n"); - #endif - } - -@@ -67,6 +70,8 @@ config_fini(void) - config_hal_fini(); - #elif defined(CONFIG_WSCONS) - config_wscons_fini(); -+#elif defined(CONFIG_DEVD) -+ config_devd_fini(); - #endif - } - Index: x11-servers/xorg-server/files/patch-config_devd.c =================================================================== --- x11-servers/xorg-server/files/patch-config_devd.c +++ /dev/null @@ -1,858 +0,0 @@ ---- config/devd.c.orig 2017-03-16 05:24:43 UTC -+++ config/devd.c -@@ -0,0 +1,855 @@ -+/* -+ * Copyright (c) 2012 Baptiste Daroussin -+ * Copyright (c) 2013, 2014 Alex Kozlov -+ * Copyright (c) 2014 Robert Millan -+ * Copyright (c) 2014 Jean-Sebastien Pedron -+ * Copyright (c) 2015 Hans Petter Selasky -+ * Copyright (c) 2015-2017 Rozhuk Ivan -+ * Copyright (c) 2016, 2017 Vladimir Kondratyev -+ * Copyright (c) 2017 Matthew Rezny -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the "Software"), -+ * to deal in the Software without restriction, including without limitation -+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, -+ * and/or sell copies of the Software, and to permit persons to whom the -+ * Software is furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the next -+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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. -+ * -+ * Author: Baptiste Daroussin -+ */ -+ -+#ifdef HAVE_DIX_CONFIG_H -+#include -+#endif -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "input.h" -+#include "inputstr.h" -+#include "hotplug.h" -+#include "config-backends.h" -+#include "os.h" -+ -+#define _IOC_READ IOC_OUT -+ -+#define ULONG_BITS (sizeof(unsigned long) * 8) -+#define ULONG_CNT(__x) (((__x) + ULONG_BITS - 1) / ULONG_BITS) -+#define ULONG_IS_BIT_SET(__x, __bit) (((const unsigned long*)(__x))[(__bit) / ULONG_BITS] & (1UL << (__bit % ULONG_BITS))) -+ -+/* from: */ -+#define JSIOCGNAME(len) _IOC(_IOC_READ, 'j', 0x13, len) /* get identifier string */ -+ -+/* WebCamD specific. */ -+#define WEBCAMD_IOCTL_GET_USB_VENDOR_ID _IOR('q', 250, unsigned short) -+#define WEBCAMD_IOCTL_GET_USB_PRODUCT_ID _IOR('q', 251, unsigned short) -+#define WEBCAMD_IOCTL_GET_USB_SPEED _IOR('q', 252, unsigned int) -+ -+#ifdef COMPAT_32BIT -+ #define hid_pass_ptr(ptr) ((uint64_t)(uintptr_t)(ptr)) -+#else -+ #define hid_pass_ptr(ptr) (ptr) -+#endif -+ -+#define _PATH_DEV_LEN (sizeof(_PATH_DEV) - 1) -+#define DEVD_PATH_DEV "devd:" _PATH_DEV -+#define DEVD_PATH_DEV_LEN (sizeof(DEVD_PATH_DEV) - 1) -+#define DEVD_PATH_LEN (DEVD_PATH_DEV_LEN - _PATH_DEV_LEN) -+ -+#define DEVD_SOCK_PATH _PATH_VARRUN "devd.pipe" -+ -+#define DEVD_EVENT_ADD '+' -+#define DEVD_EVENT_REMOVE '-' -+#define DEVD_EVENT_NOTIFY '!' -+ -+#define RECONNECT_DELAY (5 * 1000) -+ -+#define is_meuqual(__v1, __v1sz, __v2, __v2sz) \ -+ ((__v1sz) == (__v2sz) && NULL != (__v1) && NULL != (__v2) && \ -+ 0 == memcmp((__v1), (__v2), (__v1sz))) -+ -+#define is_meuqual_cstr(__cstr, __v, __vsz) \ -+ is_meuqual(__cstr, (sizeof(__cstr) - 1), __v, __vsz) -+ -+#define is_de_euqual_cstr(__de, __cstr) \ -+ (NULL != (__de) && \ -+ is_meuqual((__de)->d_name, (__de)->d_namlen, __cstr, (sizeof(__cstr) - 1))) -+ -+#define devd_get_val_cstr(__cstr, __buf, __bufsz, __valsz) \ -+ devd_get_val((__buf), (__bufsz), __cstr, (sizeof(__cstr) - 1), \ -+ (__valsz)) -+ -+static int devd_skt = 0; -+static char devd_buf[4096]; -+static size_t devd_buf_used = 0; -+static int is_kbdmux = 0; -+static int evdev_support = 0; -+static OsTimerPtr rtimer = NULL; -+ -+/* Input devices. */ -+typedef struct hw_type_s { -+ const char *dev_name; -+ size_t dev_name_size; -+ size_t path_offset; -+ int is_hybrid; /* has both evdev and traditional interfaces */ -+ int flags; -+ const char *xdriver; -+} hw_type_t, *hw_type_p; -+ -+/* xdriver can be set via config "InputClass" section. -+ * Do not set xdriver name if device have more than one -+ * xf86-input-* drivers. -+ * "input/event" can be handled by: xf86-input-libinput, -+ * xf86-input-evdev and xf86-input-wacom, let user choose. -+ */ -+static hw_type_t hw_types[] = { -+ { "uhid", 4, 0, 0, 0, NULL }, -+ { "ukbd", 4, 0, 1, ATTR_KEY | ATTR_KEYBOARD, "kbd" }, -+ { "atkbd", 5, 0, 1, ATTR_KEY | ATTR_KEYBOARD, "kbd" }, -+ { "kbdmux", 6, 0, 1, ATTR_KEY | ATTR_KEYBOARD, "kbd" }, -+ { "sysmouse", 8, 0, 1, ATTR_POINTER, "mouse" }, -+ { "ums", 3, 0, 1, ATTR_POINTER, "mouse" }, -+ { "psm", 3, 0, 1, ATTR_POINTER, "mouse" }, -+ { "vboxguest", 9, 0, 0, ATTR_POINTER, "vboxmouse" }, -+ { "joy", 3, 0, 0, ATTR_JOYSTICK, NULL }, -+ { "atp", 3, 0, 0, ATTR_TOUCHPAD, NULL }, -+ { "uep", 3, 0, 0, ATTR_TOUCHSCREEN, NULL }, -+ { "input/event",5, 6, 0, 0, NULL }, -+ { "input/js", 2, 6, 0, ATTR_JOYSTICK, NULL }, -+ { NULL, 0, 0, 0, NULL }, -+}; -+ -+/* Input devices paths. */ -+static hw_type_t hw_type_path[] = { -+ { "input/", 0, 6, 0, NULL }, -+ { NULL, 0, 0, 0, NULL }, -+}; -+ -+static size_t -+bits_calc(const unsigned long *bits, size_t off_start, size_t off_stop) -+{ -+ size_t count = 0; -+ -+ for (size_t i = off_start; i < off_stop; ++i) { -+ if (ULONG_IS_BIT_SET(bits, i)) { -+ ++count; -+ } -+ } -+ return count; -+} -+ -+static hw_type_p -+get_dev_type_by_name(const char *dev_name, size_t dev_name_size) -+{ -+ if (!dev_name || !dev_name_size) -+ return NULL; -+ -+ for (size_t i = 0; hw_types[i].dev_name; ++i) { -+ if (dev_name_size >= (hw_types[i].dev_name_size + hw_types[i].path_offset) && -+ !memcmp(dev_name, hw_types[i].dev_name, (hw_types[i].path_offset + hw_types[i].dev_name_size))) { -+ return &hw_types[i]; -+ } -+ } -+ return NULL; -+} -+ -+static hw_type_p -+get_dev_type_by_path(const char *dev_name, size_t dev_name_size, hw_type_p hw_type_cust) -+{ -+ if (!dev_name || !dev_name_size || !hw_type_cust) -+ return NULL; -+ -+ for (size_t i = 0; hw_type_path[i].dev_name; ++i) { -+ if (dev_name_size <= hw_type_path[i].path_offset || -+ memcmp(dev_name, hw_type_path[i].dev_name, hw_type_path[i].path_offset)) -+ continue; -+ /* Path in white list. */ -+ hw_type_cust->dev_name = dev_name; -+ hw_type_cust->flags = hw_type_path[i].flags; -+ hw_type_cust->xdriver = hw_type_path[i].xdriver; -+ hw_type_cust->path_offset = hw_type_path[i].path_offset; -+ size_t name_end = hw_type_cust->path_offset; -+ while (name_end < dev_name_size && !isdigit(dev_name[name_end])) -+ ++name_end; -+ hw_type_cust->dev_name_size = (name_end - hw_type_cust->path_offset); -+ return hw_type_cust; -+ } -+ return NULL; -+} -+ -+static int -+is_kbdmux_enabled(void) -+{ -+ /* Xorg uses /dev/ttyv0 as a console device */ -+ /* const char device[]="/dev/console"; */ -+ static const char *device = _PATH_TTY "v0"; -+ -+ int fd = open(device, O_RDONLY); -+ if (fd < 0) -+ return 0; -+ -+ keyboard_info_t info; -+ int ret = (ioctl(fd, KDGKBINFO, &info) == -1 || -+ memcmp(info.kb_name, "kbdmux", 6)) ? 0 : 1; -+ close(fd); -+ return ret; -+} -+ -+/* Derived from EvdevProbe() function of xf86-input-evdev driver */ -+static int -+get_evdev_flags(int fd) -+{ -+ if (fd<0) -+ return 0; -+ -+ unsigned long key_bits[ULONG_CNT(KEY_CNT)], rel_bits[ULONG_CNT(REL_CNT)], abs_bits[ULONG_CNT(ABS_CNT)]; -+ size_t has_keys = 0, has_buttons = 0, has_lmr = 0, has_rel_axes = 0, has_abs_axes = 0, has_mt = 0; -+ if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)), key_bits) != -1) { -+ has_keys = bits_calc(key_bits, 0, BTN_MISC); -+ has_buttons = bits_calc(key_bits, BTN_MISC, BTN_JOYSTICK); -+ has_lmr = bits_calc(key_bits, BTN_LEFT, BTN_MIDDLE + 1); -+ } -+ if (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(rel_bits)), rel_bits) != -1) { -+ has_rel_axes = bits_calc(rel_bits, 0, REL_CNT); -+ } -+ if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)), abs_bits) != -1) { -+ has_abs_axes = bits_calc(abs_bits, 0, ABS_CNT); -+ has_mt = bits_calc(abs_bits, ABS_MT_SLOT, ABS_CNT); -+ } -+ -+ int flags = 0; -+ if (has_abs_axes) { -+ if (has_mt) { -+ if (!has_buttons) { -+ /* -+ * XXX: I'm not sure that joystick detection is -+ * done right. xf86-input-evdev does not support them. -+ */ -+ if (ULONG_IS_BIT_SET(key_bits, BTN_JOYSTICK)) -+ flags = ATTR_JOYSTICK; -+ else -+ ++has_buttons; -+ } -+ } -+ if (!flags && ULONG_IS_BIT_SET(abs_bits, ABS_X) && ULONG_IS_BIT_SET(abs_bits, ABS_Y)) { -+ if (ULONG_IS_BIT_SET(key_bits, BTN_TOOL_PEN) || -+ ULONG_IS_BIT_SET(key_bits, BTN_STYLUS) || -+ ULONG_IS_BIT_SET(key_bits, BTN_STYLUS2)) -+ flags = ATTR_TABLET; -+ else if (ULONG_IS_BIT_SET(abs_bits, ABS_PRESSURE) || -+ ULONG_IS_BIT_SET(key_bits, BTN_TOUCH)) { -+ if (has_lmr || ULONG_IS_BIT_SET(key_bits, BTN_TOOL_FINGER)) -+ flags = ATTR_TOUCHPAD; -+ else -+ flags = ATTR_TOUCHSCREEN; -+ } else if (!(ULONG_IS_BIT_SET(rel_bits, REL_X) && -+ ULONG_IS_BIT_SET(rel_bits, REL_Y)) && -+ has_lmr) /* some touchscreens use BTN_LEFT rather than BTN_TOUCH */ -+ flags = ATTR_TOUCHSCREEN; -+ } -+ } -+ if (!flags) { -+ if (has_keys) -+ flags = ATTR_KEY | ATTR_KEYBOARD; -+ else if (has_rel_axes || has_abs_axes || has_buttons) -+ flags = ATTR_POINTER; -+ } -+ return flags; -+} -+ -+/* From: sys/dev/usb/usb_hid.c */ -+static int -+hid_is_collection(report_desc_t s, uint32_t usage) -+{ -+ struct hid_data* hd = hid_start_parse(s, ~0, -1); -+ if (!hd) -+ return 0; -+ -+ struct hid_item hi; -+ int rc; -+ while ((rc = hid_get_item(hd, &hi))) { -+ if (hi.kind == hid_collection && hi.usage == usage) -+ break; -+ } -+ hid_end_parse(hd); -+ return rc; -+} -+ -+static int -+hid_is_mouse(report_desc_t s) -+{ -+ struct hid_data* hd = hid_start_parse(s, (1 << hid_input), -1); -+ if (!hd) -+ return 0; -+ -+ struct hid_item hi; -+ int found = 0, mdepth = 0; -+ while (hid_get_item(hd, &hi)) { -+ switch (hi.kind) { -+ case hid_collection: -+ if (mdepth != 0) -+ ++mdepth; -+ else if (hi.collection == 1 && -+ hi.usage == HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_MOUSE)) -+ ++mdepth; -+ break; -+ case hid_endcollection: -+ if (mdepth) -+ --mdepth; -+ break; -+ case hid_input: -+ if (!mdepth) -+ break; -+ if (hi.usage == HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X) && -+ (hi.flags & (HIO_CONST|HIO_RELATIVE)) == HIO_RELATIVE) -+ ++found; -+ if (hi.usage == HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y) && -+ (hi.flags & (HIO_CONST|HIO_RELATIVE)) == HIO_RELATIVE) -+ ++found; -+ break; -+ default: -+ break; -+ } -+ } -+ hid_end_parse(hd); -+ return found; -+} -+ -+static char * -+sysctl_get_str(const char *sysctlname, size_t *size_ret) -+{ -+ if (!sysctlname) -+ return NULL; -+ -+ size_t len = 0; -+ if (sysctlbyname(sysctlname, NULL, &len, NULL, 0) || !len) -+ return NULL; -+ -+ char* dest = malloc(len + 1); -+ if (!dest) -+ return NULL; -+ -+ if (sysctlbyname(sysctlname, dest, &len, NULL, 0)) { -+ free(dest); -+ return NULL; -+ } -+ dest[len] = 0; -+ if (size_ret) -+ *size_ret = len; -+ return dest; -+} -+ -+static char * -+devd_get_val(char *buf, size_t buf_size, const char *val_name, size_t val_name_size, size_t *val_size) -+{ -+ if (!buf || !buf_size || !val_name || !val_name_size) -+ return NULL; -+ -+ char *ret = buf, *buf_end = (buf + buf_size); -+ while (ret && ret < buf_end) { -+ ret = memmem(ret, (buf_end - ret), val_name, val_name_size); -+ if (!ret) -+ return NULL; -+ /* Found. */ -+ /* Check: space before or buf+1. */ -+ if ((buf + 1) < ret && ret[-1] != ' ') { -+ ret += val_name_size; -+ continue; -+ } -+ /* Check: = after name and size for value. */ -+ ret += val_name_size; -+ if ((ret + 1) >= buf_end) -+ return NULL; -+ if (ret[0] != '=') -+ continue; -+ ++ret; -+ break; -+ } -+ if (!ret || !val_size) -+ return ret; -+ /* Calc value data size. */ -+ char* ptr = memchr(ret, ' ', (buf_end - ret)); -+ if (!ptr) /* End of string/last value. */ -+ ptr = buf_end; -+ *val_size = (ptr - ret); -+ return ret; -+} -+ -+static void -+device_added(const char *dev_name, size_t dev_name_size, int allow_no_device) -+{ -+ if (!dev_name || !dev_name_size || dev_name_size > PATH_MAX) -+ return; -+ -+ char config_info[PATH_MAX + 32]; -+ /* Make dev_name null ended string. */ -+ snprintf(config_info, sizeof(config_info), DEVD_PATH_DEV"%.*s", (int)dev_name_size, dev_name); -+ /* Set / update pointers to dev_name and dev_path. */ -+ char* dev_path = (config_info + DEVD_PATH_LEN); /* Skip: "devd:" */ -+ dev_name = (dev_path + _PATH_DEV_LEN); /* Skip: "/dev/" */ -+ -+ /* Is known input device or path? */ -+ hw_type_t *hwtype = get_dev_type_by_name(dev_name, dev_name_size); -+ if (!hwtype) { -+ hw_type_t hwtype_cust; -+ hwtype = get_dev_type_by_path(dev_name, dev_name_size, &hwtype_cust); -+ } -+ if (!hwtype) /* Not found in white list. */ -+ return; -+ -+ /* Skip legacy interfaces if EVDEV_SUPPORT is compiled into kernel */ -+ if (evdev_support && hwtype->is_hybrid) { -+ LogMessage(X_INFO, "config/devd: EVDEV_SUPPORT is enabled, ignoring device %s\n", dev_name); -+ return; -+ } -+ /* Skip keyboard devices if kbdmux is enabled */ -+ if (is_kbdmux && !allow_no_device && (hwtype->flags & ATTR_KEYBOARD)) { -+ LogMessage(X_INFO, "config/devd: kbdmux is enabled, ignoring device %s\n", dev_name); -+ return; -+ } -+ /* Skip duplicate devices. */ -+ if (device_is_duplicate(config_info)) { -+ LogMessage(X_WARNING, "config/devd: device %s already added. ignoring\n", dev_path); -+ return; -+ } -+ -+ /* Init and set attributes. */ -+ char pnp_usb_id[PATH_MAX], product[PATH_MAX], vendor[PATH_MAX]; -+ InputAttributes attrs; -+ memset(&attrs, 0, sizeof(attrs)); -+ attrs.device = dev_path; -+ attrs.flags = hwtype->flags; -+ -+ /* Try to open device. */ -+ int fd = open(dev_path, O_RDONLY); -+ if (fd < 0) { -+ if (!(hwtype->flags & (ATTR_KEY | ATTR_KEYBOARD))) { -+ /* -+ * Fail if cannot open device, it breaks AllowMouseOpenFail, -+ * but it should not matter when config/devd is enabled -+ */ -+ LogMessage(X_WARNING, "config/devd: device %s already opened\n", dev_path); -+ return; -+ } -+ if (!allow_no_device) { -+ /* -+ * There can be only one keyboard attached to console and -+ * it is already added. -+ */ -+ LogMessage(X_WARNING, "config/devd: console keyboard is already added, ignoring %s\n", dev_path); -+ return; -+ } -+ } else { -+ /* Try to get device info via ioctl(). */ -+ keyboard_info_t kbdi; -+ mousehw_t mshw; -+ struct input_id iid; -+ report_desc_t rep_desc; -+ -+ if (ioctl(fd, KDGKBINFO, &kbdi) != -1) { /* Is this keyboard? */ -+ memcpy(product, kbdi.kb_name, sizeof(kbdi.kb_name)); -+ attrs.product = product; -+ attrs.flags = ATTR_KEY | ATTR_KEYBOARD; -+ LogMessage(X_INFO, "config/devd: detected keyboard: %s, kb_index=%i, kb_unit=%i, kb_type=%i, kb_config=%i\n", -+ kbdi.kb_name, kbdi.kb_index, kbdi.kb_unit, kbdi.kb_type, kbdi.kb_config); -+ } else if (ioctl(fd, MOUSE_GETHWINFO, &mshw) != -1) { /* Is this mouse? */ -+ /* FreeBSD mouse drivers does not return real vid+pid. */ -+ /* construct USB ID in lowercase hex - "0000:ffff" */ -+ if (mshw.iftype != MOUSE_IF_USB && mshw.model > 0) { -+ snprintf(pnp_usb_id, sizeof(pnp_usb_id), "%04x:%04x", mshw.hwid, mshw.model); -+ attrs.usb_id = pnp_usb_id; -+ } -+ if (mshw.type == MOUSE_PAD) -+ attrs.flags = ATTR_TOUCHPAD; -+ else -+ attrs.flags = ATTR_POINTER; -+ LogMessage(X_INFO, "config/devd: detected mouse: hwid=%04x, model=%04x, type=%04x, iftype=%04x, buttons=%d\n", -+ mshw.hwid, mshw.model, mshw.type, mshw.iftype, mshw.buttons); -+ } else if (ioctl(fd, JSIOCGNAME((sizeof(product) - 1)), product) != -1) { /* Is this joystick? */ -+ attrs.product = product; -+ attrs.flags = ATTR_JOYSTICK; -+ LogMessage(X_INFO, "config/devd: detected joystick: %s\n", product); -+ } else if (ioctl(fd, EVIOCGID, &iid) != -1 && -+ ioctl(fd, EVIOCGNAME((sizeof(product) - 1)), product) != -1) { /* Is this event? */ -+ /* construct USB ID in lowercase hex - "0000:ffff" */ -+ snprintf(pnp_usb_id, sizeof(pnp_usb_id), "%04x:%04x", iid.vendor, iid.product); -+ attrs.usb_id = pnp_usb_id; -+ attrs.product = product; -+ /* Detect device type. */ -+ attrs.flags = get_evdev_flags(fd); -+ /* Skip keyboard devices if kbdmux is enabled and EVDEV_SUPPORT is not compiled into kernel*/ -+ if (is_kbdmux && !evdev_support && (attrs.flags & ATTR_KEYBOARD)) { -+ close(fd); -+ LogMessage(X_INFO, "config/devd: kbdmux is enabled, ignoring device %s\n", dev_name); -+ return; -+ } -+ LogMessage(X_INFO, "config/devd: detected event input: %s, bustype=%04x, vendor=%04x, product=%04x, version=%04x\n", -+ product, iid.bustype, iid.vendor, iid.product, iid.version); -+ } else if ((rep_desc = hid_get_report_desc(fd))) { /* Is USB HID? */ -+ if (hid_is_mouse(rep_desc)) { -+ attrs.flags = ATTR_POINTER; -+ LogMessage(X_INFO, "config/devd: detected USB HID mouse\n"); -+ } else if (hid_is_collection(rep_desc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_KEYBOARD))) { -+ /* Skip keyboard devices if kbdmux is enabled */ -+ if (is_kbdmux) { -+ hid_dispose_report_desc(rep_desc); -+ close(fd); -+ LogMessage(X_INFO, "config/devd: kbdmux is enabled, ignoring device %s\n", dev_name); -+ return; -+ } -+ attrs.flags = ATTR_KEY | ATTR_KEYBOARD; -+ LogMessage(X_INFO, "config/devd: detected USB HID keyboard\n"); -+ } else if (hid_is_collection(rep_desc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_JOYSTICK)) || -+ hid_is_collection(rep_desc, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_GAME_PAD))) { -+ attrs.flags = ATTR_JOYSTICK; -+ LogMessage(X_INFO, "config/devd: detected USB HID joystick\n"); -+ } else -+ LogMessage(X_INFO, "config/devd: detected USB HID of unknown type\n"); -+ hid_dispose_report_desc(rep_desc); -+ } -+ -+ if (!attrs.usb_id) { /* Is this webcamd device? */ -+ unsigned short vid, pid; -+ if (ioctl(fd, WEBCAMD_IOCTL_GET_USB_VENDOR_ID, &vid) != -1 && -+ ioctl(fd, WEBCAMD_IOCTL_GET_USB_PRODUCT_ID, &pid) != -1) { -+ snprintf(pnp_usb_id, sizeof(pnp_usb_id), "%04x:%04x", vid, pid); -+ attrs.usb_id = pnp_usb_id; -+ LogMessage(X_INFO, "config/devd: webcamd device: %s\n", pnp_usb_id); -+ } -+ } -+ } -+ close(fd); -+ -+ /* Try to get device info via sysctl(). */ -+ if (!attrs.usb_id && !attrs.pnp_id) { -+ char sysctlname[PATH_MAX]; -+ snprintf(sysctlname, sizeof(sysctlname), "dev.%.*s.%s.%%pnpinfo", -+ (int)hwtype->dev_name_size, -+ (hwtype->dev_name + hwtype->path_offset), -+ (dev_name + hwtype->path_offset + hwtype->dev_name_size)); -+ size_t sdata_size; -+ char* sdata = sysctl_get_str(sysctlname, &sdata_size); -+ if (sdata) { -+ size_t pid_size, vid_size; -+ char* ptr_vid = devd_get_val_cstr("vendor", sdata, sdata_size, &vid_size); -+ char* ptr_pid = devd_get_val_cstr("product", sdata, sdata_size, &pid_size); -+ if (ptr_vid && ptr_pid) { /* usb_id */ -+ ptr_vid[vid_size] = 0; -+ ptr_pid[pid_size] = 0; -+ snprintf(pnp_usb_id, sizeof(pnp_usb_id), "%s:%s", ptr_vid, ptr_pid); -+ attrs.usb_id = pnp_usb_id; -+ LogMessage(X_INFO, "config/devd: [sysctl] usb_id: %s\n", pnp_usb_id); -+ } else { /* pnp_id */ -+ strlcpy(pnp_usb_id, sdata, sizeof(pnp_usb_id)); -+ attrs.pnp_id = pnp_usb_id; -+ } -+ free(sdata); -+ } -+ } -+ if (!attrs.vendor || !attrs.product) { -+ char sysctlname[PATH_MAX]; -+ snprintf(sysctlname, sizeof(sysctlname), "dev.%.*s.%s.%%desc", -+ (int)hwtype->dev_name_size, -+ (hwtype->dev_name + hwtype->path_offset), -+ (dev_name + hwtype->path_offset + hwtype->dev_name_size)); -+ size_t sdata_size; -+ char* sdata = sysctl_get_str(sysctlname, &sdata_size); -+ if (sdata) { -+ /* Vendor. */ -+ char* ptr_pid = memchr(sdata, ' ', sdata_size); -+ if (ptr_pid) -+ ptr_pid[0] = 0; -+ strlcpy(vendor, sdata, sizeof(vendor)); -+ attrs.vendor = vendor; -+ /* Product. */ -+ if (!attrs.product && ptr_pid) { -+ ++ptr_pid; -+ char* ptr_vid = memchr(ptr_pid, ',', (sdata_size - (ptr_pid - sdata))); -+ if (ptr_vid) -+ ptr_vid[0] = 0; -+ strlcpy(product, ptr_pid, sizeof(product)); -+ attrs.product = product; -+ } else -+ product[0] = 0; -+ free(sdata); -+ LogMessage(X_INFO, "config/devd: [sysctl] vendor: %s, product: %s\n", vendor, product); -+ } -+ } -+ -+ /* Init options. */ -+ InputOption *option = NULL, *options = NULL; -+ if ((option = input_option_new(options, "_source", "server/devd"))) -+ options = option; -+ if (option && (option = input_option_new(options, "config_info", config_info))) -+ options = option; -+ if (option && (option = input_option_new(options, "name", (attrs.product ? attrs.product : dev_name)))) -+ options = option; -+ if (option && hwtype->xdriver && (option = input_option_new(options, "driver", hwtype->xdriver))) -+ options = option; -+ /* -+ * Don't pass "device" option if the keyboard is already attached to the console (ie. open() failed) -+ * This would activate a special logic in xf86-input-keyboard. Prevent any other attached to console -+ * keyboards being processed. There can be only one such device. -+ */ -+ if (option && fd >= 0 && (option = input_option_new(options, "device", dev_path))) -+ options = option; -+ /* Most drivers just use "device" but evdev also uses "path" so populate both */ -+ if (option && (option = input_option_new(options, "path", dev_path))) -+ options = option; -+ if (option) { -+ LogMessage(X_INFO, "config/devd: adding input device %s\n", dev_path); -+ DeviceIntPtr dev_iptr = NULL; -+ int rc; -+ if ((rc = NewInputDeviceRequest(options, &attrs, &dev_iptr)) != Success) -+ LogMessage(X_ERROR, "config/devd: error %d adding device %s\n", rc, dev_path); -+ } else -+ LogMessage(X_ERROR, "config/devd: error adding device %s\n", dev_path); -+ if (options) -+ input_option_free_list(&options); -+ return; -+} -+ -+static void -+device_removed(const char *dev_name, size_t dev_name_size) -+{ -+ -+ if (!dev_name || !dev_name_size || dev_name_size > PATH_MAX) -+ return; -+ -+ hw_type_t hwtype_cust; -+ if (!get_dev_type_by_name(dev_name, dev_name_size) && -+ !get_dev_type_by_path(dev_name, dev_name_size, &hwtype_cust)) -+ return; /* Device not in list - unknown. */ -+ -+ char config_info[PATH_MAX + 32]; -+ snprintf(config_info, sizeof(config_info), DEVD_PATH_DEV"%.*s", (int)dev_name_size, dev_name); -+ if (device_is_duplicate(config_info)) -+ LogMessage(X_INFO, "config/devd: removing input device %s\n", (config_info + DEVD_PATH_LEN)); -+ else -+ LogMessage(X_INFO, "config/devd: removing nonexistent device %s\n", (config_info + DEVD_PATH_LEN)); -+ remove_devices("devd", config_info); -+ return; -+} -+ -+static void socket_handler(int fd, int ready, void *data); -+ -+static int -+connect_devd(void) -+{ -+ int sock = socket(AF_UNIX, SOCK_STREAM, 0); -+ if (sock < 0) { -+ LogMessage(X_ERROR, "config/devd: failed opening stream socket: %s\n", strerror(errno)); -+ return -1; -+ } -+ -+ struct sockaddr_un devd; -+ devd.sun_family = AF_UNIX; -+ memcpy(devd.sun_path, DEVD_SOCK_PATH, sizeof(DEVD_SOCK_PATH)); -+ if (connect(sock, (struct sockaddr*)&devd, sizeof(devd)) < 0) { -+ int error = errno; -+ close(sock); -+ LogMessage(X_ERROR, "config/devd: failed to connect to devd: %s)\n", strerror(error)); -+ return -1; -+ } -+ -+ SetNotifyFd(sock, socket_handler, X_NOTIFY_READ, NULL); -+ return sock; -+} -+ -+static void -+disconnect_devd(int sock) -+{ -+ if (sock < 0) -+ return; -+ RemoveNotifyFd(sock); -+ close(sock); -+ return; -+} -+ -+static CARD32 -+reconnect_handler(OsTimerPtr timer, CARD32 time, void *arg) -+{ -+ devd_buf_used = 0; -+ devd_skt = connect_devd(); -+ if (devd_skt < 0) /* Try again after RECONNECT_DELAY */ -+ return RECONNECT_DELAY; -+ TimerFree(rtimer); -+ rtimer = NULL; -+ LogMessage(X_INFO, "config/devd: reopened devd socket\n"); -+ return 0; -+} -+ -+static void -+socket_handler(int fd, int ready, void *data) -+{ -+ /* Read new data. */ -+ while (1) { -+ ssize_t ios = recv(devd_skt, (devd_buf + devd_buf_used), (sizeof(devd_buf) - devd_buf_used), MSG_DONTWAIT); -+ if (ios > 0) { /* Read OK. */ -+ devd_buf_used += ios; -+ continue; /* Try to read more. */ -+ } -+ /* Something wrong. */ -+ int error = errno; -+ if (error == EAGAIN) -+ break; /* All available data read. */ -+ if (error == EINTR) -+ continue; -+ if (devd_buf_used >= sizeof(devd_buf)) { -+ devd_buf_used = 0; /* Message too long, reset buf. */ -+ continue; -+ } -+ /* devd socket is lost */ -+ disconnect_devd(devd_skt); -+ rtimer = TimerSet(NULL, 0, 1, reconnect_handler, NULL); -+ LogMessage(X_WARNING, "config/devd: devd socket read error: %s\n", strerror(error)); -+ return; -+ } -+ -+ /* Process data. */ -+ char *ptr, *line = (devd_buf + 1); -+ size_t line_size = 0; -+ while((ptr = memchr(line, '\n', (devd_buf_used - line_size)))) { -+ line_size = (ptr - line); -+ do { -+ if (*(line - 1) != DEVD_EVENT_NOTIFY) -+ break; /* Handle only notify. */ -+ /* Check: is system=DEVFS. */ -+ size_t val_size; -+ char* val = devd_get_val_cstr("system", line, line_size, &val_size); -+ if (!is_meuqual_cstr("DEVFS", val, val_size)) -+ break; -+ /* Check: is subsystem=CDEV. */ -+ val = devd_get_val_cstr("subsystem", line, line_size, &val_size); -+ if (!is_meuqual_cstr("CDEV", val, val_size)) -+ break; -+ /* Get device name. */ -+ size_t cdev_size; -+ char* cdev = devd_get_val_cstr("cdev", line, line_size, &cdev_size); -+ if (!cdev) -+ break; -+ /* Get event type. */ -+ val = devd_get_val_cstr("type", line, line_size, &val_size); -+ if (is_meuqual_cstr("CREATE", val, val_size)) { -+ device_added(cdev, cdev_size, 0); -+ } else if (is_meuqual_cstr("DESTROY", val, val_size)) { -+ device_removed(cdev, cdev_size); -+ } -+ } while(0); -+ -+ line += (line_size + 2); /* Skip '\n' and event type byte. */ -+ line_size = (line - devd_buf); -+ if (devd_buf_used <= line_size) { -+ devd_buf_used = 0; -+ return; -+ } -+ } -+ /* Save line without end marker. */ -+ if (line_size) { -+ devd_buf_used -= (line_size - 1); -+ memmove(devd_buf, (line - 1), devd_buf_used); -+ } -+ return; -+} -+ -+int -+config_devd_init(void) -+{ -+ LogMessage(X_INFO, "config/devd: probing input devices...\n"); -+ -+ /* Check if kernel is compiled with evdev support in hybrid drivers */ -+ evdev_support = feature_present("evdev_support"); -+ -+ /* -+ * Add fake keyboard and give up on keyboards management -+ * if kbdmux is enabled and not exported through evdev -+ */ -+ is_kbdmux = is_kbdmux_enabled(); -+ if (is_kbdmux && !evdev_support) -+ device_added("kbdmux0", 7, 1); -+ -+ /* Scan /dev/ for devices. */ -+ struct dirent** namelist; -+ size_t dir_cnt = scandir(_PATH_DEV, &namelist, 0, alphasort); -+ for (size_t i = 0; i < dir_cnt; ++i) { -+ struct dirent* de = namelist[i]; -+ if (is_de_euqual_cstr(de, ".") || -+ is_de_euqual_cstr(de, "..")) { -+ free(de); -+ continue; -+ } -+ if (de->d_type != DT_DIR) { -+ device_added(de->d_name, de->d_namlen, 0); -+ } else { /* Sub folder. */ -+ char devicename[PATH_MAX]; -+ snprintf(devicename, sizeof(devicename), _PATH_DEV "%s", de->d_name); -+ struct dirent** snamelist; -+ size_t sdir_cnt = scandir(devicename, &snamelist, 0, alphasort); -+ for (size_t j = 0; j < sdir_cnt; ++j) { -+ struct dirent* sde = snamelist[j]; -+ if (!is_de_euqual_cstr(sde, ".") && -+ !is_de_euqual_cstr(sde, "..") && -+ sde->d_type != DT_DIR) { -+ size_t tm = snprintf(devicename, sizeof(devicename), "%s/%s", de->d_name, sde->d_name); -+ device_added(devicename, tm, 0); -+ } -+ free(sde); -+ } -+ free(snamelist); -+ } -+ free(de); -+ } -+ free(namelist); -+ -+ devd_buf_used = 0; -+ devd_skt = connect_devd(); -+ return (devd_skt < 0) ? 0 : 1; -+} -+ -+void -+config_devd_fini(void) -+{ -+ LogMessage(X_INFO, "config/devd: terminating backend...\n"); -+ -+ if (rtimer) { -+ TimerFree(rtimer); -+ rtimer = NULL; -+ } -+ -+ disconnect_devd(devd_skt); -+ return; -+} Index: x11-servers/xorg-server/files/patch-configure =================================================================== --- x11-servers/xorg-server/files/patch-configure +++ /dev/null @@ -1,165 +0,0 @@ -* generated from patched configure.ac; revise and regen instead of editing -* -* Plumb the devd config backend into configure -* -* define USE_DEV_IO for ARM platforms -* -* Only run pkg-config for udev if it is not disabled to prevent over-linking -* -* Automatically use systemd/logind only on Linux -* ---- configure.orig 2017-03-15 18:05:39 UTC -+++ configure -@@ -1032,6 +1032,8 @@ CONFIG_UDEV_FALSE - CONFIG_UDEV_TRUE - UDEV_LIBS - UDEV_CFLAGS -+CONFIG_DEVD_FALSE -+CONFIG_DEVD_TRUE - HAVE_SYSTEMD_DAEMON_FALSE - HAVE_SYSTEMD_DAEMON_TRUE - SYSTEMD_DAEMON_LIBS -@@ -1367,6 +1369,7 @@ enable_tslib - enable_dbe - enable_xf86bigfont - enable_dpms -+enable_config_devd - enable_config_udev - enable_config_udev_kms - enable_config_hal -@@ -2191,6 +2194,7 @@ Optional Features: - --disable-dbe Build DBE extension (default: enabled) - --enable-xf86bigfont Build XF86 Big Font extension (default: disabled) - --disable-dpms Build DPMS extension (default: enabled) -+ --enable-config-devd Build devd support (default: auto) - --enable-config-udev Build udev support (default: auto) - --enable-config-udev-kms - Build udev kms support (default: auto) -@@ -23280,9 +23284,13 @@ $as_echo "#define USE_ALPHA_PIO 1" >>con - esac - GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee" - ;; -- arm*) -+ arm*|aarch64*|riscv*) - ARM_VIDEO=yes - DEFAULT_INT10="stub" -+ case $host_os in -+ *freebsd*) $as_echo "#define USE_DEV_IO 1" >>confdefs.h -+ ;; -+ esac - ;; - i*86) - I386_VIDEO=yes -@@ -24053,6 +24061,13 @@ else - DPMSExtension=yes - fi - -+# Check whether --enable-config-devd was given. -+if test "${enable_config_devd+set}" = set; then : -+ enableval=$enable_config_devd; CONFIG_DEVD=$enableval -+else -+ CONFIG_DEVD=auto -+fi -+ - # Check whether --enable-config-udev was given. - if test "${enable_config_udev+set}" = set; then : - enableval=$enable_config_udev; CONFIG_UDEV=$enableval -@@ -25813,6 +25828,31 @@ if test "x$CONFIG_UDEV" = xyes && test " - as_fn_error $? "Hotplugging through both libudev and hal not allowed" "$LINENO" 5 - fi - -+if test "x$CONFIG_DEVD" = xauto; then -+ case $host_os in -+ *freebsd*) -+ CONFIG_DEVD=yes -+ ;; -+ *) -+ CONFIG_DEVD=no -+ ;; -+ esac -+fi -+ if test "x$CONFIG_DEVD" = xyes; then -+ CONFIG_DEVD_TRUE= -+ CONFIG_DEVD_FALSE='#' -+else -+ CONFIG_DEVD_TRUE='#' -+ CONFIG_DEVD_FALSE= -+fi -+ -+if test "x$CONFIG_DEVD" = xyes; then -+ -+$as_echo "#define CONFIG_DEVD 1" >>confdefs.h -+ -+fi -+ -+if test "x$CONFIG_UDEV" != xno; then - - pkg_failed=no - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for UDEV" >&5 -@@ -25884,11 +25924,12 @@ else - printf "%s\n" "yes" >&6; } - HAVE_LIBUDEV=yes - fi --if test "x$CONFIG_UDEV" = xauto; then -- CONFIG_UDEV="$HAVE_LIBUDEV" -+ if test "x$CONFIG_UDEV" = xauto; then -+ CONFIG_UDEV="$HAVE_LIBUDEV" - - printf "%s\n" "#define HAVE_LIBUDEV 1" >>confdefs.h - -+ fi - fi - if test "x$CONFIG_UDEV" = xyes; then - CONFIG_UDEV_TRUE= -@@ -26132,7 +26173,14 @@ fi - - if test "x$SYSTEMD_LOGIND" = xauto; then - if test "x$HAVE_DBUS" = xyes -a "x$CONFIG_UDEV" = xyes ; then -- SYSTEMD_LOGIND=yes -+ case $host_os in -+ *linux*) -+ SYSTEMD_LOGIND=yes -+ ;; -+ *) -+ SYSTEMD_LOGIND=no -+ ;; -+ esac - else - SYSTEMD_LOGIND=no - fi -@@ -32849,17 +32897,17 @@ DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER - ac_config_commands="$ac_config_commands sdksyms" - - --if test "x$CONFIG_HAL" = xno && test "x$CONFIG_UDEV" = xno; then -+if test "x$CONFIG_HAL" = xno && test "x$CONFIG_UDEV" = xno && test "x$CONFIG_DEVD" = xno; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: -- *********************************************** -- Neither HAL nor udev backend will be enabled. -+ ***************************************************** -+ Neither HAL, devd, nor udev backend will be enabled. - Input device hotplugging will not be available! -- ***********************************************" >&5 -+ *****************************************************" >&5 - printf "%s\n" "$as_me: WARNING: -- *********************************************** -- Neither HAL nor udev backend will be enabled. -+ ***************************************************** -+ Neither HAL, devd, nor udev backend will be enabled. - Input device hotplugging will not be available! -- ***********************************************" >&2;} -+ *****************************************************" >&2;} - fi - - ac_config_files="$ac_config_files Makefile glx/Makefile include/Makefile composite/Makefile damageext/Makefile dbe/Makefile dix/Makefile doc/Makefile doc/dtrace/Makefile man/Makefile fb/Makefile glamor/Makefile record/Makefile config/Makefile mi/Makefile miext/Makefile miext/sync/Makefile miext/damage/Makefile miext/shadow/Makefile miext/rootless/Makefile os/Makefile pseudoramiX/Makefile randr/Makefile render/Makefile xkb/Makefile Xext/Makefile Xi/Makefile xfixes/Makefile exa/Makefile dri3/Makefile present/Makefile hw/Makefile hw/xfree86/Makefile hw/xfree86/Xorg.sh hw/xfree86/common/Makefile hw/xfree86/common/xf86Build.h hw/xfree86/ddc/Makefile hw/xfree86/dixmods/Makefile hw/xfree86/doc/Makefile hw/xfree86/dri/Makefile hw/xfree86/dri2/Makefile hw/xfree86/dri2/pci_ids/Makefile hw/xfree86/drivers/Makefile hw/xfree86/drivers/modesetting/Makefile hw/xfree86/exa/Makefile hw/xfree86/exa/man/Makefile hw/xfree86/fbdevhw/Makefile hw/xfree86/fbdevhw/man/Makefile hw/xfree86/glamor_egl/Makefile hw/xfree86/i2c/Makefile hw/xfree86/int10/Makefile hw/xfree86/loader/Makefile hw/xfree86/man/Makefile hw/xfree86/modes/Makefile hw/xfree86/os-support/Makefile hw/xfree86/os-support/bsd/Makefile hw/xfree86/os-support/bus/Makefile hw/xfree86/os-support/hurd/Makefile hw/xfree86/os-support/misc/Makefile hw/xfree86/os-support/linux/Makefile hw/xfree86/os-support/solaris/Makefile hw/xfree86/os-support/stub/Makefile hw/xfree86/parser/Makefile hw/xfree86/ramdac/Makefile hw/xfree86/shadowfb/Makefile hw/xfree86/vbe/Makefile hw/xfree86/vgahw/Makefile hw/xfree86/x86emu/Makefile hw/xfree86/utils/Makefile hw/xfree86/utils/man/Makefile hw/xfree86/utils/cvt/Makefile hw/xfree86/utils/gtf/Makefile hw/dmx/config/Makefile hw/dmx/config/man/Makefile hw/dmx/doc/Makefile hw/dmx/doxygen/doxygen.conf hw/dmx/doxygen/Makefile hw/dmx/examples/Makefile hw/dmx/input/Makefile hw/dmx/glxProxy/Makefile hw/dmx/Makefile hw/dmx/man/Makefile hw/vfb/Makefile hw/vfb/man/Makefile hw/xnest/Makefile hw/xnest/man/Makefile hw/xwin/Makefile hw/xwin/dri/Makefile hw/xwin/glx/Makefile hw/xwin/man/Makefile hw/xwin/winclipboard/Makefile hw/xquartz/Makefile hw/xquartz/GL/Makefile hw/xquartz/bundle/Makefile hw/xquartz/man/Makefile hw/xquartz/mach-startup/Makefile hw/xquartz/pbproxy/Makefile hw/xquartz/xpr/Makefile hw/kdrive/Makefile hw/kdrive/ephyr/Makefile hw/kdrive/ephyr/man/Makefile hw/kdrive/fake/Makefile hw/kdrive/fbdev/Makefile hw/kdrive/linux/Makefile hw/kdrive/src/Makefile hw/xwayland/Makefile test/Makefile test/xi1/Makefile test/xi2/Makefile xserver.ent xorg-server.pc" -@@ -33122,6 +33170,10 @@ if test -z "${HAVE_SYSTEMD_DAEMON_TRUE}" - as_fn_error $? "conditional \"HAVE_SYSTEMD_DAEMON\" was never defined. - Usually this means the macro was only invoked conditionally." "$LINENO" 5 - fi -+if test -z "${CONFIG_DEVD_TRUE}" && test -z "${CONFIG_DEVD_FALSE}"; then -+ as_fn_error $? "conditional \"CONFIG_DEVD\" was never defined. -+Usually this means the macro was only invoked conditionally." "$LINENO" 5 -+fi - if test -z "${CONFIG_UDEV_TRUE}" && test -z "${CONFIG_UDEV_FALSE}"; then - as_fn_error $? "conditional \"CONFIG_UDEV\" was never defined. - Usually this means the macro was only invoked conditionally." "$LINENO" 5 Index: x11-servers/xorg-server/files/patch-hw_xfree86_Makefile.in =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_Makefile.in +++ /dev/null @@ -1,14 +0,0 @@ -* Don't overwrite Xorg binary with Xorg.sh when SUID_WRAPPER_DIR == bindir -* Instead, relink bin/X to Xorg.wrap rather than to Xorg (which isn't Xorg.sh) -* ---- hw/xfree86/Makefile.in.orig 2017-03-16 05:24:43 UTC -+++ hw/xfree86/Makefile.in -@@ -1156,7 +1156,7 @@ install-exec-hook: - @INSTALL_SETUID_TRUE@ chmod u+s $(DESTDIR)$(bindir)/Xorg - @SUID_WRAPPER_TRUE@ $(MKDIR_P) $(DESTDIR)$(SUID_WRAPPER_DIR) - @SUID_WRAPPER_TRUE@ mv $(DESTDIR)$(bindir)/Xorg $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg --@SUID_WRAPPER_TRUE@ ${INSTALL} -m 755 Xorg.sh $(DESTDIR)$(bindir)/Xorg -+@SUID_WRAPPER_TRUE@ (test ! -f $(DESTDIR)$(bindir)/Xorg && ${INSTALL} -m 755 Xorg.sh $(DESTDIR)$(bindir)/Xorg || cd $(DESTDIR)$(bindir) && rm -f X && $(LN_S) Xorg.wrap$(EXEEXT) X) - @SUID_WRAPPER_TRUE@ -chown 0 $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg.wrap && chmod u+s $(DESTDIR)$(SUID_WRAPPER_DIR)/Xorg.wrap - - uninstall-local: Index: x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86AutoConfig.c =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86AutoConfig.c +++ x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86AutoConfig.c @@ -2,9 +2,9 @@ * * Use our scfb driver as fallback instead of Linux's fbdev * ---- hw/xfree86/common/xf86AutoConfig.c.orig 2017-03-15 18:05:25 UTC -+++ hw/xfree86/common/xf86AutoConfig.c -@@ -294,7 +294,7 @@ listPossibleVideoDrivers(XF86MatchedDriv +--- hw/xfree86/common/xf86AutoConfig.c.orig 2022-01-02 23:41:56.000000000 +0100 ++++ hw/xfree86/common/xf86AutoConfig.c 2022-06-29 11:57:25.400030000 +0200 +@@ -294,7 +294,7 @@ listPossibleVideoDrivers(XF86MatchedDrivers *md) xf86PciMatchDriver(md); #endif @@ -13,7 +13,7 @@ xf86AddMatchedDriver(md, "modesetting"); #endif -@@ -302,8 +302,10 @@ listPossibleVideoDrivers(XF86MatchedDriv +@@ -302,8 +302,10 @@ listPossibleVideoDrivers(XF86MatchedDrivers *md) /* Fallback to platform default frame buffer driver */ #if !defined(__linux__) && defined(__sparc__) xf86AddMatchedDriver(md, "wsfb"); Index: x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Config.c =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Config.c +++ /dev/null @@ -1,22 +0,0 @@ -* Select the devd config backend if it is activated -* ---- hw/xfree86/common/xf86Config.c.orig 2017-03-15 18:05:25 UTC -+++ hw/xfree86/common/xf86Config.c -@@ -1375,13 +1375,16 @@ checkCoreInputDevices(serverLayoutPtr se - } - - if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) { --#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) -+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) || \ -+ defined(CONFIG_DEVD) - const char *config_backend; - - #if defined(CONFIG_HAL) - config_backend = "HAL"; - #elif defined(CONFIG_UDEV) - config_backend = "udev"; -+#elif defined(CONFIG_DEVD) -+ config_backend = "devd"; - #else - config_backend = "wscons"; - #endif Index: x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Globals.c =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Globals.c +++ /dev/null @@ -1,14 +0,0 @@ -* Include devd in the set of config backends -* ---- hw/xfree86/common/xf86Globals.c.orig 2017-03-15 18:05:25 UTC -+++ hw/xfree86/common/xf86Globals.c -@@ -119,7 +119,8 @@ xf86InfoRec xf86Info = { - .miscModInDevEnabled = TRUE, - .miscModInDevAllowNonLocal = FALSE, - .pmFlag = TRUE, --#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) -+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) || \ -+ defined(CONFIG_DEVD) - .forceInputDevices = FALSE, - .autoAddDevices = TRUE, - .autoEnableDevices = TRUE, Index: x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Xinput.c =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Xinput.c +++ /dev/null @@ -1,21 +0,0 @@ -* Recognize devd backend as a source of auto-configured devices -* ---- hw/xfree86/common/xf86Xinput.c.orig 2017-03-15 18:05:25 UTC -+++ hw/xfree86/common/xf86Xinput.c -@@ -871,7 +871,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, D - { - InputDriverPtr drv = NULL; - DeviceIntPtr dev = NULL; -- Bool paused; -+ Bool paused = 0; - int rval; - char *path = NULL; - -@@ -1034,6 +1034,7 @@ NewInputDeviceRequest(InputOption *optio - if (strcmp(key, "_source") == 0 && - (strcmp(value, "server/hal") == 0 || - strcmp(value, "server/udev") == 0 || -+ strcmp(value, "server/devd") == 0 || - strcmp(value, "server/wscons") == 0)) { - is_auto = 1; - if (!xf86Info.autoAddDevices) { Index: x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86str.h =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86str.h +++ x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86str.h @@ -1,5 +1,5 @@ ---- hw/xfree86/common/xf86str.h.orig 2020-02-23 17:34:26 UTC -+++ hw/xfree86/common/xf86str.h +--- hw/xfree86/common/xf86str.h.orig 2022-01-02 23:41:56.000000000 +0100 ++++ hw/xfree86/common/xf86str.h 2022-06-29 11:57:25.502421000 +0200 @@ -249,7 +249,7 @@ typedef struct _DriverRec { */ Index: x11-servers/xorg-server/files/patch-hw_xfree86_meson.build =================================================================== --- /dev/null +++ x11-servers/xorg-server/files/patch-hw_xfree86_meson.build @@ -0,0 +1,11 @@ +--- hw/xfree86/meson.build.orig 2022-06-29 14:37:28.042085000 +0000 ++++ hw/xfree86/meson.build 2022-06-29 14:37:36.259147000 +0000 +@@ -152,7 +152,7 @@ if get_option('suid_wrapper') + c_args: xorg_c_args, + install: true, + install_dir: get_option('libexecdir'), +- install_mode: ['r-sr-xr-x', 0, 0], ++ # install_mode: ['r-sr-xr-x', 0, 0], + ) + + # meson gets confused when there are two targets of the same name Index: x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_bsd__init.c =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_bsd__init.c +++ x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_bsd__init.c @@ -1,6 +1,6 @@ ---- hw/xfree86/os-support/bsd/bsd_init.c.orig 2017-03-15 18:05:25 UTC -+++ hw/xfree86/os-support/bsd/bsd_init.c -@@ -48,6 +48,8 @@ static int devConsoleFd = -1; +--- hw/xfree86/os-support/bsd/bsd_init.c.orig 2022-01-02 23:41:56.000000000 +0100 ++++ hw/xfree86/os-support/bsd/bsd_init.c 2022-06-29 11:57:25.596851000 +0200 +@@ -48,6 +48,8 @@ static int initialVT = -1; #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) static int VTnum = -1; static int initialVT = -1; Index: x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_ppc__video.c =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_ppc__video.c +++ x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_ppc__video.c @@ -1,5 +1,5 @@ ---- hw/xfree86/os-support/bsd/ppc_video.c.orig 2016-07-15 16:18:11 UTC -+++ hw/xfree86/os-support/bsd/ppc_video.c +--- hw/xfree86/os-support/bsd/ppc_video.c.orig 2022-01-02 23:41:56.000000000 +0100 ++++ hw/xfree86/os-support/bsd/ppc_video.c 2022-06-29 11:57:25.691481000 +0200 @@ -79,7 +79,11 @@ xf86DisableIO() { Index: x11-servers/xorg-server/files/patch-hw_xfree86_xorg-wrapper.c =================================================================== --- x11-servers/xorg-server/files/patch-hw_xfree86_xorg-wrapper.c +++ x11-servers/xorg-server/files/patch-hw_xfree86_xorg-wrapper.c @@ -1,27 +1,23 @@ * Skip the detection of root rights requirement, the assumption that presence * of KMS drivers removes the root requirement is only valid for Linux * ---- hw/xfree86/xorg-wrapper.c.orig 2017-03-15 18:05:25 UTC -+++ hw/xfree86/xorg-wrapper.c -@@ -188,9 +188,6 @@ static int on_console(int fd) +--- hw/xfree86/xorg-wrapper.c.orig 2022-01-02 23:41:56.000000000 +0100 ++++ hw/xfree86/xorg-wrapper.c 2022-06-29 16:28:24.797008000 +0200 +@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) int main(int argc, char *argv[]) { -#ifdef WITH_LIBDRM -- struct drm_mode_card_res res; --#endif ++#ifdef WITH_LIBDRM && defined(__linux__) + struct drm_mode_card_res res; + #endif char buf[PATH_MAX]; - int i, r, fd; - int kms_cards = 0; -@@ -227,9 +224,10 @@ int main(int argc, char *argv[]) +@@ -230,7 +230,7 @@ int main(int argc, char *argv[]) } } -#ifdef WITH_LIBDRM -+#if defined(WITH_LIBDRM) && defined(__linux__) - /* Detect if we need root rights, except when overriden by the config */ ++#ifdef WITH_LIBDRM && defined(__linux__) + /* Detect if we need root rights, except when overridden by the config */ if (needs_root_rights == -1) { -+ struct drm_mode_card_res res; for (i = 0; i < 16; i++) { - snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, i); - fd = open(buf, O_RDWR); Index: x11-servers/xorg-server/files/patch-include_dix-config.h.in =================================================================== --- x11-servers/xorg-server/files/patch-include_dix-config.h.in +++ /dev/null @@ -1,14 +0,0 @@ -* Add a define which will be toggled by configure when devd backend is activated -* ---- include/dix-config.h.in.orig 2017-03-15 18:05:25 UTC -+++ include/dix-config.h.in -@@ -433,6 +433,9 @@ - /* Support D-Bus */ - #undef HAVE_DBUS - -+/* Use devd for input hotplug */ -+#undef CONFIG_DEVD -+ - /* Use libudev for input hotplug */ - #undef CONFIG_UDEV - Index: x11-servers/xorg-server/files/patch-test_xtest.c =================================================================== --- x11-servers/xorg-server/files/patch-test_xtest.c +++ /dev/null @@ -1,17 +0,0 @@ ---- test/xtest.c.orig 2019-04-30 16:40:02.828913000 -0700 -+++ test/xtest.c 2019-04-30 16:40:42.769713000 -0700 -@@ -59,10 +59,10 @@ - static void - xtest_init_devices(void) - { -- ScreenRec screen = {0}; -- ClientRec server_client = {0}; -- WindowRec root = {0}; -- WindowOptRec optional = {0}; -+ ScreenRec screen = {{0}}; -+ ClientRec server_client = {{0}}; -+ WindowRec root = {{0}}; -+ WindowOptRec optional = {{0}}; - - /* random stuff that needs initialization */ - root.drawable.id = 0xab; Index: x11-servers/xorg-server/files/patch-xkb_Makefile.in =================================================================== --- x11-servers/xorg-server/files/patch-xkb_Makefile.in +++ /dev/null @@ -1,16 +0,0 @@ -* Skip installing a README into a directory which is actually a symlink created -* by another port. If this file is installed, then upon uninstall pkg will -* delete the directory under the symlink, which would cause a reinstall to fail -* as the target directory is not remade until reinstalling the other port -* ---- xkb/Makefile.in.orig 2017-03-16 05:24:43 UTC -+++ xkb/Makefile.in -@@ -886,7 +886,7 @@ info: info-am - - info-am: - --install-data-am: install-dist_xkbcompiledDATA -+install-data-am: - - install-dvi: install-dvi-am - Index: x11-servers/xorg-server/files/xkb_Makefile.am =================================================================== --- x11-servers/xorg-server/files/xkb_Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -* Skip installing a README into a directory which is actually a symlink created -* by another port. If this file is installed, then upon uninstall pkg will -* delete the directory under the symlink, which would cause a reinstall to fail -* as the target directory is not remade until reinstalling the other port -* ---- xkb/Makefile.am.orig 2017-03-16 05:24:43 UTC -+++ xkb/Makefile.am -@@ -39,4 +39,4 @@ libxkbstubs_la_SOURCES = ddxVT.c ddxPriv - EXTRA_DIST = xkbDflts.h xkbgeom.h xkb.h - - xkbcompileddir = $(XKB_COMPILED_DIR) --dist_xkbcompiled_DATA = README.compiled -+#dist_xkbcompiled_DATA = README.compiled Index: x11-servers/xorg-server/pkg-descr =================================================================== --- /dev/null +++ x11-servers/xorg-server/pkg-descr @@ -1,3 +0,0 @@ -This package contains the X.Org X server and some associated programs. - -WWW: http://www.freedesktop.org/Software/xorg Index: x11-servers/xorg-server/pkg-plist =================================================================== --- x11-servers/xorg-server/pkg-plist +++ x11-servers/xorg-server/pkg-plist @@ -1,11 +1,6 @@ bin/X bin/Xorg -%%SUID%%@(,,4555) bin/Xorg.wrap -bin/cvt bin/gtf -include/xorg/BT.h -include/xorg/IBM.h -include/xorg/TI.h include/xorg/XIstubs.h include/xorg/Xprintf.h include/xorg/callback.h @@ -109,7 +104,6 @@ include/xorg/shadow.h include/xorg/shadowfb.h include/xorg/shmint.h -include/xorg/site.h include/xorg/syncsdk.h include/xorg/validate.h include/xorg/vbe.h @@ -137,7 +131,6 @@ include/xorg/xf86PciInfo.h include/xorg/xf86Priv.h include/xorg/xf86Privstr.h -include/xorg/xf86RamDac.h include/xorg/xf86RandR12.h %%SPARC64%%include/xorg/xf86Sbus.h include/xorg/xf86VGAarbiter.h @@ -165,33 +158,35 @@ include/xorg/xserver_poll.h include/xorg/xvdix.h include/xorg/xvmcext.h +include/xorg/xf86-input-inputtest-protocol.h lib/xorg/modules/drivers/modesetting_drv.so lib/xorg/modules/extensions/.xorg/libglx.so +lib/xorg/modules/input/inputtest_drv.so lib/xorg/modules/libexa.so -lib/xorg/modules/libfb.so -lib/xorg/modules/libfbdevhw.so lib/xorg/modules/libglamoregl.so lib/xorg/modules/libint10.so lib/xorg/modules/libshadow.so lib/xorg/modules/libshadowfb.so -lib/xorg/modules/libvbe.so +lib/xorg/modules/libfbdevhw.so lib/xorg/modules/libvgahw.so lib/xorg/modules/libwfb.so lib/xorg/protocol.txt libdata/pkgconfig/xorg-server.pc +%%SUID%%@(,,4555) libexec/Xorg.wrap man/man1/Xorg.1.gz %%SUID%%man/man1/Xorg.wrap.1.gz man/man1/Xserver.1.gz -man/man1/cvt.1.gz man/man1/gtf.1.gz man/man4/exa.4.gz man/man4/fbdevhw.4.gz +man/man4/inputtestdrv.4.gz man/man4/modesetting.4.gz %%SUID%%man/man5/Xwrapper.config.5.gz man/man5/xorg.conf.5.gz man/man5/xorg.conf.d.5.gz -%%UDEV%%share/X11/xorg.conf.d/10-quirks.conf +share/X11/xorg.conf.d/10-quirks.conf share/X11/xorg.conf.d/20-evdev-kbd.conf share/aclocal/xorg-server.m4 @dir etc/X11/xorg.conf.d @dir %%FONTPATHD%% +@dir /var/db/xkb Index: x11-servers/xorg-vfbserver/Makefile =================================================================== --- x11-servers/xorg-vfbserver/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -# Created by: Eric Anholt - -PORTNAME= xorg-vfbserver -PORTREVISION= 0 -PORTEPOCH= 1 - -COMMENT= X virtual framebuffer server from X.Org - -LICENSE= MIT - -MASTERDIR= ${.CURDIR}/../xorg-server -DESCR= ${.CURDIR}/pkg-descr - -SLAVE_PORT= yes - -CONFIGURE_ARGS+=--enable-xvfb --disable-dmx --disable-xephyr --disable-xnest \ - --disable-xwayland - -PLIST_FILES= bin/Xvfb man/man1/Xvfb.1.gz - -do-install: - cd ${WRKSRC}/hw/vfb; DESTDIR=${STAGEDIR} ${MAKE} install - -.include "${MASTERDIR}/Makefile" Index: x11-servers/xorg-vfbserver/pkg-descr =================================================================== --- /dev/null +++ x11-servers/xorg-vfbserver/pkg-descr @@ -1,3 +0,0 @@ -This package contains Xvfb, a virtual framebuffer X server. - -WWW: https://www.x.org/ Index: x11/py-pyvirtualdisplay/Makefile =================================================================== --- x11/py-pyvirtualdisplay/Makefile +++ x11/py-pyvirtualdisplay/Makefile @@ -31,10 +31,10 @@ XEPHYR_DESC= Install Xephyr backend XVNC_DESC= Install Xvnc backend -XVFB_RUN_DEPENDS= xorg-vfbserver>0:x11-servers/xorg-vfbserver -XEPHYR_RUN_DEPENDS= xephyr>=0:x11-servers/xephyr +XVFB_RUN_DEPENDS= Xvfb:x11-servers/xorg-server@Xvfb +XEPHYR_RUN_DEPENDS= Xephyr>=0:x11-servers/xorg-server@Xvfb XVNC_RUN_DEPENDS= tightvnc>=0:net/tightvnc NO_ARCH= yes -.include +hanninclude Index: x11/xorg/Makefile =================================================================== --- x11/xorg/Makefile +++ x11/xorg/Makefile @@ -27,9 +27,8 @@ xorg-drivers>0:x11-drivers/xorg-drivers .if defined(XORG_COMPLETE) -RUN_DEPENDS+= Xnest:x11-servers/xorg-nestserver \ - Xdmx:x11-servers/xorg-dmx \ - Xvfb:x11-servers/xorg-vfbserver +RUN_DEPENDS+= Xnest:x11-servers/xorg-server@Xnest \ + Xvfb:x11-servers/xorg-server@Xvfb .endif .include Index: x11/xpra/Makefile =================================================================== --- x11/xpra/Makefile +++ x11/xpra/Makefile @@ -30,7 +30,7 @@ ssh-askpass:security/openssh-askpass \ xauth:x11/xauth \ xkbcomp:x11/xkbcomp \ - Xvfb:x11-servers/xorg-vfbserver + Xvfb:x11-servers/xorg-server@Xvfb USES= desktop-file-utils gettext-runtime gnome pkgconfig \ python:3.6+ shared-mime-info shebangfix tar:xz xorg