aboutsummaryrefslogtreecommitdiff
path: root/x11-servers
diff options
context:
space:
mode:
authorNiclas Zeising <zeising@FreeBSD.org>2020-02-20 21:15:44 +0000
committerNiclas Zeising <zeising@FreeBSD.org>2020-02-20 21:15:44 +0000
commit4b9c697c260cea91ea55f15c82727076e1b64169 (patch)
tree8eb97083048a09d8ff688a6feffec83dbadd756a /x11-servers
parent61f74551751784736def2694000d3b20c5110126 (diff)
downloadports-4b9c697c260cea91ea55f15c82727076e1b64169.tar.gz
ports-4b9c697c260cea91ea55f15c82727076e1b64169.zip
Update xorg x11 servers to 1.20.7
Update xorg x11 servers to 1.20.7. This updates x11-servers/xorg-server, xephyr, xorg-dmx, xorg-nestserver, xorg-vbserver and xwayland. Enable the UDEV backend by default, instead of the DEVD backend, for autoconfiguration of input devices on FreeBSD 12 and later. FreeBSD 11 lacks the needed support in base and will keep on using the DEVD backend. Support for the HAL backend is dropped completely, it has been deprecated for a long time. Update and improve the DEVD backend. Add a pkg message about sysctl configuration that might be needed when using UDEV. Use the upstream fix for glamour issues. Use evdev xkb rules by default in xwayland [2] Add x11-drivers/xf86-input-libinput to the list installed by default by x11-drivers/xorg-drivers. Fix net/tigervnc-server and emulators/virtualbox-ose Bump portrevision of all x11 drivers, as well as other ports dependent on xorg-server. This represents work by many people over a long period. These include wulf, ak, dumbbell, hselasky pete AT nomadlogic DOT org, jbeich, manu, myself and possibly others (I tried to look through history, but might have missed people. If so, I am sorry.) PR: 196678 [1], 244129 [2] Submitted by: hselasky, wulf [1], jbeich [2] Obtained from: https://github.com/FreeBSDDesktop/freebsd-ports/tree/feature/xserver-1.20 (in part)
Notes
Notes: svn path=/head/; revision=526589
Diffstat (limited to 'x11-servers')
-rw-r--r--x11-servers/xephyr/Makefile2
-rw-r--r--x11-servers/xorg-dmx/Makefile2
-rw-r--r--x11-servers/xorg-nestserver/Makefile18
-rw-r--r--x11-servers/xorg-nestserver/distinfo3
-rw-r--r--x11-servers/xorg-server/Makefile87
-rw-r--r--x11-servers/xorg-server/distinfo6
-rw-r--r--x11-servers/xorg-server/files/20-evdev-kbd.conf6
-rw-r--r--x11-servers/xorg-server/files/config_Makefile.am16
-rw-r--r--x11-servers/xorg-server/files/configure.ac97
-rw-r--r--x11-servers/xorg-server/files/hw_xfree86_Makefile.am14
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-10971163
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1097238
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1217631
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1217741
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1217829
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1217952
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1218395
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1218x601
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1218y139
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-1372126
-rw-r--r--x11-servers/xorg-server/files/patch-CVE-2017-13723115
-rw-r--r--x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-misc-Makefile.in2
-rw-r--r--x11-servers/xorg-server/files/patch-config_Makefile.in100
-rw-r--r--x11-servers/xorg-server/files/patch-config_config-backends.h13
-rw-r--r--x11-servers/xorg-server/files/patch-config_config.c4
-rw-r--r--x11-servers/xorg-server/files/patch-config_devd.c1025
-rw-r--r--x11-servers/xorg-server/files/patch-config_udev.c56
-rw-r--r--x11-servers/xorg-server/files/patch-configure166
-rw-r--r--x11-servers/xorg-server/files/patch-glamor_glamor__dash.c27
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_Makefile.in14
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86AutoConfig.c24
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Config.c8
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Globals.c10
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Xinput.c8
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_dri2_pci__ids_i965__pci__ids.h171
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_bsd__init.c57
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_i386__video.c11
-rw-r--r--x11-servers/xorg-server/files/patch-hw_xfree86_xorg-wrapper.c27
-rw-r--r--x11-servers/xorg-server/files/patch-include_dix-config.h.in14
-rw-r--r--x11-servers/xorg-server/files/patch-os_io.c34
-rw-r--r--x11-servers/xorg-server/files/patch-test_xtest.c17
-rw-r--r--x11-servers/xorg-server/files/patch-xkb_Makefile.in9
-rw-r--r--x11-servers/xorg-server/files/xkb_Makefile.am13
-rw-r--r--x11-servers/xorg-server/pkg-message26
-rw-r--r--x11-servers/xorg-server/pkg-plist12
-rw-r--r--x11-servers/xorg-vfbserver/Makefile17
-rw-r--r--x11-servers/xorg-vfbserver/distinfo3
-rw-r--r--x11-servers/xwayland/Makefile26
-rw-r--r--x11-servers/xwayland/distinfo3
49 files changed, 1374 insertions, 2104 deletions
diff --git a/x11-servers/xephyr/Makefile b/x11-servers/xephyr/Makefile
index 38b5a720316c..b6c0805100d0 100644
--- a/x11-servers/xephyr/Makefile
+++ b/x11-servers/xephyr/Makefile
@@ -16,8 +16,6 @@ MASTERDIR= ${.CURDIR}/../xorg-server
DESCR= ${.CURDIR}/pkg-descr
SLAVE_PORT= yes
-OPTIONS_EXCLUDE=DEVD HAL SUID UDEV
-
USE_XORG= x11 xcb
CONFIGURE_ARGS+=--enable-xephyr --disable-dmx --disable-xnest --disable-xvfb \
diff --git a/x11-servers/xorg-dmx/Makefile b/x11-servers/xorg-dmx/Makefile
index f78c64797b8b..a88feac4033a 100644
--- a/x11-servers/xorg-dmx/Makefile
+++ b/x11-servers/xorg-dmx/Makefile
@@ -11,8 +11,6 @@ MASTERDIR= ${.CURDIR}/../xorg-server
DESCR= ${.CURDIR}/pkg-descr
SLAVE_PORT= yes
-OPTIONS_EXCLUDE=DEVD HAL SUID UDEV
-
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 \
diff --git a/x11-servers/xorg-nestserver/Makefile b/x11-servers/xorg-nestserver/Makefile
index 0c2f122987ba..5a2473579de4 100644
--- a/x11-servers/xorg-nestserver/Makefile
+++ b/x11-servers/xorg-nestserver/Makefile
@@ -2,7 +2,6 @@
# $FreeBSD$
PORTNAME= xorg-nestserver
-PORTVERSION= 1.19.1
PORTEPOCH= 2
COMMENT= Nesting X server from X.Org
@@ -11,32 +10,17 @@ LICENSE= MIT
MASTERDIR= ${.CURDIR}/../xorg-server
DESCR= ${.CURDIR}/pkg-descr
-DISTINFO_FILE= ${.CURDIR}/distinfo
-PATCHDIR= ${.CURDIR}/files
RUN_DEPENDS= xkeyboard-config>=2.5:x11/xkeyboard-config
SLAVE_PORT= yes
-OPTIONS_EXCLUDE=DEVD HAL SUID UDEV
-
-USE_XORG= x11 xext xfont2
+USE_XORG= x11 xext
CONFIGURE_ARGS+=--enable-xnest --disable-dmx --disable-xephyr --disable-xvfb \
--disable-xwayland
PLIST_FILES= bin/Xnest man/man1/Xnest.1.gz
-EXTRA_PATCHES= ${MASTERDIR}/files/patch-CVE-2017-12176 \
- ${MASTERDIR}/files/patch-CVE-2017-12177 \
- ${MASTERDIR}/files/patch-CVE-2017-12178 \
- ${MASTERDIR}/files/patch-CVE-2017-12179 \
- ${MASTERDIR}/files/patch-CVE-2017-12183 \
- ${MASTERDIR}/files/patch-CVE-2017-1218x \
- ${MASTERDIR}/files/patch-CVE-2017-1218y \
- ${MASTERDIR}/files/patch-CVE-2017-13721 \
- ${MASTERDIR}/files/patch-CVE-2017-13723 \
- ${MASTERDIR}/files/patch-os_io.c
-
do-install:
cd ${WRKSRC}/hw/xnest; DESTDIR=${STAGEDIR} ${MAKE} install
diff --git a/x11-servers/xorg-nestserver/distinfo b/x11-servers/xorg-nestserver/distinfo
deleted file mode 100644
index 2083f2d9a628..000000000000
--- a/x11-servers/xorg-nestserver/distinfo
+++ /dev/null
@@ -1,3 +0,0 @@
-TIMESTAMP = 1484388904
-SHA256 (xorg/xserver/xorg-server-1.19.1.tar.bz2) = 79ae2cf39d3f6c4a91201d8dad549d1d774b3420073c5a70d390040aa965a7fb
-SIZE (xorg/xserver/xorg-server-1.19.1.tar.bz2) = 6041792
diff --git a/x11-servers/xorg-server/Makefile b/x11-servers/xorg-server/Makefile
index f392309b28b0..c74b7f600f28 100644
--- a/x11-servers/xorg-server/Makefile
+++ b/x11-servers/xorg-server/Makefile
@@ -2,8 +2,8 @@
# $FreeBSD$
PORTNAME?= xorg-server
-PORTVERSION?= 1.18.4
-PORTREVISION?= 13
+PORTVERSION?= 1.20.7
+PORTREVISION?= 0
PORTEPOCH?= 1
CATEGORIES= x11-servers
MASTER_SITES= XORG/individual/xserver
@@ -22,14 +22,24 @@ SLAVE_PORT?= no
OPTIONS_SUB= yes
OPTIONS_DEFINE= SUID
OPTIONS_RADIO= CONF
-OPTIONS_RADIO_CONF= DEVD HAL UDEV
+OPTIONS_RADIO_CONF= DEVD UDEV
+OPTIONS_DEFAULT= SUID
+OPTIONS_DEFAULT_FreeBSD_11= DEVD
+OPTIONS_DEFAULT_FreeBSD_12= UDEV
+OPTIONS_DEFAULT_FreeBSD_13= 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
-HAL_DESC= Use hald for autoconfiguration of input devices
UDEV_DESC= Use udev via libudev-devd for autoconfiguration of input devices
-SUID_DESC= Install the Xorg server with setuid bit set
-OPTIONS_DEFAULT=DEVD SUID
-OPTIONS_EXCLUDE_sparc64= HAL
+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
.include <bsd.port.options.mk>
@@ -46,15 +56,14 @@ DEFAULT_FONTPATH_LIST= \
DEFAULT_FONTPATH_CMD=${ECHO_CMD} ${DEFAULT_FONTPATH_LIST} | ${TR} ' ' ,
PLIST_SUB+= FONTPATHD="${FONTPATHD:S,^${PREFIX}/,,}"
-USES= gmake gl libtool perl5 ssl tar:bzip2 xorg xorg-cat:xserver
+USES= gl gmake perl5 ssl xorg xorg-cat:xserver
USE_PERL5= build
USE_GL+= gl
-USE_XORG+= pixman xau xdmcp xfont xkbfile xorgproto xshmfence xtrans
+USE_XORG+= pixman xau xdmcp xfont2 xkbfile xorgproto xshmfence xtrans
CONFIGURE_ARGS+=--without-doxygen --without-xmlto --without-fop \
--with-default-font-path="$$(${DEFAULT_FONTPATH_CMD})" \
- --localstatedir=/var --with-shared-memory-dir=/tmp \
- --disable-config-udev-kms --disable-systemd-logind \
- --without-dtrace --enable-glamor
+ --without-dtrace --with-shared-memory-dir=/tmp \
+ --disable-install-setuid --disable-unit-tests
INSTALL_TARGET= install-strip
.if ${SLAVE_PORT} == "no" || ${PORTNAME} == "xephyr" || ${PORTNAME} == "xwayland"
@@ -71,9 +80,9 @@ 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
-# for slave ports we need to overwrite PLIST, so it doesn't overwrite
-# PLIST_FILES, with the masterport plist.
+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
@@ -86,23 +95,6 @@ PLIST= ${.CURDIR}/pkg-plist
CONFIGURE_ENV= SHA1_LIB="-L/usr/lib -lcrypto" SHA1_CFLAGS="-I/usr/include"
.endif
-.if ${PORT_OPTIONS:MHAL}
-LIB_DEPENDS+= libhal.so:sysutils/hal
-CONFIGURE_ARGS+= --enable-config-hal
-.else
-CONFIGURE_ARGS+= --disable-config-hal
-.endif
-
-.if ${PORT_OPTIONS:MUDEV}
-LIB_DEPENDS+= libudev.so:devel/libudev-devd
-CONFIGURE_ARGS+= --enable-config-udev
-.else
-CONFIGURE_ARGS+= --disable-config-udev
-.endif
-
-# We handle Xorg setuid in the plist. This allows to build xorg-server as a user.
-CONFIGURE_ARGS+=--disable-install-setuid
-
.if ${ARCH} == "i386" || ${ARCH} == "amd64"
LIB_DEPENDS+= libunwind.so:devel/libunwind
.endif
@@ -113,42 +105,21 @@ PLIST_SUB+= SPARC64=""
PLIST_SUB+= SPARC64="@comment "
.endif
-.if ${PORT_OPTIONS:MSUID}
-pre-everything::
- @${ECHO_MSG} "By default, the X Server installs as a set-user-id root binary. When run by"
- @${ECHO_MSG} "a normal user, it checks arguments and environment as done in the x11/wrapper"
- @${ECHO_MSG} "port before handling them normally. If you are concerned about the security"
- @${ECHO_MSG} "of this, but still want to run an X Server (for example using xdm/kdm/gdm,"
- @${ECHO_MSG} "which will still run the server as root), you can cancel the build and set"
- @${ECHO_MSG} "xorg-server_UNSET=SUID in /etc/make.conf."
-.endif
-
post-patch:
@${REINPLACE_CMD} 's/test.*-traditional.*;/true;/' \
${WRKSRC}/configure
-# build libglx.so but don't install it yet. which is done in pre-install.
- @${REINPLACE_CMD} -e 's|@GLX_TRUE@GLXMODS =|@GLX_BOGUS@GLXMODS =|g' \
- -e 's|^LTLIBRARIES = |LTLIBRARIES = libglx.la |g' \
- ${WRKSRC}/hw/xfree86/dixmods/Makefile.in
-
-post-configure:
-.if ${PORT_OPTIONS:MDEVD}
- @${REINPLACE_CMD} -e 's|config\.c|config.c devd.c|g' \
- -e 's|config\.lo|config.lo devd.lo|g' \
- ${WRKSRC}/config/Makefile
- @${REINPLACE_CMD} -e 's|^/\* #undef CONFIG_UDEV \*/|#define CONFIG_DEVD 1|' \
- ${WRKSRC}/include/dix-config.h
-.endif
.if ${SLAVE_PORT} == "no"
post-install:
-# The .xorg dir because else the xorg-server might not load the correct
-# libglx module.
+# Avoid conflict with nvidia-driver, move libglx.so into .xorg directory
@${MKDIR} ${STAGEDIR}${PREFIX}/lib/xorg/modules/extensions/.xorg
- ${INSTALL_LIB} ${WRKSRC}/hw/xfree86/dixmods/.libs/libglx.so \
+ ${MV} ${STAGEDIR}${PREFIX}/lib/xorg/modules/extensions/libglx.so \
${STAGEDIR}${PREFIX}/lib/xorg/modules/extensions/.xorg/
@${MKDIR} ${STAGEDIR}${PREFIX}/etc/X11/xorg.conf.d
@${MKDIR} ${STAGEDIR}${FONTPATHD}
+ @${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
.include <bsd.port.post.mk>
diff --git a/x11-servers/xorg-server/distinfo b/x11-servers/xorg-server/distinfo
index 9a0938b3bccc..19954d70ef0b 100644
--- a/x11-servers/xorg-server/distinfo
+++ b/x11-servers/xorg-server/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1484803304
-SHA256 (xorg/xserver/xorg-server-1.18.4.tar.bz2) = 278459b2c31d61a15655d95a72fb79930c480a6bb8cf9226e48a07df8b1d31c8
-SIZE (xorg/xserver/xorg-server-1.18.4.tar.bz2) = 6009508
+TIMESTAMP = 1580036705
+SHA256 (xorg/xserver/xorg-server-1.20.7.tar.bz2) = bd5986f010f34f5b3d6bc99fe395ecb1e0dead15a26807e0c832701809a06ea1
+SIZE (xorg/xserver/xorg-server-1.20.7.tar.bz2) = 6303005
diff --git a/x11-servers/xorg-server/files/20-evdev-kbd.conf b/x11-servers/xorg-server/files/20-evdev-kbd.conf
new file mode 100644
index 000000000000..7a73fb641c36
--- /dev/null
+++ b/x11-servers/xorg-server/files/20-evdev-kbd.conf
@@ -0,0 +1,6 @@
+Section "InputClass"
+ Identifier "Evdev keyboard"
+ MatchDevicePath "/dev/input/event*"
+ MatchIsKeyboard "on"
+ Option "XkbRules" "evdev"
+EndSection
diff --git a/x11-servers/xorg-server/files/config_Makefile.am b/x11-servers/xorg-server/files/config_Makefile.am
new file mode 100644
index 000000000000..c62e761a4955
--- /dev/null
+++ b/x11-servers/xorg-server/files/config_Makefile.am
@@ -0,0 +1,16 @@
+* 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
diff --git a/x11-servers/xorg-server/files/configure.ac b/x11-servers/xorg-server/files/configure.ac
new file mode 100644
index 000000000000..91e74974db9f
--- /dev/null
+++ b/x11-servers/xorg-server/files/configure.ac
@@ -0,0 +1,97 @@
+* 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*)
+ 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([
diff --git a/x11-servers/xorg-server/files/hw_xfree86_Makefile.am b/x11-servers/xorg-server/files/hw_xfree86_Makefile.am
new file mode 100644
index 000000000000..6d9e0a0d26c6
--- /dev/null
+++ b/x11-servers/xorg-server/files/hw_xfree86_Makefile.am
@@ -0,0 +1,14 @@
+* 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
+
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-10971 b/x11-servers/xorg-server/files/patch-CVE-2017-10971
deleted file mode 100644
index 6eae9000fe40..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-10971
+++ /dev/null
@@ -1,163 +0,0 @@
-From 215f894965df5fb0bb45b107d84524e700d2073c Mon Sep 17 00:00:00 2001
-From: Michal Srb <msrb@suse.com>
-Date: Wed, 24 May 2017 15:54:40 +0300
-Subject: dix: Disallow GenericEvent in SendEvent request.
-
-The SendEvent request holds xEvent which is exactly 32 bytes long, no more,
-no less. Both ProcSendEvent and SProcSendEvent verify that the received data
-exactly match the request size. However nothing stops the client from passing
-in event with xEvent::type = GenericEvent and any value of
-xGenericEvent::length.
-
-In the case of ProcSendEvent, the event will be eventually passed to
-WriteEventsToClient which will see that it is Generic event and copy the
-arbitrary length from the receive buffer (and possibly past it) and send it to
-the other client. This allows clients to copy unitialized heap memory out of X
-server or to crash it.
-
-In case of SProcSendEvent, it will attempt to swap the incoming event by
-calling a swapping function from the EventSwapVector array. The swapped event
-is written to target buffer, which in this case is local xEvent variable. The
-xEvent variable is 32 bytes long, but the swapping functions for GenericEvents
-expect that the target buffer has size matching the size of the source
-GenericEvent. This allows clients to cause stack buffer overflows.
-
-Signed-off-by: Michal Srb <msrb@suse.com>
-Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- dix/events.c | 6 ++++++
- dix/swapreq.c | 7 +++++++
- 2 files changed, 13 insertions(+)
-
-diff --git a/dix/events.c b/dix/events.c
-index 3e3a01e..d3a33ea 100644
---- dix/events.c
-+++ dix/events.c
-@@ -5366,6 +5366,12 @@ ProcSendEvent(ClientPtr client)
- client->errorValue = stuff->event.u.u.type;
- return BadValue;
- }
-+ /* Generic events can have variable size, but SendEvent request holds
-+ exactly 32B of event data. */
-+ if (stuff->event.u.u.type == GenericEvent) {
-+ client->errorValue = stuff->event.u.u.type;
-+ return BadValue;
-+ }
- if (stuff->event.u.u.type == ClientMessage &&
- stuff->event.u.u.detail != 8 &&
- stuff->event.u.u.detail != 16 && stuff->event.u.u.detail != 32) {
-diff --git a/dix/swapreq.c b/dix/swapreq.c
-index 719e9b8..6785059 100644
---- dix/swapreq.c
-+++ dix/swapreq.c
-@@ -292,6 +292,13 @@ SProcSendEvent(ClientPtr client)
- swapl(&stuff->destination);
- swapl(&stuff->eventMask);
-
-+ /* Generic events can have variable size, but SendEvent request holds
-+ exactly 32B of event data. */
-+ if (stuff->event.u.u.type == GenericEvent) {
-+ client->errorValue = stuff->event.u.u.type;
-+ return BadValue;
-+ }
-+
- /* Swap event */
- proc = EventSwapVector[stuff->event.u.u.type & 0177];
- if (!proc || proc == NotImplemented) /* no swapping proc; invalid event type? */
---
-cgit v1.1
-
-From 8caed4df36b1f802b4992edcfd282cbeeec35d9d Mon Sep 17 00:00:00 2001
-From: Michal Srb <msrb@suse.com>
-Date: Wed, 24 May 2017 15:54:41 +0300
-Subject: Xi: Verify all events in ProcXSendExtensionEvent.
-
-The requirement is that events have type in range
-EXTENSION_EVENT_BASE..lastEvent, but it was tested
-only for first event of all.
-
-Signed-off-by: Michal Srb <msrb@suse.com>
-Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- Xi/sendexev.c | 12 +++++++-----
- 1 file changed, 7 insertions(+), 5 deletions(-)
-
-diff --git a/Xi/sendexev.c b/Xi/sendexev.c
-index 1cf118a..5e63bfc 100644
---- Xi/sendexev.c
-+++ Xi/sendexev.c
-@@ -117,7 +117,7 @@ SProcXSendExtensionEvent(ClientPtr client)
- int
- ProcXSendExtensionEvent(ClientPtr client)
- {
-- int ret;
-+ int ret, i;
- DeviceIntPtr dev;
- xEvent *first;
- XEventClass *list;
-@@ -141,10 +141,12 @@ ProcXSendExtensionEvent(ClientPtr client)
- /* The client's event type must be one defined by an extension. */
-
- first = ((xEvent *) &stuff[1]);
-- if (!((EXTENSION_EVENT_BASE <= first->u.u.type) &&
-- (first->u.u.type < lastEvent))) {
-- client->errorValue = first->u.u.type;
-- return BadValue;
-+ for (i = 0; i < stuff->num_events; i++) {
-+ if (!((EXTENSION_EVENT_BASE <= first[i].u.u.type) &&
-+ (first[i].u.u.type < lastEvent))) {
-+ client->errorValue = first[i].u.u.type;
-+ return BadValue;
-+ }
- }
-
- list = (XEventClass *) (first + stuff->num_events);
---
-cgit v1.1
-
-From ba336b24052122b136486961c82deac76bbde455 Mon Sep 17 00:00:00 2001
-From: Michal Srb <msrb@suse.com>
-Date: Wed, 24 May 2017 15:54:42 +0300
-Subject: Xi: Do not try to swap GenericEvent.
-
-The SProcXSendExtensionEvent must not attempt to swap GenericEvent because
-it is assuming that the event has fixed size and gives the swapping function
-xEvent-sized buffer.
-
-A GenericEvent would be later rejected by ProcXSendExtensionEvent anyway.
-
-Signed-off-by: Michal Srb <msrb@suse.com>
-Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- Xi/sendexev.c | 10 +++++++++-
- 1 file changed, 9 insertions(+), 1 deletion(-)
-
-diff --git a/Xi/sendexev.c b/Xi/sendexev.c
-index 5e63bfc..5c2e0fc 100644
---- Xi/sendexev.c
-+++ Xi/sendexev.c
-@@ -95,9 +95,17 @@ SProcXSendExtensionEvent(ClientPtr client)
-
- eventP = (xEvent *) &stuff[1];
- for (i = 0; i < stuff->num_events; i++, eventP++) {
-+ if (eventP->u.u.type == GenericEvent) {
-+ client->errorValue = eventP->u.u.type;
-+ return BadValue;
-+ }
-+
- proc = EventSwapVector[eventP->u.u.type & 0177];
-- if (proc == NotImplemented) /* no swapping proc; invalid event type? */
-+ /* no swapping proc; invalid event type? */
-+ if (proc == NotImplemented) {
-+ client->errorValue = eventP->u.u.type;
- return BadValue;
-+ }
- (*proc) (eventP, &eventT);
- *eventP = eventT;
- }
---
-cgit v1.1
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-10972 b/x11-servers/xorg-server/files/patch-CVE-2017-10972
deleted file mode 100644
index 444d0d2c5d2a..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-10972
+++ /dev/null
@@ -1,38 +0,0 @@
-From 05442de962d3dc624f79fc1a00eca3ffc5489ced Mon Sep 17 00:00:00 2001
-From: Michal Srb <msrb@suse.com>
-Date: Wed, 24 May 2017 15:54:39 +0300
-Subject: Xi: Zero target buffer in SProcXSendExtensionEvent.
-
-Make sure that the xEvent eventT is initialized with zeros, the same way as
-in SProcSendEvent.
-
-Some event swapping functions do not overwrite all 32 bytes of xEvent
-structure, for example XSecurityAuthorizationRevoked. Two cooperating
-clients, one swapped and the other not, can send
-XSecurityAuthorizationRevoked event to each other to retrieve old stack data
-from X server. This can be potentialy misused to go around ASLR or
-stack-protector.
-
-Signed-off-by: Michal Srb <msrb@suse.com>
-Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
----
- Xi/sendexev.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Xi/sendexev.c b/Xi/sendexev.c
-index 11d8202..1cf118a 100644
---- Xi/sendexev.c
-+++ Xi/sendexev.c
-@@ -78,7 +78,7 @@ SProcXSendExtensionEvent(ClientPtr client)
- {
- CARD32 *p;
- int i;
-- xEvent eventT;
-+ xEvent eventT = { .u.u.type = 0 };
- xEvent *eventP;
- EventSwapPtr proc;
-
---
-cgit v1.1
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-12176 b/x11-servers/xorg-server/files/patch-CVE-2017-12176
deleted file mode 100644
index c5c6fb85c136..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-12176
+++ /dev/null
@@ -1,31 +0,0 @@
-From 95f605b42d8bbb6bea2834a1abfc205981c5b803 Mon Sep 17 00:00:00 2001
-From: Nathan Kidd <nkidd@opentext.com>
-Date: Fri, 9 Jan 2015 10:15:46 -0500
-Subject: Unvalidated extra length in ProcEstablishConnection (CVE-2017-12176)
-
-Reviewed-by: Julien Cristau <jcristau@debian.org>
-Signed-off-by: Nathan Kidd <nkidd@opentext.com>
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-(cherry picked from commit b747da5e25be944337a9cd1415506fc06b70aa81)
-
-diff --git a/dix/dispatch.c b/dix/dispatch.c
-index 0da431b..0fdfe11 100644
---- dix/dispatch.c
-+++ dix/dispatch.c
-@@ -3703,7 +3703,12 @@ ProcEstablishConnection(ClientPtr client)
- prefix = (xConnClientPrefix *) ((char *) stuff + sz_xReq);
- auth_proto = (char *) prefix + sz_xConnClientPrefix;
- auth_string = auth_proto + pad_to_int32(prefix->nbytesAuthProto);
-- if ((prefix->majorVersion != X_PROTOCOL) ||
-+
-+ if ((client->req_len << 2) != sz_xReq + sz_xConnClientPrefix +
-+ pad_to_int32(prefix->nbytesAuthProto) +
-+ pad_to_int32(prefix->nbytesAuthString))
-+ reason = "Bad length";
-+ else if ((prefix->majorVersion != X_PROTOCOL) ||
- (prefix->minorVersion != X_PROTOCOL_REVISION))
- reason = "Protocol version mismatch";
- else
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-12177 b/x11-servers/xorg-server/files/patch-CVE-2017-12177
deleted file mode 100644
index 65033f566dc9..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-12177
+++ /dev/null
@@ -1,41 +0,0 @@
-From cc41e5b581d287c56f8d7113a97a4882dcfdd696 Mon Sep 17 00:00:00 2001
-From: Nathan Kidd <nkidd@opentext.com>
-Date: Fri, 9 Jan 2015 10:09:14 -0500
-Subject: dbe: Unvalidated variable-length request in ProcDbeGetVisualInfo
- (CVE-2017-12177)
-
-v2: Protect against integer overflow (Alan Coopersmith)
-
-Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Reviewed-by: Julien Cristau <jcristau@debian.org>
-Signed-off-by: Nathan Kidd <nkidd@opentext.com>
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-(cherry picked from commit 4ca68b878e851e2136c234f40a25008297d8d831)
-
-diff --git a/dbe/dbe.c b/dbe/dbe.c
-index 23f7e16..f31766f 100644
---- dbe/dbe.c
-+++ dbe/dbe.c
-@@ -574,6 +574,9 @@ ProcDbeGetVisualInfo(ClientPtr client)
- XdbeScreenVisualInfo *pScrVisInfo;
-
- REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
-+ if (stuff->n > UINT32_MAX / sizeof(CARD32))
-+ return BadLength;
-+ REQUEST_FIXED_SIZE(xDbeGetVisualInfoReq, stuff->n * sizeof(CARD32));
-
- if (stuff->n > UINT32_MAX / sizeof(DrawablePtr))
- return BadAlloc;
-@@ -924,7 +927,7 @@ SProcDbeSwapBuffers(ClientPtr client)
-
- swapl(&stuff->n);
- if (stuff->n > UINT32_MAX / sizeof(DbeSwapInfoRec))
-- return BadAlloc;
-+ return BadLength;
- REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, stuff->n * sizeof(xDbeSwapInfo));
-
- if (stuff->n != 0) {
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-12178 b/x11-servers/xorg-server/files/patch-CVE-2017-12178
deleted file mode 100644
index d2b3474f0500..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-12178
+++ /dev/null
@@ -1,29 +0,0 @@
-From 6c15122163a2d2615db7e998e8d436815a08dec6 Mon Sep 17 00:00:00 2001
-From: Nathan Kidd <nkidd@opentext.com>
-Date: Wed, 24 Dec 2014 16:22:18 -0500
-Subject: Xi: fix wrong extra length check in ProcXIChangeHierarchy
- (CVE-2017-12178)
-
-Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Reviewed-by: Julien Cristau <jcristau@debian.org>
-Signed-off-by: Nathan Kidd <nkidd@opentext.com>
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-(cherry picked from commit 859b08d523307eebde7724fd1a0789c44813e821)
-
-diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
-index f2b7785..7286eff 100644
---- Xi/xichangehierarchy.c
-+++ Xi/xichangehierarchy.c
-@@ -423,7 +423,7 @@ ProcXIChangeHierarchy(ClientPtr client)
- if (!stuff->num_changes)
- return rc;
-
-- len = ((size_t)stuff->length << 2) - sizeof(xXIAnyHierarchyChangeInfo);
-+ len = ((size_t)stuff->length << 2) - sizeof(xXIChangeHierarchyReq);
-
- any = (xXIAnyHierarchyChangeInfo *) &stuff[1];
- while (stuff->num_changes--) {
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-12179 b/x11-servers/xorg-server/files/patch-CVE-2017-12179
deleted file mode 100644
index 7787fc117d69..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-12179
+++ /dev/null
@@ -1,52 +0,0 @@
-From c77cd08efcf386bcc5d8dfbd0427134b2b2d0888 Mon Sep 17 00:00:00 2001
-From: Nathan Kidd <nkidd@opentext.com>
-Date: Fri, 9 Jan 2015 10:04:41 -0500
-Subject: Xi: integer overflow and unvalidated length in
- (S)ProcXIBarrierReleasePointer
-
-[jcristau: originally this patch fixed the same issue as commit
- 211e05ac85 "Xi: Test exact size of XIBarrierReleasePointer", with the
- addition of these checks]
-
-This addresses CVE-2017-12179
-
-Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Reviewed-by: Julien Cristau <jcristau@debian.org>
-Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Signed-off-by: Nathan Kidd <nkidd@opentext.com>
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-(cherry picked from commit d088e3c1286b548a58e62afdc70bb40981cdb9e8)
-
-
---- Xi/xibarriers.c.orig 2016-07-15 18:17:45.000000000 +0200
-+++ Xi/xibarriers.c 2017-10-13 18:26:09.226006000 +0200
-@@ -830,10 +830,15 @@
- REQUEST(xXIBarrierReleasePointerReq);
- int i;
-
-- info = (xXIBarrierReleasePointerInfo*) &stuff[1];
--
- swaps(&stuff->length);
-+ REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq);
-+
- swapl(&stuff->num_barriers);
-+ if (stuff->num_barriers > UINT32_MAX / sizeof(xXIBarrierReleasePointerInfo))
-+ return BadLength;
-+ REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
-+
-+ info = (xXIBarrierReleasePointerInfo*) &stuff[1];
- for (i = 0; i < stuff->num_barriers; i++, info++) {
- swaps(&info->deviceid);
- swapl(&info->barrier);
-@@ -854,6 +859,10 @@
-
- REQUEST(xXIBarrierReleasePointerReq);
- REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq);
-+ if (stuff->num_barriers > UINT32_MAX / sizeof(xXIBarrierReleasePointerInfo))
-+ return BadLength;
-+ REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
-+
-
- info = (xXIBarrierReleasePointerInfo*) &stuff[1];
- for (i = 0; i < stuff->num_barriers; i++, info++) {
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-12183 b/x11-servers/xorg-server/files/patch-CVE-2017-12183
deleted file mode 100644
index 5ccc3760e022..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-12183
+++ /dev/null
@@ -1,95 +0,0 @@
-From 61502107a30d64f991784648c3228ebc6694a032 Mon Sep 17 00:00:00 2001
-From: Nathan Kidd <nkidd@opentext.com>
-Date: Fri, 9 Jan 2015 11:43:05 -0500
-Subject: xfixes: unvalidated lengths (CVE-2017-12183)
-
-v2: Use before swap (Jeremy Huddleston Sequoia)
-
-v3: Fix wrong XFixesCopyRegion checks (Alan Coopersmith)
-
-Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Reviewed-by: Julien Cristau <jcristau@debian.org>
-Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Signed-off-by: Nathan Kidd <nkidd@opentext.com>
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-(cherry picked from commit 55caa8b08c84af2b50fbc936cf334a5a93dd7db5)
-
-diff --git a/xfixes/cursor.c b/xfixes/cursor.c
-index f009a78..6e84d71 100644
---- xfixes/cursor.c
-+++ xfixes/cursor.c
-@@ -281,6 +281,7 @@ int
- SProcXFixesSelectCursorInput(ClientPtr client)
- {
- REQUEST(xXFixesSelectCursorInputReq);
-+ REQUEST_SIZE_MATCH(xXFixesSelectCursorInputReq);
-
- swaps(&stuff->length);
- swapl(&stuff->window);
-@@ -414,7 +415,7 @@ ProcXFixesSetCursorName(ClientPtr client)
- REQUEST(xXFixesSetCursorNameReq);
- Atom atom;
-
-- REQUEST_AT_LEAST_SIZE(xXFixesSetCursorNameReq);
-+ REQUEST_FIXED_SIZE(xXFixesSetCursorNameReq, stuff->nbytes);
- VERIFY_CURSOR(pCursor, stuff->cursor, client, DixSetAttrAccess);
- tchar = (char *) &stuff[1];
- atom = MakeAtom(tchar, stuff->nbytes, TRUE);
-@@ -1007,6 +1008,8 @@ SProcXFixesCreatePointerBarrier(ClientPtr client)
- int i;
- CARD16 *in_devices = (CARD16 *) &stuff[1];
-
-+ REQUEST_AT_LEAST_SIZE(xXFixesCreatePointerBarrierReq);
-+
- swaps(&stuff->length);
- swaps(&stuff->num_devices);
- REQUEST_FIXED_SIZE(xXFixesCreatePointerBarrierReq, pad_to_int32(stuff->num_devices));
-diff --git a/xfixes/region.c b/xfixes/region.c
-index dd74d7f..f300d2b 100644
---- xfixes/region.c
-+++ xfixes/region.c
-@@ -359,6 +359,7 @@ ProcXFixesCopyRegion(ClientPtr client)
- RegionPtr pSource, pDestination;
-
- REQUEST(xXFixesCopyRegionReq);
-+ REQUEST_SIZE_MATCH(xXFixesCopyRegionReq);
-
- VERIFY_REGION(pSource, stuff->source, client, DixReadAccess);
- VERIFY_REGION(pDestination, stuff->destination, client, DixWriteAccess);
-@@ -375,7 +376,7 @@ SProcXFixesCopyRegion(ClientPtr client)
- REQUEST(xXFixesCopyRegionReq);
-
- swaps(&stuff->length);
-- REQUEST_AT_LEAST_SIZE(xXFixesCopyRegionReq);
-+ REQUEST_SIZE_MATCH(xXFixesCopyRegionReq);
- swapl(&stuff->source);
- swapl(&stuff->destination);
- return (*ProcXFixesVector[stuff->xfixesReqType]) (client);
-diff --git a/xfixes/saveset.c b/xfixes/saveset.c
-index eb3f658..aa365cf 100644
---- xfixes/saveset.c
-+++ xfixes/saveset.c
-@@ -62,6 +62,7 @@ int
- SProcXFixesChangeSaveSet(ClientPtr client)
- {
- REQUEST(xXFixesChangeSaveSetReq);
-+ REQUEST_SIZE_MATCH(xXFixesChangeSaveSetReq);
-
- swaps(&stuff->length);
- swapl(&stuff->window);
-diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
-index 8d1bd4c..8b45c53 100644
---- xfixes/xfixes.c
-+++ xfixes/xfixes.c
-@@ -160,6 +160,7 @@ static int
- SProcXFixesQueryVersion(ClientPtr client)
- {
- REQUEST(xXFixesQueryVersionReq);
-+ REQUEST_SIZE_MATCH(xXFixesQueryVersionReq);
-
- swaps(&stuff->length);
- swapl(&stuff->majorVersion);
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-1218x b/x11-servers/xorg-server/files/patch-CVE-2017-1218x
deleted file mode 100644
index 264f6298ab18..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-1218x
+++ /dev/null
@@ -1,601 +0,0 @@
-From d264da92f7f8129b8aad4f0114a6467fc38fc896 Mon Sep 17 00:00:00 2001
-From: Nathan Kidd <nkidd@opentext.com>
-Date: Sun, 21 Dec 2014 01:10:03 -0500
-Subject: hw/xfree86: unvalidated lengths
-
-This addresses:
-CVE-2017-12180 in XFree86-VidModeExtension
-CVE-2017-12181 in XFree86-DGA
-CVE-2017-12182 in XFree86-DRI
-
-Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Reviewed-by: Julien Cristau <jcristau@debian.org>
-Signed-off-by: Nathan Kidd <nkidd@opentext.com>
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-(cherry picked from commit 1b1d4c04695dced2463404174b50b3581dbd857b)
-
-diff --git a/Xext/vidmode.c b/Xext/vidmode.c
-index ea3ad13..76055c8 100644
---- Xext/vidmode.c
-+++ Xext/vidmode.c
-@@ -454,6 +454,20 @@ ProcVidModeAddModeLine(ClientPtr client)
- DEBUG_P("XF86VidModeAddModeline");
-
- ver = ClientMajorVersion(client);
-+
-+ if (ver < 2) {
-+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq));
-+ }
-+ else {
-+ REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq));
-+ }
-+
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
-@@ -501,18 +515,6 @@ ProcVidModeAddModeLine(ClientPtr client)
- stuff->after_vsyncend, stuff->after_vtotal,
- (unsigned long) stuff->after_flags);
-
-- if (ver < 2) {
-- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeAddModeLineReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86OldVidModeAddModeLineReq));
-- }
-- else {
-- REQUEST_AT_LEAST_SIZE(xXF86VidModeAddModeLineReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86VidModeAddModeLineReq));
-- }
- if (len != stuff->privsize)
- return BadLength;
-
-@@ -622,6 +624,20 @@ ProcVidModeDeleteModeLine(ClientPtr client)
- DEBUG_P("XF86VidModeDeleteModeline");
-
- ver = ClientMajorVersion(client);
-+
-+ if (ver < 2) {
-+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq));
-+ }
-+ else {
-+ REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq));
-+ }
-+
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
-@@ -649,18 +665,6 @@ ProcVidModeDeleteModeLine(ClientPtr client)
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
- (unsigned long) stuff->flags);
-
-- if (ver < 2) {
-- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeDeleteModeLineReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86OldVidModeDeleteModeLineReq));
-- }
-- else {
-- REQUEST_AT_LEAST_SIZE(xXF86VidModeDeleteModeLineReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86VidModeDeleteModeLineReq));
-- }
- if (len != stuff->privsize) {
- DebugF("req_len = %ld, sizeof(Req) = %d, privsize = %ld, "
- "len = %d, length = %d\n",
-@@ -744,6 +748,20 @@ ProcVidModeModModeLine(ClientPtr client)
- DEBUG_P("XF86VidModeModModeline");
-
- ver = ClientMajorVersion(client);
-+
-+ if (ver < 2) {
-+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq));
-+ }
-+ else {
-+ REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86VidModeModModeLineReq));
-+ }
-+
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
-@@ -768,18 +786,6 @@ ProcVidModeModModeLine(ClientPtr client)
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend,
- stuff->vtotal, (unsigned long) stuff->flags);
-
-- if (ver < 2) {
-- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeModModeLineReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86OldVidModeModModeLineReq));
-- }
-- else {
-- REQUEST_AT_LEAST_SIZE(xXF86VidModeModModeLineReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86VidModeModModeLineReq));
-- }
- if (len != stuff->privsize)
- return BadLength;
-
-@@ -877,6 +883,19 @@ ProcVidModeValidateModeLine(ClientPtr client)
- DEBUG_P("XF86VidModeValidateModeline");
-
- ver = ClientMajorVersion(client);
-+
-+ if (ver < 2) {
-+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
-+ len = client->req_len -
-+ bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq));
-+ }
-+ else {
-+ REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq));
-+ }
-+
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
-@@ -905,17 +924,6 @@ ProcVidModeValidateModeLine(ClientPtr client)
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
- (unsigned long) stuff->flags);
-
-- if (ver < 2) {
-- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeValidateModeLineReq);
-- len = client->req_len -
-- bytes_to_int32(sizeof(xXF86OldVidModeValidateModeLineReq));
-- }
-- else {
-- REQUEST_AT_LEAST_SIZE(xXF86VidModeValidateModeLineReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86VidModeValidateModeLineReq));
-- }
- if (len != stuff->privsize)
- return BadLength;
-
-@@ -1027,6 +1035,20 @@ ProcVidModeSwitchToMode(ClientPtr client)
- DEBUG_P("XF86VidModeSwitchToMode");
-
- ver = ClientMajorVersion(client);
-+
-+ if (ver < 2) {
-+ REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq));
-+ }
-+ else {
-+ REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
-+ len =
-+ client->req_len -
-+ bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq));
-+ }
-+
- if (ver < 2) {
- /* convert from old format */
- stuff = &newstuff;
-@@ -1055,18 +1077,6 @@ ProcVidModeSwitchToMode(ClientPtr client)
- stuff->vdisplay, stuff->vsyncstart, stuff->vsyncend, stuff->vtotal,
- (unsigned long) stuff->flags);
-
-- if (ver < 2) {
-- REQUEST_AT_LEAST_SIZE(xXF86OldVidModeSwitchToModeReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86OldVidModeSwitchToModeReq));
-- }
-- else {
-- REQUEST_AT_LEAST_SIZE(xXF86VidModeSwitchToModeReq);
-- len =
-- client->req_len -
-- bytes_to_int32(sizeof(xXF86VidModeSwitchToModeReq));
-- }
- if (len != stuff->privsize)
- return BadLength;
-
-@@ -1457,6 +1467,7 @@ ProcVidModeSetGammaRamp(ClientPtr client)
- VidModePtr pVidMode;
-
- REQUEST(xXF86VidModeSetGammaRampReq);
-+ REQUEST_AT_LEAST_SIZE(xXF86VidModeSetGammaRampReq);
-
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
-index c689dcb..039f38d 100644
---- hw/xfree86/common/xf86DGA.c
-+++ hw/xfree86/common/xf86DGA.c
-@@ -1272,13 +1272,14 @@ ProcXDGAOpenFramebuffer(ClientPtr client)
- char *deviceName;
- int nameSize;
-
-+ REQUEST_SIZE_MATCH(xXDGAOpenFramebufferReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!DGAAvailable(stuff->screen))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
-
-- REQUEST_SIZE_MATCH(xXDGAOpenFramebufferReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-@@ -1305,14 +1306,14 @@ ProcXDGACloseFramebuffer(ClientPtr client)
- {
- REQUEST(xXDGACloseFramebufferReq);
-
-+ REQUEST_SIZE_MATCH(xXDGACloseFramebufferReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (!DGAAvailable(stuff->screen))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
-
-- REQUEST_SIZE_MATCH(xXDGACloseFramebufferReq);
--
- DGACloseFramebuffer(stuff->screen);
-
- return Success;
-@@ -1328,10 +1329,11 @@ ProcXDGAQueryModes(ClientPtr client)
- xXDGAModeInfo info;
- XDGAModePtr mode;
-
-+ REQUEST_SIZE_MATCH(xXDGAQueryModesReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
-- REQUEST_SIZE_MATCH(xXDGAQueryModesReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.number = 0;
-@@ -1443,11 +1445,12 @@ ProcXDGASetMode(ClientPtr client)
- ClientPtr owner;
- int size;
-
-+ REQUEST_SIZE_MATCH(xXDGASetModeReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
- owner = DGA_GETCLIENT(stuff->screen);
-
-- REQUEST_SIZE_MATCH(xXDGASetModeReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.offset = 0;
-@@ -1533,14 +1536,14 @@ ProcXDGASetViewport(ClientPtr client)
- {
- REQUEST(xXDGASetViewportReq);
-
-+ REQUEST_SIZE_MATCH(xXDGASetViewportReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGASetViewportReq);
--
- DGASetViewport(stuff->screen, stuff->x, stuff->y, stuff->flags);
-
- return Success;
-@@ -1554,14 +1557,14 @@ ProcXDGAInstallColormap(ClientPtr client)
-
- REQUEST(xXDGAInstallColormapReq);
-
-+ REQUEST_SIZE_MATCH(xXDGAInstallColormapReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGAInstallColormapReq);
--
- rc = dixLookupResourceByType((void **) &cmap, stuff->cmap, RT_COLORMAP,
- client, DixInstallAccess);
- if (rc != Success)
-@@ -1575,14 +1578,14 @@ ProcXDGASelectInput(ClientPtr client)
- {
- REQUEST(xXDGASelectInputReq);
-
-+ REQUEST_SIZE_MATCH(xXDGASelectInputReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGASelectInputReq);
--
- if (DGA_GETCLIENT(stuff->screen) == client)
- DGASelectInput(stuff->screen, client, stuff->mask);
-
-@@ -1594,14 +1597,14 @@ ProcXDGAFillRectangle(ClientPtr client)
- {
- REQUEST(xXDGAFillRectangleReq);
-
-+ REQUEST_SIZE_MATCH(xXDGAFillRectangleReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGAFillRectangleReq);
--
- if (Success != DGAFillRect(stuff->screen, stuff->x, stuff->y,
- stuff->width, stuff->height, stuff->color))
- return BadMatch;
-@@ -1614,14 +1617,14 @@ ProcXDGACopyArea(ClientPtr client)
- {
- REQUEST(xXDGACopyAreaReq);
-
-+ REQUEST_SIZE_MATCH(xXDGACopyAreaReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGACopyAreaReq);
--
- if (Success != DGABlitRect(stuff->screen, stuff->srcx, stuff->srcy,
- stuff->width, stuff->height, stuff->dstx,
- stuff->dsty))
-@@ -1635,14 +1638,14 @@ ProcXDGACopyTransparentArea(ClientPtr client)
- {
- REQUEST(xXDGACopyTransparentAreaReq);
-
-+ REQUEST_SIZE_MATCH(xXDGACopyTransparentAreaReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGACopyTransparentAreaReq);
--
- if (Success != DGABlitTransRect(stuff->screen, stuff->srcx, stuff->srcy,
- stuff->width, stuff->height, stuff->dstx,
- stuff->dsty, stuff->key))
-@@ -1657,13 +1660,14 @@ ProcXDGAGetViewportStatus(ClientPtr client)
- REQUEST(xXDGAGetViewportStatusReq);
- xXDGAGetViewportStatusReply rep;
-
-+ REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-@@ -1680,13 +1684,14 @@ ProcXDGASync(ClientPtr client)
- REQUEST(xXDGASyncReq);
- xXDGASyncReply rep;
-
-+ REQUEST_SIZE_MATCH(xXDGASyncReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGASyncReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-@@ -1725,13 +1730,14 @@ ProcXDGAChangePixmapMode(ClientPtr client)
- xXDGAChangePixmapModeReply rep;
- int x, y;
-
-+ REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-@@ -1755,14 +1761,14 @@ ProcXDGACreateColormap(ClientPtr client)
- REQUEST(xXDGACreateColormapReq);
- int result;
-
-+ REQUEST_SIZE_MATCH(xXDGACreateColormapReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXDGACreateColormapReq);
--
- if (!stuff->mode)
- return BadValue;
-
-@@ -1791,10 +1797,11 @@ ProcXF86DGAGetVideoLL(ClientPtr client)
- int num, offset, flags;
- char *name;
-
-+ REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
-- REQUEST_SIZE_MATCH(xXF86DGAGetVideoLLReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-@@ -1831,9 +1838,10 @@ ProcXF86DGADirectVideo(ClientPtr client)
-
- REQUEST(xXF86DGADirectVideoReq);
-
-+ REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-- REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
-
- if (!DGAAvailable(stuff->screen))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
-@@ -1889,10 +1897,11 @@ ProcXF86DGAGetViewPortSize(ClientPtr client)
- REQUEST(xXF86DGAGetViewPortSizeReq);
- xXF86DGAGetViewPortSizeReply rep;
-
-+ REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
-- REQUEST_SIZE_MATCH(xXF86DGAGetViewPortSizeReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-@@ -1917,14 +1926,14 @@ ProcXF86DGASetViewPort(ClientPtr client)
- {
- REQUEST(xXF86DGASetViewPortReq);
-
-+ REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
--
- if (!DGAAvailable(stuff->screen))
- return DGAErrorBase + XF86DGANoDirectVideoMode;
-
-@@ -1944,10 +1953,11 @@ ProcXF86DGAGetVidPage(ClientPtr client)
- REQUEST(xXF86DGAGetVidPageReq);
- xXF86DGAGetVidPageReply rep;
-
-+ REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
-- REQUEST_SIZE_MATCH(xXF86DGAGetVidPageReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-@@ -1962,11 +1972,11 @@ ProcXF86DGASetVidPage(ClientPtr client)
- {
- REQUEST(xXF86DGASetVidPageReq);
-
-+ REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
-- REQUEST_SIZE_MATCH(xXF86DGASetVidPageReq);
--
- /* silently fail */
-
- return Success;
-@@ -1980,14 +1990,14 @@ ProcXF86DGAInstallColormap(ClientPtr client)
-
- REQUEST(xXF86DGAInstallColormapReq);
-
-+ REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq);
--
- if (!DGAActive(stuff->screen))
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-@@ -2008,10 +2018,11 @@ ProcXF86DGAQueryDirectVideo(ClientPtr client)
- REQUEST(xXF86DGAQueryDirectVideoReq);
- xXF86DGAQueryDirectVideoReply rep;
-
-+ REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
-- REQUEST_SIZE_MATCH(xXF86DGAQueryDirectVideoReq);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-@@ -2030,14 +2041,14 @@ ProcXF86DGAViewPortChanged(ClientPtr client)
- REQUEST(xXF86DGAViewPortChangedReq);
- xXF86DGAViewPortChangedReply rep;
-
-+ REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq);
-+
- if (stuff->screen >= screenInfo.numScreens)
- return BadValue;
-
- if (DGA_GETCLIENT(stuff->screen) != client)
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-- REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq);
--
- if (!DGAActive(stuff->screen))
- return DGAErrorBase + XF86DGADirectNotActivated;
-
-diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c
-index 68f8b7e..65f368e 100644
---- hw/xfree86/dri/xf86dri.c
-+++ hw/xfree86/dri/xf86dri.c
-@@ -570,6 +570,7 @@ static int
- SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client)
- {
- REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
-+ REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
- swaps(&stuff->length);
- swapl(&stuff->screen);
- return ProcXF86DRIQueryDirectRenderingCapable(client);
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-1218y b/x11-servers/xorg-server/files/patch-CVE-2017-1218y
deleted file mode 100644
index fe02768869ca..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-1218y
+++ /dev/null
@@ -1,139 +0,0 @@
-From c206f36a4b6ecf2555ab2291c349ab7d7d0b02f5 Mon Sep 17 00:00:00 2001
-From: Nathan Kidd <nkidd@opentext.com>
-Date: Fri, 9 Jan 2015 09:57:23 -0500
-Subject: Unvalidated lengths
-
-v2: Add overflow check and remove unnecessary check (Julien Cristau)
-
-This addresses:
-CVE-2017-12184 in XINERAMA
-CVE-2017-12185 in MIT-SCREEN-SAVER
-CVE-2017-12186 in X-Resource
-CVE-2017-12187 in RENDER
-
-Reviewed-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-Reviewed-by: Julien Cristau <jcristau@debian.org>
-Signed-off-by: Nathan Kidd <nkidd@opentext.com>
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-(cherry picked from commit cad5a1050b7184d828aef9c1dd151c3ab649d37e)
-
-diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
-index 209df29..844ea49 100644
---- Xext/panoramiX.c
-+++ Xext/panoramiX.c
-@@ -988,10 +988,11 @@ ProcPanoramiXGetScreenSize(ClientPtr client)
- xPanoramiXGetScreenSizeReply rep;
- int rc;
-
-+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
-+
- if (stuff->screen >= PanoramiXNumScreens)
- return BadMatch;
-
-- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-diff --git a/Xext/saver.c b/Xext/saver.c
-index 750b8b9..45ac4d2 100644
---- Xext/saver.c
-+++ Xext/saver.c
-@@ -1185,6 +1185,8 @@ ProcScreenSaverUnsetAttributes(ClientPtr client)
- PanoramiXRes *draw;
- int rc, i;
-
-+ REQUEST_SIZE_MATCH(xScreenSaverUnsetAttributesReq);
-+
- rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
- XRC_DRAWABLE, client, DixWriteAccess);
- if (rc != Success)
-diff --git a/Xext/xres.c b/Xext/xres.c
-index ae779df..bc54133 100644
---- Xext/xres.c
-+++ Xext/xres.c
-@@ -947,6 +947,8 @@ ProcXResQueryResourceBytes (ClientPtr client)
- ConstructResourceBytesCtx ctx;
-
- REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
-+ if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
-+ return BadLength;
- REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
- stuff->numSpecs * sizeof(ctx.specs[0]));
-
-@@ -1052,8 +1054,8 @@ SProcXResQueryResourceBytes (ClientPtr client)
- int c;
- xXResResourceIdSpec *specs = (void*) ((char*) stuff + sizeof(*stuff));
-
-- swapl(&stuff->numSpecs);
- REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
-+ swapl(&stuff->numSpecs);
- REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
- stuff->numSpecs * sizeof(specs[0]));
-
-diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
-index 8a35b7b..4d412b8 100644
---- Xext/xvdisp.c
-+++ Xext/xvdisp.c
-@@ -1493,12 +1493,14 @@ XineramaXvShmPutImage(ClientPtr client)
- {
- REQUEST(xvShmPutImageReq);
- PanoramiXRes *draw, *gc, *port;
-- Bool send_event = stuff->send_event;
-+ Bool send_event;
- Bool isRoot;
- int result, i, x, y;
-
- REQUEST_SIZE_MATCH(xvShmPutImageReq);
-
-+ send_event = stuff->send_event;
-+
- result = dixLookupResourceByClass((void **) &draw, stuff->drawable,
- XRC_DRAWABLE, client, DixWriteAccess);
- if (result != Success)
-diff --git a/hw/dmx/dmxpict.c b/hw/dmx/dmxpict.c
-index 1f1022e..63caec9 100644
---- hw/dmx/dmxpict.c
-+++ hw/dmx/dmxpict.c
-@@ -716,6 +716,8 @@ dmxProcRenderSetPictureFilter(ClientPtr client)
- filter = (char *) (stuff + 1);
- params = (XFixed *) (filter + ((stuff->nbytes + 3) & ~3));
- nparams = ((XFixed *) stuff + client->req_len) - params;
-+ if (nparams < 0)
-+ return BadLength;
-
- XRenderSetPictureFilter(dmxScreen->beDisplay,
- pPictPriv->pict, filter, params, nparams);
-diff --git a/pseudoramiX/pseudoramiX.c b/pseudoramiX/pseudoramiX.c
-index d8b2593..95f6e10 100644
---- pseudoramiX/pseudoramiX.c
-+++ pseudoramiX/pseudoramiX.c
-@@ -297,10 +297,11 @@ ProcPseudoramiXGetScreenSize(ClientPtr client)
-
- TRACE;
-
-+ REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
-+
- if (stuff->screen >= pseudoramiXNumScreens)
- return BadMatch;
-
-- REQUEST_SIZE_MATCH(xPanoramiXGetScreenSizeReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-diff --git a/render/render.c b/render/render.c
-index bfacaa0..3a41e33 100644
---- render/render.c
-+++ render/render.c
-@@ -1757,6 +1757,9 @@ ProcRenderSetPictureFilter(ClientPtr client)
- name = (char *) (stuff + 1);
- params = (xFixed *) (name + pad_to_int32(stuff->nbytes));
- nparams = ((xFixed *) stuff + client->req_len) - params;
-+ if (nparams < 0)
-+ return BadLength;
-+
- result = SetPictureFilter(pPicture, name, stuff->nbytes, params, nparams);
- return result;
- }
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-13721 b/x11-servers/xorg-server/files/patch-CVE-2017-13721
deleted file mode 100644
index 68b3fcb5a5f9..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-13721
+++ /dev/null
@@ -1,26 +0,0 @@
-From b95f25af141d33a65f6f821ea9c003f66a01e1f1 Mon Sep 17 00:00:00 2001
-From: Michal Srb <msrb@suse.com>
-Date: Fri, 28 Jul 2017 16:27:10 +0200
-Subject: Xext/shm: Validate shmseg resource id (CVE-2017-13721)
-
-Otherwise it can belong to a non-existing client and abort X server with
-FatalError "client not in use", or overwrite existing segment of another
-existing client.
-
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-
-diff --git a/Xext/shm.c b/Xext/shm.c
-index 91ea90b..2f9a788 100644
---- Xext/shm.c
-+++ Xext/shm.c
-@@ -1238,6 +1238,7 @@ ProcShmCreateSegment(ClientPtr client)
- };
-
- REQUEST_SIZE_MATCH(xShmCreateSegmentReq);
-+ LEGAL_NEW_RESOURCE(stuff->shmseg, client);
- if ((stuff->readOnly != xTrue) && (stuff->readOnly != xFalse)) {
- client->errorValue = stuff->readOnly;
- return BadValue;
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-CVE-2017-13723 b/x11-servers/xorg-server/files/patch-CVE-2017-13723
deleted file mode 100644
index c8952f28c6ae..000000000000
--- a/x11-servers/xorg-server/files/patch-CVE-2017-13723
+++ /dev/null
@@ -1,115 +0,0 @@
-From 94f11ca5cf011ef123bd222cabeaef6f424d76ac Mon Sep 17 00:00:00 2001
-From: Keith Packard <keithp@keithp.com>
-Date: Thu, 27 Jul 2017 10:08:32 -0700
-Subject: xkb: Handle xkb formated string output safely (CVE-2017-13723)
-
-Generating strings for XKB data used a single shared static buffer,
-which offered several opportunities for errors. Use a ring of
-resizable buffers instead, to avoid problems when strings end up
-longer than anticipated.
-
-Reviewed-by: Michal Srb <msrb@suse.com>
-Signed-off-by: Keith Packard <keithp@keithp.com>
-Signed-off-by: Julien Cristau <jcristau@debian.org>
-
-diff --git a/xkb/xkbtext.c b/xkb/xkbtext.c
-index ead2b1a..d2a2567 100644
---- xkb/xkbtext.c
-+++ xkb/xkbtext.c
-@@ -47,23 +47,27 @@
-
- /***====================================================================***/
-
--#define BUFFER_SIZE 512
--
--static char textBuffer[BUFFER_SIZE];
--static int tbNext = 0;
-+#define NUM_BUFFER 8
-+static struct textBuffer {
-+ int size;
-+ char *buffer;
-+} textBuffer[NUM_BUFFER];
-+static int textBufferIndex;
-
- static char *
- tbGetBuffer(unsigned size)
- {
-- char *rtrn;
-+ struct textBuffer *tb;
-
-- if (size >= BUFFER_SIZE)
-- return NULL;
-- if ((BUFFER_SIZE - tbNext) <= size)
-- tbNext = 0;
-- rtrn = &textBuffer[tbNext];
-- tbNext += size;
-- return rtrn;
-+ tb = &textBuffer[textBufferIndex];
-+ textBufferIndex = (textBufferIndex + 1) % NUM_BUFFER;
-+
-+ if (size > tb->size) {
-+ free(tb->buffer);
-+ tb->buffer = xnfalloc(size);
-+ tb->size = size;
-+ }
-+ return tb->buffer;
- }
-
- /***====================================================================***/
-@@ -79,8 +83,6 @@ XkbAtomText(Atom atm, unsigned format)
- int len;
-
- len = strlen(atmstr) + 1;
-- if (len > BUFFER_SIZE)
-- len = BUFFER_SIZE - 2;
- rtrn = tbGetBuffer(len);
- strlcpy(rtrn, atmstr, len);
- }
-@@ -128,8 +130,6 @@ XkbVModIndexText(XkbDescPtr xkb, unsigned ndx, unsigned format)
- len = strlen(tmp) + 1;
- if (format == XkbCFile)
- len += 4;
-- if (len >= BUFFER_SIZE)
-- len = BUFFER_SIZE - 1;
- rtrn = tbGetBuffer(len);
- if (format == XkbCFile) {
- strcpy(rtrn, "vmod_");
-@@ -140,6 +140,8 @@ XkbVModIndexText(XkbDescPtr xkb, unsigned ndx, unsigned format)
- return rtrn;
- }
-
-+#define VMOD_BUFFER_SIZE 512
-+
- char *
- XkbVModMaskText(XkbDescPtr xkb,
- unsigned modMask, unsigned mask, unsigned format)
-@@ -147,7 +149,7 @@ XkbVModMaskText(XkbDescPtr xkb,
- register int i, bit;
- int len;
- char *mm, *rtrn;
-- char *str, buf[BUFFER_SIZE];
-+ char *str, buf[VMOD_BUFFER_SIZE];
-
- if ((modMask == 0) && (mask == 0)) {
- rtrn = tbGetBuffer(5);
-@@ -173,7 +175,7 @@ XkbVModMaskText(XkbDescPtr xkb,
- len = strlen(tmp) + 1 + (str == buf ? 0 : 1);
- if (format == XkbCFile)
- len += 4;
-- if ((str - (buf + len)) <= BUFFER_SIZE) {
-+ if ((str - (buf + len)) <= VMOD_BUFFER_SIZE) {
- if (str != buf) {
- if (format == XkbCFile)
- *str++ = '|';
-@@ -199,8 +201,6 @@ XkbVModMaskText(XkbDescPtr xkb,
- len = 0;
- if (str)
- len += strlen(str) + (mm == NULL ? 0 : 1);
-- if (len >= BUFFER_SIZE)
-- len = BUFFER_SIZE - 1;
- rtrn = tbGetBuffer(len + 1);
- rtrn[0] = '\0';
-
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-misc-Makefile.in b/x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-misc-Makefile.in
index 8a05ae6b33cb..3815a93ea08e 100644
--- a/x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-misc-Makefile.in
+++ b/x11-servers/xorg-server/files/patch-Xserver-hw-xfree86-os-support-misc-Makefile.in
@@ -1,6 +1,6 @@
--- 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
-@@ -530,7 +530,8 @@
+@@ -543,7 +543,8 @@
#AM_LDFLAGS = -r
AM_CPPFLAGS = $(XORG_INCS)
diff --git a/x11-servers/xorg-server/files/patch-config_Makefile.in b/x11-servers/xorg-server/files/patch-config_Makefile.in
new file mode 100644
index 000000000000..400a969c470d
--- /dev/null
+++ b/x11-servers/xorg-server/files/patch-config_Makefile.in
@@ -0,0 +1,100 @@
+* 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
diff --git a/x11-servers/xorg-server/files/patch-config_config-backends.h b/x11-servers/xorg-server/files/patch-config_config-backends.h
index ff0f03899399..7f264de90af1 100644
--- a/x11-servers/xorg-server/files/patch-config_config-backends.h
+++ b/x11-servers/xorg-server/files/patch-config_config-backends.h
@@ -1,11 +1,12 @@
---- config/config-backends.h.orig 2016-07-15 16:17:45 UTC
+* Define required functions for devd config backend
+*
+--- config/config-backends.h.orig 2017-03-15 18:05:25 UTC
+++ config/config-backends.h
-@@ -44,3 +44,8 @@ void config_hal_fini(void);
+@@ -43,4 +43,7 @@ void config_hal_fini(void);
+ #elif defined(CONFIG_WSCONS)
int config_wscons_init(void);
void config_wscons_fini(void);
- #endif
-+
-+#ifdef CONFIG_DEVD
++#elif defined(CONFIG_DEVD)
+int config_devd_init(void);
+void config_devd_fini(void);
-+#endif
+ #endif
diff --git a/x11-servers/xorg-server/files/patch-config_config.c b/x11-servers/xorg-server/files/patch-config_config.c
index e9dd5c667168..df226c205efc 100644
--- a/x11-servers/xorg-server/files/patch-config_config.c
+++ b/x11-servers/xorg-server/files/patch-config_config.c
@@ -1,4 +1,6 @@
---- config/config.c.orig 2016-07-19 17:07:29 UTC
+* 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)
diff --git a/x11-servers/xorg-server/files/patch-config_devd.c b/x11-servers/xorg-server/files/patch-config_devd.c
index fba07a77373f..495af11e777c 100644
--- a/x11-servers/xorg-server/files/patch-config_devd.c
+++ b/x11-servers/xorg-server/files/patch-config_devd.c
@@ -1,11 +1,15 @@
---- config/devd.c.orig 2017-01-19 15:20:42 UTC
+--- config/devd.c.orig 2017-03-16 05:24:43 UTC
+++ config/devd.c
-@@ -0,0 +1,532 @@
+@@ -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"),
@@ -39,14 +43,24 @@
+#include <sys/stat.h>
+#include <sys/sysctl.h>
+#include <sys/un.h>
++#include <sys/mouse.h>
++#include <sys/consio.h>
++#include <sys/ioctl.h>
++#include <dev/evdev/input.h>
++#include <dev/usb/usb_ioctl.h>
++#include <dev/usb/usbhid.h>
+
+#include <ctype.h>
++#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <unistd.h>
++#include <string.h>
++#include <paths.h>
++#include <usbhid.h>
+
+#include "input.h"
+#include "inputstr.h"
@@ -54,467 +68,779 @@
+#include "config-backends.h"
+#include "os.h"
+
-+#define DEVD_SOCK_PATH "/var/run/devd.pipe"
++#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: <linux/joystick.h> */
++#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 RECONNECT_DELAY 5 * 1000
++#define is_meuqual_cstr(__cstr, __v, __vsz) \
++ is_meuqual(__cstr, (sizeof(__cstr) - 1), __v, __vsz)
+
-+static int sock_devd;
-+static bool is_console_kbd = false;
-+static bool is_kbdmux = false;
++#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;
+
-+struct hw_type {
-+ const char *driver;
-+ int flag;
-+ const char *xdriver;
++/* 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 },
+};
+
-+static struct hw_type hw_types[] = {
-+ { "ukbd", ATTR_KEYBOARD, "kbd" },
-+ { "atkbd", ATTR_KEYBOARD, "kbd" },
-+ { "kbdmux", ATTR_KEYBOARD, "kbd" },
-+ { "sysmouse", ATTR_POINTER, "mouse" },
-+ { "ums", ATTR_POINTER, "mouse" },
-+ { "psm", ATTR_POINTER, "mouse" },
-+ { "vboxguest", ATTR_POINTER, "vboxmouse" },
-+ { "joy", ATTR_JOYSTICK, NULL },
-+ { "atp", ATTR_TOUCHPAD, NULL },
-+ { "uep", ATTR_TOUCHSCREEN, NULL },
-+ { NULL, -1, NULL },
++/* Input devices paths. */
++static hw_type_t hw_type_path[] = {
++ { "input/", 0, 6, 0, NULL },
++ { NULL, 0, 0, 0, NULL },
+};
+
-+static bool
-+sysctl_exists(const struct hw_type *device, int unit,
-+ char *devname, size_t devname_len)
++static size_t
++bits_calc(const unsigned long *bits, size_t off_start, size_t off_stop)
+{
-+ char sysctlname[PATH_MAX];
-+ size_t len;
-+ int ret;
++ size_t count = 0;
+
-+ if (device == NULL || device->driver == NULL)
-+ return false;
++ for (size_t i = off_start; i < off_stop; ++i) {
++ if (ULONG_IS_BIT_SET(bits, i)) {
++ ++count;
++ }
++ }
++ return count;
++}
+
-+ /* Check if a sysctl exists. */
-+ snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%i.%%desc",
-+ device->driver, unit);
-+ ret = sysctlbyname(sysctlname, NULL, &len, NULL, 0);
++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;
+
-+ if (ret == 0 && len > 0) {
-+ snprintf(devname, devname_len, "%s%i", device->driver, unit);
-+ return true;
++ 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 false;
++ return NULL;
+}
+
-+static bool
-+devpath_exists(const struct hw_type *device,
-+ char *devname, size_t devname_len)
++static hw_type_p
++get_dev_type_by_path(const char *dev_name, size_t dev_name_size, hw_type_p hw_type_cust)
+{
-+ char *devpath;
-+ struct stat st;
-+ int ret;
-+
-+ if (device == NULL || device->driver == NULL)
-+ return false;
++ if (!dev_name || !dev_name_size || !hw_type_cust)
++ return NULL;
+
-+ /* Check if /dev/$driver exists. */
-+ asprintf(&devpath, "/dev/%s", device->driver);
-+ if (devpath == NULL)
-+ return false;
++ 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;
++}
+
-+ ret = stat(devpath, &st);
-+ free(devpath);
++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";
+
-+ if (ret == 0) {
-+ strncpy(devname, device->driver, devname_len);
-+ return true;
-+ }
++ int fd = open(device, O_RDONLY);
++ if (fd < 0)
++ return 0;
+
-+ return false;
++ keyboard_info_t info;
++ int ret = (ioctl(fd, KDGKBINFO, &info) == -1 ||
++ memcmp(info.kb_name, "kbdmux", 6)) ? 0 : 1;
++ close(fd);
++ return ret;
+}
+
-+static char *
-+sysctl_get_str(const char *sysctlname)
++/* Derived from EvdevProbe() function of xf86-input-evdev driver */
++static int
++get_evdev_flags(int fd)
+{
-+ char *dest = NULL;
-+ size_t len;
++ if (fd<0)
++ return 0;
+
-+ if (sysctlname == NULL)
-+ return NULL;
++ 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);
++ }
+
-+ if (sysctlbyname(sysctlname, NULL, &len, NULL, 0) == 0) {
-+ dest = malloc(len + 1);
-+ if (dest) {
-+ if (sysctlbyname(sysctlname, dest, &len, NULL, 0) == 0)
-+ dest[len] = '\0';
-+ else {
-+ free(dest);
-+ dest = NULL;
++ 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;
++ }
+ }
-+
-+ return dest;
++ 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;
+}
+
-+static void
-+device_added(const char *devname)
++/* From: sys/dev/usb/usb_hid.c */
++static int
++hid_is_collection(report_desc_t s, uint32_t usage)
+{
-+ char path[PATH_MAX];
-+ char sysctlname[PATH_MAX];
-+ char *vendor;
-+ char *product = NULL;
-+ char *config_info = NULL;
-+ char *walk;
-+ InputOption *options = NULL;
-+ InputAttributes attrs = { };
-+ DeviceIntPtr dev = NULL;
-+ int i;
-+ int fd;
-+
-+ for (i = 0; hw_types[i].driver != NULL; i++) {
-+ size_t len;
-+
-+ len = strlen(hw_types[i].driver);
-+ if (strcmp(devname, hw_types[i].driver) == 0 ||
-+ (strncmp(devname, hw_types[i].driver, len) == 0 &&
-+ isnumber(*(devname + len)))) {
-+ attrs.flags |= hw_types[i].flag;
++ 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;
++}
+
-+ if (hw_types[i].driver == NULL || hw_types[i].xdriver == NULL) {
-+ LogMessage(X_INFO, "config/devd: ignoring device %s\n",
-+ devname);
-+ return;
-+ }
++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;
+
-+ /* Skip keyboard devices if kbdmux is enabled */
-+ if (is_kbdmux && is_console_kbd && hw_types[i].flag & ATTR_KEYBOARD) {
-+ LogMessage(X_INFO, "config/devd: kbdmux is enabled, ignoring device %s\n",
-+ devname);
-+ return;
++ 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;
+
-+ snprintf(path, sizeof(path), "/dev/%s", devname);
++ size_t len = 0;
++ if (sysctlbyname(sysctlname, NULL, &len, NULL, 0) || !len)
++ return NULL;
+
-+ options = input_option_new(NULL, "_source", "server/devd");
-+ if (!options)
-+ return;
++ char* dest = malloc(len + 1);
++ if (!dest)
++ return NULL;
+
-+ snprintf(sysctlname, sizeof(sysctlname), "dev.%s.%s.%%desc",
-+ hw_types[i].driver, devname + strlen(hw_types[i].driver));
-+ vendor = sysctl_get_str(sysctlname);
-+ if (vendor == NULL) {
-+ options = input_option_new(options, "name", devname);
++ if (sysctlbyname(sysctlname, dest, &len, NULL, 0)) {
++ free(dest);
++ return NULL;
+ }
-+ else {
-+ if ((walk = strchr(vendor, ' ')) != NULL) {
-+ walk[0] = '\0';
-+ walk++;
-+ product = walk;
-+ if ((walk = strchr(product, ',')) != NULL)
-+ walk[0] = '\0';
-+ }
++ dest[len] = 0;
++ if (size_ret)
++ *size_ret = len;
++ return dest;
++}
+
-+ attrs.vendor = strdup(vendor);
-+ if (product) {
-+ attrs.product = strdup(product);
-+ options = input_option_new(options, "name", product);
-+ }
-+ else
-+ options = input_option_new(options, "name", "(unnamed)");
++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;
+
-+ free(vendor);
++ 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;
+
-+ /* XXX implement usb_id */
-+ attrs.usb_id = NULL;
-+ attrs.device = strdup(path);
-+ options = input_option_new(options, "driver", hw_types[i].xdriver);
++ 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;
+
-+ fd = open(path, O_RDONLY);
-+ if (fd > 0) {
-+ close(fd);
-+ options = input_option_new(options, "device", path);
++ /* 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;
+ }
-+ else {
-+ if (attrs.flags & ~ATTR_KEYBOARD) {
-+ LogMessage(X_INFO, "config/devd: device %s already opened\n",
-+ path);
+
++ /* 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 enabled
++ * but it should not matter when config/devd is enabled
+ */
-+ goto unwind;
++ LogMessage(X_WARNING, "config/devd: device %s already opened\n", dev_path);
++ return;
+ }
-+
-+ if (is_console_kbd) {
++ 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 (%s)\n",
-+ attrs.product, path);
-+ goto unwind;
++ 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);
+ }
-+ else
-+ /*
-+ * Don't pass "device" option if the keyboard is already
-+ * attached to the console (ie. open() fails).
-+ * 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.
-+ */
-+ is_console_kbd = true;
-+ }
+
-+ if (asprintf(&config_info, "devd:%s", devname) == -1) {
-+ config_info = NULL;
-+ goto unwind;
++ 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);
+
-+ if (device_is_duplicate(config_info)) {
-+ LogMessage(X_WARNING, "config/devd: device %s (%s) already added. "
-+ "ignoring\n", attrs.product, path);
-+ goto unwind;
++ /* 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);
++ }
+ }
+
-+ options = input_option_new(options, "config_info", config_info);
-+ LogMessage(X_INFO, "config/devd: adding input device %s (%s)\n",
-+ attrs.product, path);
-+
-+ NewInputDeviceRequest(options, &attrs, &dev);
-+
-+unwind:
-+ free(config_info);
-+ input_option_free_list(&options);
-+ free(attrs.usb_id);
-+ free(attrs.product);
-+ free(attrs.device);
-+ free(attrs.vendor);
++ /* 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(char *devname)
++device_removed(const char *dev_name, size_t dev_name_size)
+{
-+ char *config_info;
+
-+ if (asprintf(&config_info, "devd:%s", devname) == -1)
++ if (!dev_name || !dev_name_size || dev_name_size > PATH_MAX)
+ return;
+
-+ remove_devices("devd", config_info);
-+
-+ free(config_info);
-+}
-+
-+static bool is_kbdmux_enabled(void)
-+{
-+ /* Xorg uses /dev/ttyv0 as a console device */
-+ /* const char device[]="/dev/console"; */
-+ const char device[]="/dev/ttyv0";
-+ keyboard_info_t info;
-+ int fd;
-+
-+ fd = open(device, O_RDONLY);
-+
-+ if (fd < 0)
-+ return false;
-+
-+ if (ioctl(fd, KDGKBINFO, &info) == -1) {
-+ close(fd);
-+ return false;
-+ }
-+
-+ close(fd);
++ 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. */
+
-+ if (!strncmp(info.kb_name, "kbdmux", 6))
-+ return true;
-+
-+ return false;
++ 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
-+disconnect_devd(int sock)
-+{
-+ if (sock >= 0) {
-+ RemoveGeneralSocket(sock);
-+ close(sock);
-+ }
-+}
++static void socket_handler(int fd, int ready, void *data);
+
+static int
+connect_devd(void)
+{
-+ struct sockaddr_un devd;
-+ int sock;
-+
-+ sock = socket(AF_UNIX, SOCK_STREAM, 0);
++ int sock = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (sock < 0) {
-+ LogMessage(X_ERROR, "config/devd: fail opening stream socket\n");
++ LogMessage(X_ERROR, "config/devd: failed opening stream socket: %s\n", strerror(errno));
+ return -1;
+ }
+
++ struct sockaddr_un devd;
+ devd.sun_family = AF_UNIX;
-+ strlcpy(devd.sun_path, DEVD_SOCK_PATH, sizeof(devd.sun_path));
-+
-+ if (connect(sock, (struct sockaddr *) &devd, sizeof(devd)) < 0) {
++ 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: fail to connect to devd\n");
++ LogMessage(X_ERROR, "config/devd: failed to connect to devd: %s)\n", strerror(error));
+ return -1;
+ }
+
-+ AddGeneralSocket(sock);
++ SetNotifyFd(sock, socket_handler, X_NOTIFY_READ, NULL);
++ return sock;
++}
+
-+ 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)
+{
-+ int newsock;
-+
-+ if ((newsock = connect_devd()) > 0) {
-+ sock_devd = newsock;
-+ TimerFree(rtimer);
-+ rtimer = NULL;
-+ LogMessage(X_INFO, "config/devd: reopening devd socket\n");
-+ return 0;
-+ }
-+
-+ /* Try again after RECONNECT_DELAY */
-+ return RECONNECT_DELAY;
++ 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 ssize_t
-+socket_getline(int fd, char **out)
++static void
++socket_handler(int fd, int ready, void *data)
+{
-+ char *buf, *newbuf;
-+ ssize_t ret, cap, sz = 0;
-+ char c;
-+
-+ cap = 1024;
-+ buf = malloc(cap * sizeof(char));
-+ if (!buf)
-+ return -1;
-+
-+ for (;;) {
-+ ret = read(sock_devd, &c, 1);
-+ if (ret < 0) {
-+ if (errno == EINTR)
-+ continue;
-+ free(buf);
-+ return -1;
-+ /* EOF - devd socket is lost */
-+ } else if (ret == 0) {
-+ disconnect_devd(sock_devd);
-+ rtimer = TimerSet(NULL, 0, 1, reconnect_handler, NULL);
-+ LogMessage(X_WARNING, "config/devd: devd socket is lost\n");
-+ free(buf);
-+ return -1;
++ /* 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. */
+ }
-+ if (c == '\n')
-+ break;
-+
-+ if (sz + 1 >= cap) {
-+ cap *= 2;
-+ newbuf = realloc(buf, cap * sizeof(char));
-+ if (!newbuf) {
-+ free(buf);
-+ return -1;
-+ }
-+ buf = newbuf;
++ /* 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;
+ }
-+ buf[sz] = c;
-+ sz++;
++ /* 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;
+ }
+
-+ buf[sz] = '\0';
-+ if (sz >= 0)
-+ *out = buf;
-+ else
-+ free(buf);
-+
-+ /* Number of bytes in the line, not counting the line break */
-+ return sz;
-+}
-+
-+static void
-+wakeup_handler(void *data, int err, void *read_mask)
-+{
-+ char *line = NULL;
-+ char *walk;
-+
-+ if (err < 0)
-+ 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);
+
-+ if (FD_ISSET(sock_devd, (fd_set *) read_mask)) {
-+ if (socket_getline(sock_devd, &line) < 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;
-+
-+ walk = strchr(line + 1, ' ');
-+ if (walk != NULL)
-+ walk[0] = '\0';
-+
-+ switch (*line) {
-+ case DEVD_EVENT_ADD:
-+ device_added(line + 1);
-+ break;
-+ case DEVD_EVENT_REMOVE:
-+ device_removed(line + 1);
-+ break;
-+ default:
-+ break;
+ }
-+ free(line);
+ }
-+}
-+
-+static void
-+block_handler(void *data, struct timeval **tv, void *read_mask)
-+{
++ /* 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)
+{
-+ char devicename[1024];
-+ int i, j;
-+
+ 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
++ * if kbdmux is enabled and not exported through evdev
+ */
-+ if ((is_kbdmux = is_kbdmux_enabled()) == true)
-+ device_added("kbdmux");
-+
-+ for (i = 0; hw_types[i].driver != NULL; i++) {
-+ /* First scan the sysctl to determine the hardware */
-+ for (j = 0; j < 16; j++) {
-+ if (sysctl_exists(&hw_types[i], j,
-+ devicename, sizeof(devicename)) != 0)
-+ device_added(devicename);
++ 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 (devpath_exists(&hw_types[i], devicename, sizeof(devicename)) != 0)
-+ device_added(devicename);
++ 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);
+
-+ if ((sock_devd = connect_devd()) < 0)
-+ return 0;
-+
-+ RegisterBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
-+
-+ return 1;
++ devd_buf_used = 0;
++ devd_skt = connect_devd();
++ return (devd_skt < 0) ? 0 : 1;
+}
+
+void
@@ -527,9 +853,6 @@
+ rtimer = NULL;
+ }
+
-+ disconnect_devd(sock_devd);
-+
-+ RemoveBlockAndWakeupHandlers(block_handler, wakeup_handler, NULL);
-+
-+ is_console_kbd = false;
++ disconnect_devd(devd_skt);
++ return;
+}
diff --git a/x11-servers/xorg-server/files/patch-config_udev.c b/x11-servers/xorg-server/files/patch-config_udev.c
new file mode 100644
index 000000000000..38b3e84db5ad
--- /dev/null
+++ b/x11-servers/xorg-server/files/patch-config_udev.c
@@ -0,0 +1,56 @@
+* Don't pass the device parameter when using kbdmux to prevent conflict
+*
+* Specify a driver to use for basic devices (keyboard and mouse), otherwise none attaches
+*
+--- config/udev.c.orig 2017-03-15 18:05:25 UTC
++++ config/udev.c
+@@ -29,6 +29,7 @@
+
+ #include <libudev.h>
+ #include <ctype.h>
++#include <fcntl.h>
+ #include <unistd.h>
+
+ #include "input.h"
+@@ -188,7 +189,21 @@ device_added(struct udev_device *udev_de
+ attrs.product = strdup(name);
+ input_options = input_option_new(input_options, "name", name);
+ input_options = input_option_new(input_options, "path", path);
+- input_options = input_option_new(input_options, "device", path);
++ if(strstr(path, "kbdmux") != NULL) {
++ /*
++ * Don't pass "device" option if the keyboard is already attached
++ * to the console (ie. open() fails). 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.
++ */
++ int fd = open(path, O_RDONLY);
++ if (fd > -1) {
++ close(fd);
++ input_options = input_option_new(input_options, "device", path);
++ }
++ }
++ else
++ input_options = input_option_new(input_options, "device", path);
+ input_options = input_option_new(input_options, "major", itoa(major(devnum)));
+ input_options = input_option_new(input_options, "minor", itoa(minor(devnum)));
+ if (path)
+@@ -272,6 +287,18 @@ device_added(struct udev_device *udev_de
+ }
+ }
+
++ if (attrs.flags & (ATTR_KEY | ATTR_KEYBOARD)) {
++ if (!feature_present("evdev_support"))
++ input_options = input_option_new(input_options, "driver", "kbd");
++ } else if (attrs.flags & ATTR_POINTER) {
++ if (strstr(path, "vbox"))
++ input_options = input_option_new(input_options, "driver", "vboxmouse");
++ else {
++ if (!feature_present("evdev_support"))
++ input_options = input_option_new(input_options, "driver", "mouse");
++ }
++ }
++
+ input_options = input_option_new(input_options, "config_info", config_info);
+
+ /* Default setting needed for non-seat0 seats */
diff --git a/x11-servers/xorg-server/files/patch-configure b/x11-servers/xorg-server/files/patch-configure
index 10674bc6034d..5847cde487f8 100644
--- a/x11-servers/xorg-server/files/patch-configure
+++ b/x11-servers/xorg-server/files/patch-configure
@@ -1,6 +1,41 @@
---- configure.orig 2016-07-19 17:27:31 UTC
+* 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
-@@ -23168,9 +23168,14 @@ $as_echo "#define USE_ALPHA_PIO 1" >>con
+@@ -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"
;;
@@ -9,19 +44,122 @@
ARM_VIDEO=yes
DEFAULT_INT10="stub"
+ case $host_os in
-+ *freebsd*)
-+ $as_echo "#define USE_DEV_IO 1" >>confdefs.h
-+ ;;
++ *freebsd*) $as_echo "#define USE_DEV_IO 1" >>confdefs.h
++ ;;
+ esac
;;
i*86)
I386_VIDEO=yes
-@@ -26057,7 +26062,7 @@ fi
- case "x$XTRANS_SEND_FDS" in
- xauto)
- case "$host_os" in
-- linux*|solaris*)
-+ linux*|solaris*|freebsd*|dragonfly*|openbsd*)
- XTRANS_SEND_FDS=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
+ $as_echo "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"
+
+ $as_echo "#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
+ { $as_echo "$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
+ $as_echo "$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
diff --git a/x11-servers/xorg-server/files/patch-glamor_glamor__dash.c b/x11-servers/xorg-server/files/patch-glamor_glamor__dash.c
deleted file mode 100644
index 3255e4bd706c..000000000000
--- a/x11-servers/xorg-server/files/patch-glamor_glamor__dash.c
+++ /dev/null
@@ -1,27 +0,0 @@
-From: Eric Anholt <eric@anholt.net>
-Date: Wed Mar 15 17:51:46 2017 -0700
-Subject: [PATCH]glamor: Fix dashed line rendering.
-Patch-mainline: fe0b297420fc1de8a7fab28457d0864b3182e967
-References: boo#1021803
-Signed-off-by: Max Staudt <mstaudt@suse.de>
-
-We were binding the screen pixmap as the dash and sampling its alpha,
-which is usually just 1.0 (no dashing at all).
-
-Please cherry-pick this to active stable branches.
-
-Signed-off-by: Eric Anholt <eric@anholt.net>
-Reviewed-by: Keith Packard <keithp@keithp.com>
-Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
-
---- glamor/glamor_dash.c.orig 2016-07-18 19:08:16 UTC
-+++ glamor/glamor_dash.c
-@@ -146,7 +146,7 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
- goto bail;
-
- dash_pixmap = glamor_get_dash_pixmap(gc);
-- dash_priv = glamor_get_pixmap_private(pixmap);
-+ dash_priv = glamor_get_pixmap_private(dash_pixmap);
-
- if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dash_priv))
- goto bail;
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_Makefile.in b/x11-servers/xorg-server/files/patch-hw_xfree86_Makefile.in
new file mode 100644
index 000000000000..1bd489997676
--- /dev/null
+++ b/x11-servers/xorg-server/files/patch-hw_xfree86_Makefile.in
@@ -0,0 +1,14 @@
+* 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:
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86AutoConfig.c b/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86AutoConfig.c
index 071e77e8fa09..daf8862b6e23 100644
--- a/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86AutoConfig.c
+++ b/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86AutoConfig.c
@@ -1,23 +1,27 @@
---- hw/xfree86/common/xf86AutoConfig.c.orig 2017-01-11 20:00:58 UTC
+* Try using modesetting driver before falling back to scfb or vesa
+*
+* 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
-@@ -276,7 +276,7 @@ listPossibleVideoDrivers(char *matches[]
- i += xf86PciMatchDriver(&matches[i], nmatches - i);
+@@ -294,7 +294,7 @@ listPossibleVideoDrivers(XF86MatchedDriv
+ xf86PciMatchDriver(md);
#endif
-#if defined(__linux__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
- matches[i++] = xnfstrdup("modesetting");
+ xf86AddMatchedDriver(md, "modesetting");
#endif
-@@ -285,8 +285,10 @@ listPossibleVideoDrivers(char *matches[]
- if (i < (nmatches - 1)) {
+@@ -302,8 +302,10 @@ listPossibleVideoDrivers(XF86MatchedDriv
+ /* Fallback to platform default frame buffer driver */
#if !defined(__linux__) && defined(__sparc__)
- matches[i++] = xnfstrdup("wsfb");
+ xf86AddMatchedDriver(md, "wsfb");
-#else
+#elif defined(__linux__)
- matches[i++] = xnfstrdup("fbdev");
+ xf86AddMatchedDriver(md, "fbdev");
+#elif defined(__FreeBSD__)
-+ matches[i++] = xnfstrdup("scfb");
++ xf86AddMatchedDriver(md, "scfb");
#endif
- }
#endif /* !__sun */
+
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Config.c b/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Config.c
index 8553ace79086..8dc3d588a172 100644
--- a/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Config.c
+++ b/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Config.c
@@ -1,12 +1,14 @@
---- hw/xfree86/common/xf86Config.c.orig 2016-07-19 17:14:30 UTC
+* 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
-@@ -1410,13 +1410,16 @@ checkCoreInputDevices(serverLayoutPtr se
+@@ -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)
++ defined(CONFIG_DEVD)
const char *config_backend;
#if defined(CONFIG_HAL)
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Globals.c b/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Globals.c
index ed134ade6c53..851a1cd18d94 100644
--- a/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Globals.c
+++ b/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Globals.c
@@ -1,9 +1,11 @@
---- hw/xfree86/common/xf86Globals.c.orig 2016-07-19 17:07:29 UTC
+* 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
-@@ -122,7 +122,8 @@ xf86InfoRec xf86Info = {
+@@ -119,7 +119,8 @@ xf86InfoRec xf86Info = {
+ .miscModInDevEnabled = TRUE,
+ .miscModInDevAllowNonLocal = FALSE,
.pmFlag = TRUE,
- .disableRandR = FALSE,
- .randRFrom = X_DEFAULT,
-#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS) || \
+ defined(CONFIG_DEVD)
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Xinput.c b/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Xinput.c
index 23d08282d4a2..3c0ea7c25874 100644
--- a/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Xinput.c
+++ b/x11-servers/xorg-server/files/patch-hw_xfree86_common_xf86Xinput.c
@@ -1,6 +1,8 @@
---- hw/xfree86/common/xf86Xinput.c.orig 2016-07-19 17:07:29 UTC
+* 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
-@@ -841,7 +841,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, D
+@@ -871,7 +871,7 @@ xf86NewInputDevice(InputInfoPtr pInfo, D
{
InputDriverPtr drv = NULL;
DeviceIntPtr dev = NULL;
@@ -9,7 +11,7 @@
int rval;
char *path = NULL;
-@@ -996,6 +996,7 @@ NewInputDeviceRequest(InputOption *optio
+@@ -1034,6 +1034,7 @@ NewInputDeviceRequest(InputOption *optio
if (strcmp(key, "_source") == 0 &&
(strcmp(value, "server/hal") == 0 ||
strcmp(value, "server/udev") == 0 ||
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_dri2_pci__ids_i965__pci__ids.h b/x11-servers/xorg-server/files/patch-hw_xfree86_dri2_pci__ids_i965__pci__ids.h
deleted file mode 100644
index 71b74b31abd1..000000000000
--- a/x11-servers/xorg-server/files/patch-hw_xfree86_dri2_pci__ids_i965__pci__ids.h
+++ /dev/null
@@ -1,171 +0,0 @@
---- hw/xfree86/dri2/pci_ids/i965_pci_ids.h.orig 2019-09-10 16:20:34 UTC
-+++ hw/xfree86/dri2/pci_ids/i965_pci_ids.h
-@@ -1,3 +1,4 @@
-+#ifndef IRIS
- CHIPSET(0x29A2, i965, "Intel(R) 965G")
- CHIPSET(0x2992, i965, "Intel(R) 965Q")
- CHIPSET(0x2982, i965, "Intel(R) 965G")
-@@ -91,6 +92,11 @@ CHIPSET(0x0F32, byt, "Intel(R) Bay Trail")
- CHIPSET(0x0F33, byt, "Intel(R) Bay Trail")
- CHIPSET(0x0157, byt, "Intel(R) Bay Trail")
- CHIPSET(0x0155, byt, "Intel(R) Bay Trail")
-+CHIPSET(0x22B0, chv, "Intel(R) HD Graphics (Cherrytrail)")
-+CHIPSET(0x22B1, chv, "Intel(R) HD Graphics XXX (Braswell)") /* Overridden in brw_get_renderer_string */
-+CHIPSET(0x22B2, chv, "Intel(R) HD Graphics (Cherryview)")
-+CHIPSET(0x22B3, chv, "Intel(R) HD Graphics (Cherryview)")
-+#endif
- CHIPSET(0x1602, bdw_gt1, "Intel(R) Broadwell GT1")
- CHIPSET(0x1606, bdw_gt1, "Intel(R) Broadwell GT1")
- CHIPSET(0x160A, bdw_gt1, "Intel(R) Broadwell GT1")
-@@ -112,6 +118,7 @@ CHIPSET(0x162E, bdw_gt3, "Intel(R) Broadwell GT3")
- CHIPSET(0x1902, skl_gt1, "Intel(R) HD Graphics 510 (Skylake GT1)")
- CHIPSET(0x1906, skl_gt1, "Intel(R) HD Graphics 510 (Skylake GT1)")
- CHIPSET(0x190A, skl_gt1, "Intel(R) Skylake GT1")
-+CHIPSET(0x190B, skl_gt1, "Intel(R) HD Graphics 510 (Skylake GT1)")
- CHIPSET(0x190E, skl_gt1, "Intel(R) Skylake GT1")
- CHIPSET(0x1912, skl_gt2, "Intel(R) HD Graphics 530 (Skylake GT2)")
- CHIPSET(0x1913, skl_gt2, "Intel(R) Skylake GT2f")
-@@ -122,42 +129,113 @@ CHIPSET(0x191A, skl_gt2, "Intel(R) Skylake GT2")
- CHIPSET(0x191B, skl_gt2, "Intel(R) HD Graphics 530 (Skylake GT2)")
- CHIPSET(0x191D, skl_gt2, "Intel(R) HD Graphics P530 (Skylake GT2)")
- CHIPSET(0x191E, skl_gt2, "Intel(R) HD Graphics 515 (Skylake GT2)")
--CHIPSET(0x1921, skl_gt2, "Intel(R) Skylake GT2")
--CHIPSET(0x1923, skl_gt3, "Intel(R) Iris Graphics 540 (Skylake GT3e)")
--CHIPSET(0x1926, skl_gt3, "Intel(R) HD Graphics 535 (Skylake GT3)")
-+CHIPSET(0x1921, skl_gt2, "Intel(R) HD Graphics 520 (Skylake GT2)")
-+CHIPSET(0x1923, skl_gt3, "Intel(R) Skylake GT3e")
-+CHIPSET(0x1926, skl_gt3, "Intel(R) Iris Graphics 540 (Skylake GT3e)")
- CHIPSET(0x1927, skl_gt3, "Intel(R) Iris Graphics 550 (Skylake GT3e)")
- CHIPSET(0x192A, skl_gt4, "Intel(R) Skylake GT4")
--CHIPSET(0x192B, skl_gt3, "Intel(R) Iris Graphics (Skylake GT3fe)")
--CHIPSET(0x1932, skl_gt4, "Intel(R) Skylake GT4")
--CHIPSET(0x193A, skl_gt4, "Intel(R) Skylake GT4")
--CHIPSET(0x193B, skl_gt4, "Intel(R) Skylake GT4")
--CHIPSET(0x193D, skl_gt4, "Intel(R) Skylake GT4")
--CHIPSET(0x5902, kbl_gt1, "Intel(R) Kabylake GT1")
--CHIPSET(0x5906, kbl_gt1, "Intel(R) Kabylake GT1")
-+CHIPSET(0x192B, skl_gt3, "Intel(R) Iris Graphics 555 (Skylake GT3e)")
-+CHIPSET(0x192D, skl_gt3, "Intel(R) Iris Graphics P555 (Skylake GT3e)")
-+CHIPSET(0x1932, skl_gt4, "Intel(R) Iris Pro Graphics 580 (Skylake GT4e)")
-+CHIPSET(0x193A, skl_gt4, "Intel(R) Iris Pro Graphics P580 (Skylake GT4e)")
-+CHIPSET(0x193B, skl_gt4, "Intel(R) Iris Pro Graphics 580 (Skylake GT4e)")
-+CHIPSET(0x193D, skl_gt4, "Intel(R) Iris Pro Graphics P580 (Skylake GT4e)")
-+CHIPSET(0x0A84, bxt, "Intel(R) HD Graphics (Broxton)")
-+CHIPSET(0x1A84, bxt, "Intel(R) HD Graphics (Broxton)")
-+CHIPSET(0x1A85, bxt_2x6, "Intel(R) HD Graphics (Broxton 2x6)")
-+CHIPSET(0x5A84, bxt, "Intel(R) HD Graphics 505 (Broxton)")
-+CHIPSET(0x5A85, bxt_2x6, "Intel(R) HD Graphics 500 (Broxton 2x6)")
-+CHIPSET(0x5902, kbl_gt1, "Intel(R) HD Graphics 610 (Kaby Lake GT1)")
-+CHIPSET(0x5906, kbl_gt1, "Intel(R) HD Graphics 610 (Kaby Lake GT1)")
- CHIPSET(0x590A, kbl_gt1, "Intel(R) Kabylake GT1")
-+CHIPSET(0x5908, kbl_gt1, "Intel(R) Kabylake GT1")
- CHIPSET(0x590B, kbl_gt1, "Intel(R) Kabylake GT1")
- CHIPSET(0x590E, kbl_gt1, "Intel(R) Kabylake GT1")
- CHIPSET(0x5913, kbl_gt1_5, "Intel(R) Kabylake GT1.5")
- CHIPSET(0x5915, kbl_gt1_5, "Intel(R) Kabylake GT1.5")
--CHIPSET(0x5917, kbl_gt1_5, "Intel(R) Kabylake GT1.5")
--CHIPSET(0x5912, kbl_gt2, "Intel(R) Kabylake GT2")
--CHIPSET(0x5916, kbl_gt2, "Intel(R) Kabylake GT2")
--CHIPSET(0x591A, kbl_gt2, "Intel(R) Kabylake GT2")
--CHIPSET(0x591B, kbl_gt2, "Intel(R) Kabylake GT2")
--CHIPSET(0x591D, kbl_gt2, "Intel(R) Kabylake GT2")
--CHIPSET(0x591E, kbl_gt2, "Intel(R) Kabylake GT2")
-+CHIPSET(0x5917, kbl_gt2, "Intel(R) UHD Graphics 620 (Kabylake GT2)")
-+CHIPSET(0x5912, kbl_gt2, "Intel(R) HD Graphics 630 (Kaby Lake GT2)")
-+CHIPSET(0x5916, kbl_gt2, "Intel(R) HD Graphics 620 (Kaby Lake GT2)")
-+CHIPSET(0x591A, kbl_gt2, "Intel(R) HD Graphics P630 (Kaby Lake GT2)")
-+CHIPSET(0x591B, kbl_gt2, "Intel(R) HD Graphics 630 (Kaby Lake GT2)")
-+CHIPSET(0x591D, kbl_gt2, "Intel(R) HD Graphics P630 (Kaby Lake GT2)")
-+CHIPSET(0x591E, kbl_gt2, "Intel(R) HD Graphics 615 (Kaby Lake GT2)")
- CHIPSET(0x5921, kbl_gt2, "Intel(R) Kabylake GT2F")
--CHIPSET(0x5926, kbl_gt3, "Intel(R) Kabylake GT3")
--CHIPSET(0x592A, kbl_gt3, "Intel(R) Kabylake GT3")
--CHIPSET(0x592B, kbl_gt3, "Intel(R) Kabylake GT3")
--CHIPSET(0x5932, kbl_gt4, "Intel(R) Kabylake GT4")
--CHIPSET(0x593A, kbl_gt4, "Intel(R) Kabylake GT4")
-+CHIPSET(0x5923, kbl_gt3, "Intel(R) Kabylake GT3")
-+CHIPSET(0x5926, kbl_gt3, "Intel(R) Iris Plus Graphics 640 (Kaby Lake GT3e)")
-+CHIPSET(0x5927, kbl_gt3, "Intel(R) Iris Plus Graphics 650 (Kaby Lake GT3e)")
- CHIPSET(0x593B, kbl_gt4, "Intel(R) Kabylake GT4")
--CHIPSET(0x593D, kbl_gt4, "Intel(R) Kabylake GT4")
--CHIPSET(0x22B0, chv, "Intel(R) HD Graphics (Cherryview)")
--CHIPSET(0x22B1, chv, "Intel(R) HD Graphics (Cherryview)")
--CHIPSET(0x22B2, chv, "Intel(R) HD Graphics (Cherryview)")
--CHIPSET(0x22B3, chv, "Intel(R) HD Graphics (Cherryview)")
--CHIPSET(0x0A84, bxt, "Intel(R) HD Graphics (Broxton)")
--CHIPSET(0x1A84, bxt, "Intel(R) HD Graphics (Broxton)")
--CHIPSET(0x5A84, bxt, "Intel(R) HD Graphics (Broxton)")
-+CHIPSET(0x591C, kbl_gt2, "Intel(R) Amber Lake (Kabylake) GT2")
-+CHIPSET(0x87C0, kbl_gt2, "Intel(R) Amber Lake (Kabylake) GT2")
-+CHIPSET(0x87CA, cfl_gt2, "Intel(R) Amber Lake (Coffeelake) GT2")
-+CHIPSET(0x3184, glk, "Intel(R) UHD Graphics 605 (Geminilake)")
-+CHIPSET(0x3185, glk_2x6, "Intel(R) UHD Graphics 600 (Geminilake 2x6)")
-+CHIPSET(0x3E90, cfl_gt1, "Intel(R) UHD Graphics 610 (Coffeelake 2x6 GT1)")
-+CHIPSET(0x3E93, cfl_gt1, "Intel(R) UHD Graphics 610 (Coffeelake 2x6 GT1)")
-+CHIPSET(0x3E99, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)")
-+CHIPSET(0x3E9C, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)")
-+CHIPSET(0x3E91, cfl_gt2, "Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2)")
-+CHIPSET(0x3E92, cfl_gt2, "Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2)")
-+CHIPSET(0x3E96, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
-+CHIPSET(0x3E98, cfl_gt2, "Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2)")
-+CHIPSET(0x3E9A, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
-+CHIPSET(0x3E9B, cfl_gt2, "Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2)")
-+CHIPSET(0x3E94, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
-+CHIPSET(0x3EA9, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)")
-+CHIPSET(0x3EA5, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)")
-+CHIPSET(0x3EA6, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)")
-+CHIPSET(0x3EA7, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)")
-+CHIPSET(0x3EA8, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)")
-+CHIPSET(0x3EA1, cfl_gt1, "Intel(R) HD Graphics (Whiskey Lake 2x6 GT1)")
-+CHIPSET(0x3EA4, cfl_gt1, "Intel(R) HD Graphics (Whiskey Lake 3x8 GT1)")
-+CHIPSET(0x3EA0, cfl_gt2, "Intel(R) HD Graphics (Whiskey Lake 3x8 GT2)")
-+CHIPSET(0x3EA3, cfl_gt2, "Intel(R) HD Graphics (Whiskey Lake 3x8 GT2)")
-+CHIPSET(0x3EA2, cfl_gt3, "Intel(R) HD Graphics (Whiskey Lake 3x8 GT3)")
-+CHIPSET(0x9B21, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9BA0, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9BA2, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9BA4, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9BA5, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9BA8, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9BAA, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9BAB, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9BAC, cfl_gt1, "Intel(R) HD Graphics (Comet Lake 2x6 GT1)")
-+CHIPSET(0x9B41, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x9BC0, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x9BC2, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x9BC4, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x9BC5, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x9BC8, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x9BCA, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x9BCB, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x9BCC, cfl_gt2, "Intel(R) HD Graphics (Comet Lake 3x8 GT2)")
-+CHIPSET(0x5A49, cnl_2x8, "Intel(R) HD Graphics (Cannonlake 2x8 GT0.5)")
-+CHIPSET(0x5A4A, cnl_2x8, "Intel(R) HD Graphics (Cannonlake 2x8 GT0.5)")
-+CHIPSET(0x5A41, cnl_3x8, "Intel(R) HD Graphics (Cannonlake 3x8 GT1)")
-+CHIPSET(0x5A42, cnl_3x8, "Intel(R) HD Graphics (Cannonlake 3x8 GT1)")
-+CHIPSET(0x5A44, cnl_3x8, "Intel(R) HD Graphics (Cannonlake 3x8 GT1)")
-+CHIPSET(0x5A59, cnl_4x8, "Intel(R) HD Graphics (Cannonlake 4x8 GT1.5)")
-+CHIPSET(0x5A5A, cnl_4x8, "Intel(R) HD Graphics (Cannonlake 4x8 GT1.5)")
-+CHIPSET(0x5A5C, cnl_4x8, "Intel(R) HD Graphics (Cannonlake 4x8 GT1.5)")
-+CHIPSET(0x5A50, cnl_5x8, "Intel(R) HD Graphics (Cannonlake 5x8 GT2)")
-+CHIPSET(0x5A51, cnl_5x8, "Intel(R) HD Graphics (Cannonlake 5x8 GT2)")
-+CHIPSET(0x5A52, cnl_5x8, "Intel(R) HD Graphics (Cannonlake 5x8 GT2)")
-+CHIPSET(0x5A54, cnl_5x8, "Intel(R) HD Graphics (Cannonlake 5x8 GT2)")
-+CHIPSET(0x8A50, icl_8x8, "Intel(R) HD Graphics (Ice Lake 8x8 GT2)")
-+CHIPSET(0x8A51, icl_8x8, "Intel(R) HD Graphics (Ice Lake 8x8 GT2)")
-+CHIPSET(0x8A52, icl_8x8, "Intel(R) HD Graphics (Ice Lake 8x8 GT2)")
-+CHIPSET(0x8A53, icl_8x8, "Intel(R) HD Graphics (Ice Lake 8x8 GT2)")
-+CHIPSET(0x8A54, icl_6x8, "Intel(R) HD Graphics (Ice Lake 6x8 GT1.5)")
-+CHIPSET(0x8A56, icl_4x8, "Intel(R) HD Graphics (Ice Lake 4x8 GT1)")
-+CHIPSET(0x8A57, icl_6x8, "Intel(R) HD Graphics (Ice Lake 6x8 GT1.5)")
-+CHIPSET(0x8A58, icl_4x8, "Intel(R) HD Graphics (Ice Lake 4x8 GT1)")
-+CHIPSET(0x8A59, icl_6x8, "Intel(R) HD Graphics (Ice Lake 6x8 GT1.5)")
-+CHIPSET(0x8A5A, icl_6x8, "Intel(R) HD Graphics (Ice Lake 6x8 GT1.5)")
-+CHIPSET(0x8A5B, icl_4x8, "Intel(R) HD Graphics (Ice Lake 4x8 GT1)")
-+CHIPSET(0x8A5C, icl_6x8, "Intel(R) HD Graphics (Ice Lake 6x8 GT1.5)")
-+CHIPSET(0x8A5D, icl_4x8, "Intel(R) HD Graphics (Ice Lake 4x8 GT1)")
-+CHIPSET(0x8A71, icl_1x8, "Intel(R) HD Graphics (Ice Lake 1x8 GT0.5)")
-+CHIPSET(0x4500, ehl_4x8, "Intel(R) HD Graphics (Elkhart Lake 4x8)")
-+CHIPSET(0x4571, ehl_4x8, "Intel(R) HD Graphics (Elkhart Lake 4x8)")
-+CHIPSET(0x4551, ehl_4x4, "Intel(R) HD Graphics (Elkhart Lake 4x4)")
-+CHIPSET(0x4541, ehl_2x4, "Intel(R) HD Graphics (Elkhart Lake 2x4)")
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_bsd__init.c b/x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_bsd__init.c
index 4f4a60ee749a..8e0dd7085224 100644
--- a/x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_bsd__init.c
+++ b/x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_bsd__init.c
@@ -1,6 +1,15 @@
---- hw/xfree86/os-support/bsd/bsd_init.c.orig 2016-07-19 17:07:29 UTC
+--- hw/xfree86/os-support/bsd/bsd_init.c.orig 2017-03-15 18:05:25 UTC
+++ hw/xfree86/os-support/bsd/bsd_init.c
-@@ -230,6 +230,9 @@ xf86OpenConsole()
+@@ -48,6 +48,8 @@ static int devConsoleFd = -1;
+ #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ static int VTnum = -1;
+ static int initialVT = -1;
++static struct termios tty_attr; /* tty state to restore */
++static int tty_mode; /* kbd mode to restore */
+ #endif
+
+ #ifdef PCCONS_SUPPORT
+@@ -230,6 +232,9 @@ xf86OpenConsole()
* Add cases for other *BSD that behave the same.
*/
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
@@ -10,3 +19,47 @@
uname(&uts);
i = atof(uts.release) * 100;
if (i >= 310)
+@@ -253,6 +258,7 @@ xf86OpenConsole()
+ #endif
+ acquire_vt:
+ if (!xf86Info.ShareVTs) {
++ struct termios nTty;
+ /*
+ * now get the VT
+ */
+@@ -287,6 +293,26 @@ xf86OpenConsole()
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+ }
++
++ tcgetattr(xf86Info.consoleFd, &tty_attr);
++ ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode);
++
++ /* disable special keys */
++ if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0) {
++ FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed (%s)",
++ strerror(errno));
++ }
++
++ nTty = tty_attr;
++ nTty.c_iflag = IGNPAR | IGNBRK;
++ nTty.c_oflag = 0;
++ nTty.c_cflag = CREAD | CS8;
++ nTty.c_lflag = 0;
++ nTty.c_cc[VTIME] = 0;
++ nTty.c_cc[VMIN] = 1;
++ cfsetispeed(&nTty, 9600);
++ cfsetospeed(&nTty, 9600);
++ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+ }
+ else { /* xf86Info.ShareVTs */
+ close(xf86Info.consoleFd);
+@@ -594,6 +620,8 @@ xf86CloseConsole()
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
++ ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
++ tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_i386__video.c b/x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_i386__video.c
deleted file mode 100644
index 57cf332c70f1..000000000000
--- a/x11-servers/xorg-server/files/patch-hw_xfree86_os-support_bsd_i386__video.c
+++ /dev/null
@@ -1,11 +0,0 @@
-Index: programs/Xserver/hw/xfree86/os-support/bsd/i386_video.c
---- hw/xfree86/os-support/bsd/i386_video.c.orig 2016-07-15 16:18:11 UTC
-+++ hw/xfree86/os-support/bsd/i386_video.c
-@@ -32,6 +32,7 @@
- #include "xf86Priv.h"
-
- #include <errno.h>
-+#include <sys/types.h>
- #include <sys/mman.h>
-
- #include "xf86_OSlib.h"
diff --git a/x11-servers/xorg-server/files/patch-hw_xfree86_xorg-wrapper.c b/x11-servers/xorg-server/files/patch-hw_xfree86_xorg-wrapper.c
new file mode 100644
index 000000000000..169ed09b3772
--- /dev/null
+++ b/x11-servers/xorg-server/files/patch-hw_xfree86_xorg-wrapper.c
@@ -0,0 +1,27 @@
+* 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)
+
+ int main(int argc, char *argv[])
+ {
+-#ifdef WITH_LIBDRM
+- 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[])
+ }
+ }
+
+-#ifdef WITH_LIBDRM
++#if defined(WITH_LIBDRM) && defined(__linux__)
+ /* Detect if we need root rights, except when overriden 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);
diff --git a/x11-servers/xorg-server/files/patch-include_dix-config.h.in b/x11-servers/xorg-server/files/patch-include_dix-config.h.in
new file mode 100644
index 000000000000..efa14c208398
--- /dev/null
+++ b/x11-servers/xorg-server/files/patch-include_dix-config.h.in
@@ -0,0 +1,14 @@
+* 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
+
diff --git a/x11-servers/xorg-server/files/patch-os_io.c b/x11-servers/xorg-server/files/patch-os_io.c
deleted file mode 100644
index dfe999e21b3e..000000000000
--- a/x11-servers/xorg-server/files/patch-os_io.c
+++ /dev/null
@@ -1,34 +0,0 @@
-From e751722a7b0c5b595794e60b054ade0b3f6cdb4d Mon Sep 17 00:00:00 2001
-From: Michal Srb <msrb@suse.com>
-Date: Fri, 7 Jul 2017 17:04:03 +0200
-Subject: os: Make sure big requests have sufficient length.
-
-A client can send a big request where the 32B "length" field has value
-0. When the big request header is removed and the length corrected,
-the value will underflow to 0xFFFFFFFF. Functions processing the
-request later will think that the client sent much more data and may
-touch memory beyond the receive buffer.
-
-Signed-off-by: Eric Anholt <eric@anholt.net>
-Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-(cherry picked from commit 9c23685009aa96f4b861dcc5d2e01dbee00c4dd9)
-
-diff --git a/os/io.c b/os/io.c
-index f80580c..70f07f3 100644
---- os/io.c
-+++ os/io.c
-@@ -441,6 +441,11 @@ ReadRequestFromClient(ClientPtr client)
- if (!gotnow)
- AvailableInput = oc;
- if (move_header) {
-+ if (client->req_len < bytes_to_int32(sizeof(xBigReq) - sizeof(xReq))) {
-+ YieldControlDeath();
-+ return -1;
-+ }
-+
- request = (xReq *) oci->bufptr;
- oci->bufptr += (sizeof(xBigReq) - sizeof(xReq));
- *(xReq *) oci->bufptr = *request;
---
-cgit v0.10.2
-
diff --git a/x11-servers/xorg-server/files/patch-test_xtest.c b/x11-servers/xorg-server/files/patch-test_xtest.c
new file mode 100644
index 000000000000..2e33addbc12d
--- /dev/null
+++ b/x11-servers/xorg-server/files/patch-test_xtest.c
@@ -0,0 +1,17 @@
+--- 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;
diff --git a/x11-servers/xorg-server/files/patch-xkb_Makefile.in b/x11-servers/xorg-server/files/patch-xkb_Makefile.in
index c3dd6aae35f7..4bcfeb9866dd 100644
--- a/x11-servers/xorg-server/files/patch-xkb_Makefile.in
+++ b/x11-servers/xorg-server/files/patch-xkb_Makefile.in
@@ -1,6 +1,11 @@
---- xkb/Makefile.in.orig 2017-01-19 15:20:42 UTC
+* 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
-@@ -878,7 +878,7 @@ info: info-am
+@@ -886,7 +886,7 @@ info: info-am
info-am:
diff --git a/x11-servers/xorg-server/files/xkb_Makefile.am b/x11-servers/xorg-server/files/xkb_Makefile.am
new file mode 100644
index 000000000000..28072621cb12
--- /dev/null
+++ b/x11-servers/xorg-server/files/xkb_Makefile.am
@@ -0,0 +1,13 @@
+* 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
diff --git a/x11-servers/xorg-server/pkg-message b/x11-servers/xorg-server/pkg-message
new file mode 100644
index 000000000000..c9aa03ba366e
--- /dev/null
+++ b/x11-servers/xorg-server/pkg-message
@@ -0,0 +1,26 @@
+[
+{ type: install
+ message: <<EOM
+Xorg-server has been installed.
+
+If your kernel is compiled with the EVDEV_SUPPORT option enabled
+(default starting from FreeBSD 12.1) it is recommended to enable evdev mode in
+pointer device drivers like ums(4) and psm(4). This will give improvements like
+better tilt wheel support for mice and centralized gesture support via
+xf86-input-synaptics or libinput drivers for touchpads.
+
+This is also needed for PS/2 devices to be properly detected by Xorg when
+moused service is disabled in /etc/rc.conf and kernel is compiled with
+EVDEV_SUPPORT.
+
+To enable evdev in such a device, run the following:
+
+# sysctl kern.evdev.rcpt_mask=6
+
+To make it persistent across reboots, add the following to /etc/sysctl.conf:
+
+kern.evdev.rcpt_mask=6
+
+EOM
+}
+]
diff --git a/x11-servers/xorg-server/pkg-plist b/x11-servers/xorg-server/pkg-plist
index cf97beb10ddc..71dd5a690605 100644
--- a/x11-servers/xorg-server/pkg-plist
+++ b/x11-servers/xorg-server/pkg-plist
@@ -1,6 +1,6 @@
bin/X
-%%SUID%%@(,,4555) bin/Xorg
-%%NO_SUID%%bin/Xorg
+bin/Xorg
+%%SUID%%@(,,4555) bin/Xorg.wrap
bin/cvt
bin/gtf
include/xorg/BT.h
@@ -54,6 +54,7 @@ include/xorg/geint.h
include/xorg/glamor.h
include/xorg/globals.h
include/xorg/glx_extinit.h
+include/xorg/glxvndabi.h
include/xorg/glyphstr.h
include/xorg/hotplug.h
include/xorg/i2c_def.h
@@ -114,6 +115,7 @@ include/xorg/validate.h
include/xorg/vbe.h
include/xorg/vbeModes.h
include/xorg/vgaHW.h
+include/xorg/vndserver.h
include/xorg/wfbrename.h
include/xorg/window.h
include/xorg/windowstr.h
@@ -124,6 +126,7 @@ include/xorg/xf86.h
include/xorg/xf86Crtc.h
include/xorg/xf86Cursor.h
include/xorg/xf86DDC.h
+include/xorg/xf86MatchDrivers.h
include/xorg/xf86Modes.h
include/xorg/xf86Module.h
include/xorg/xf86Opt.h
@@ -159,7 +162,7 @@ include/xorg/xkbstr.h
include/xorg/xorg-server.h
include/xorg/xorgVersion.h
include/xorg/xserver-properties.h
-@comment include/xorg/xserver_poll.h
+include/xorg/xserver_poll.h
include/xorg/xvdix.h
include/xorg/xvmcext.h
lib/xorg/modules/drivers/modesetting_drv.so
@@ -177,15 +180,18 @@ lib/xorg/modules/libwfb.so
lib/xorg/protocol.txt
libdata/pkgconfig/xorg-server.pc
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/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/20-evdev-kbd.conf
share/aclocal/xorg-server.m4
@dir etc/X11/xorg.conf.d
@dir %%FONTPATHD%%
diff --git a/x11-servers/xorg-vfbserver/Makefile b/x11-servers/xorg-vfbserver/Makefile
index 69e5110818d7..43f2b22d6115 100644
--- a/x11-servers/xorg-vfbserver/Makefile
+++ b/x11-servers/xorg-vfbserver/Makefile
@@ -2,7 +2,6 @@
# $FreeBSD$
PORTNAME= xorg-vfbserver
-PORTVERSION= 1.19.1
PORTEPOCH= 1
COMMENT= X virtual framebuffer server from X.Org
@@ -11,30 +10,14 @@ LICENSE= MIT
MASTERDIR= ${.CURDIR}/../xorg-server
DESCR= ${.CURDIR}/pkg-descr
-DISTINFO_FILE= ${.CURDIR}/distinfo
-PATCHDIR= ${.CURDIR}/files
SLAVE_PORT= yes
-OPTIONS_EXCLUDE=DEVD HAL SUID UDEV
-
-USE_XORG= xfont2
CONFIGURE_ARGS+=--enable-xvfb --disable-dmx --disable-xephyr --disable-xnest \
--disable-xwayland
PLIST_FILES= bin/Xvfb man/man1/Xvfb.1.gz
-EXTRA_PATCHES= ${MASTERDIR}/files/patch-CVE-2017-12176 \
- ${MASTERDIR}/files/patch-CVE-2017-12177 \
- ${MASTERDIR}/files/patch-CVE-2017-12178 \
- ${MASTERDIR}/files/patch-CVE-2017-12179 \
- ${MASTERDIR}/files/patch-CVE-2017-12183 \
- ${MASTERDIR}/files/patch-CVE-2017-1218x \
- ${MASTERDIR}/files/patch-CVE-2017-1218y \
- ${MASTERDIR}/files/patch-CVE-2017-13721 \
- ${MASTERDIR}/files/patch-CVE-2017-13723 \
- ${MASTERDIR}/files/patch-os_io.c
-
do-install:
cd ${WRKSRC}/hw/vfb; DESTDIR=${STAGEDIR} ${MAKE} install
diff --git a/x11-servers/xorg-vfbserver/distinfo b/x11-servers/xorg-vfbserver/distinfo
deleted file mode 100644
index 655e32cde9b6..000000000000
--- a/x11-servers/xorg-vfbserver/distinfo
+++ /dev/null
@@ -1,3 +0,0 @@
-TIMESTAMP = 1484389062
-SHA256 (xorg/xserver/xorg-server-1.19.1.tar.bz2) = 79ae2cf39d3f6c4a91201d8dad549d1d774b3420073c5a70d390040aa965a7fb
-SIZE (xorg/xserver/xorg-server-1.19.1.tar.bz2) = 6041792
diff --git a/x11-servers/xwayland/Makefile b/x11-servers/xwayland/Makefile
index 1b8ada2e0989..6e5a2a090516 100644
--- a/x11-servers/xwayland/Makefile
+++ b/x11-servers/xwayland/Makefile
@@ -1,10 +1,6 @@
# $FreeBSD$
PORTNAME= xwayland
-PORTVERSION= 1.19.1
-# This is inherited from x11-servers/xorg-server
-# Ensure it does not go backwards when bumping
-PORTREVISION= 11
COMMENT= X Clients under Wayland
@@ -19,32 +15,16 @@ CONFLICTS_INSTALL= ${PORTNAME}-devel
MASTERDIR= ${.CURDIR}/../xorg-server
DESCR= ${.CURDIR}/pkg-descr
-DISTINFO_FILE= ${.CURDIR}/distinfo
-PATCHDIR= ${.CURDIR}/files
SLAVE_PORT= yes
-OPTIONS_EXCLUDE=DEVD HAL SUID UDEV
-
-USE_XORG= x11 xext xfont2
+USE_XORG= x11 xext
USE_GL+= egl gbm
-CONFIGURE_ARGS+= --disable-docs --disable-devel-docs \
- --enable-xwayland --disable-xorg --disable-xvfb --disable-xnest \
- --disable-xquartz --disable-xwin
+CONFIGURE_ARGS+=--disable-dmx --disable-xephyr --disable-xnest --disable-xvfb \
+ --enable-xwayland --with-default-xkb-ruleset=evdev
PLIST_FILES= bin/Xwayland
-EXTRA_PATCHES= ${MASTERDIR}/files/patch-CVE-2017-12176 \
- ${MASTERDIR}/files/patch-CVE-2017-12177 \
- ${MASTERDIR}/files/patch-CVE-2017-12178 \
- ${MASTERDIR}/files/patch-CVE-2017-12179 \
- ${MASTERDIR}/files/patch-CVE-2017-12183 \
- ${MASTERDIR}/files/patch-CVE-2017-1218x \
- ${MASTERDIR}/files/patch-CVE-2017-1218y \
- ${MASTERDIR}/files/patch-CVE-2017-13721 \
- ${MASTERDIR}/files/patch-CVE-2017-13723 \
- ${MASTERDIR}/files/patch-os_io.c
-
do-install:
cd ${WRKSRC}/hw/xwayland; DESTDIR=${STAGEDIR} ${MAKE_CMD} install
diff --git a/x11-servers/xwayland/distinfo b/x11-servers/xwayland/distinfo
deleted file mode 100644
index 2083f2d9a628..000000000000
--- a/x11-servers/xwayland/distinfo
+++ /dev/null
@@ -1,3 +0,0 @@
-TIMESTAMP = 1484388904
-SHA256 (xorg/xserver/xorg-server-1.19.1.tar.bz2) = 79ae2cf39d3f6c4a91201d8dad549d1d774b3420073c5a70d390040aa965a7fb
-SIZE (xorg/xserver/xorg-server-1.19.1.tar.bz2) = 6041792