From 615711a8523a7782da7ab04b9435b1205ea3a240 Mon Sep 17 00:00:00 2001
From: obarun <eric@obarun.org>
Date: Sun, 1 Jul 2018 19:52:16 +1100
Subject: [PATCH] upgrel : 1.20.0-10

---
 ...hm-Refuse-to-work-for-remote-clients.patch | 59 +++++++++++++++++++
 PKGBUILD                                      | 16 ++++-
 ...n-of-listening-on-tcp-unix-and-local.patch | 36 +++++++++++
 ...-use-drmmode_bo_import-for-rotate_fb.patch | 18 ++++++
 4 files changed, 127 insertions(+), 2 deletions(-)
 create mode 100644 0001-Xext-shm-Refuse-to-work-for-remote-clients.patch
 create mode 100644 meson-Add-configuration-of-listening-on-tcp-unix-and-local.patch
 create mode 100644 xserver-modesetting-use-drmmode_bo_import-for-rotate_fb.patch

diff --git a/0001-Xext-shm-Refuse-to-work-for-remote-clients.patch b/0001-Xext-shm-Refuse-to-work-for-remote-clients.patch
new file mode 100644
index 0000000..59f53bd
--- /dev/null
+++ b/0001-Xext-shm-Refuse-to-work-for-remote-clients.patch
@@ -0,0 +1,59 @@
+From ec7e2b54c5b4a34b2a077082967bc3ead30e227e Mon Sep 17 00:00:00 2001
+From: Alexander Volkov <a.volkov@rusbitech.ru>
+Date: Tue, 5 Jun 2018 13:05:39 +0300
+Subject: [PATCH] Xext/shm: Refuse to work for remote clients
+
+Avoid access to System V shared memory segment on the X server side
+for clients forwarded via SSH. Also prevent them from hanging while
+waiting for the reply from the ShmCreateSegment request.
+
+v2: Allow ShmQueryVersion request even for remote clients
+
+Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=11080
+Signed-off-by: Alexander Volkov <a.volkov@rusbitech.ru>
+Reviewed-by: Adam Jackson <ajax@redhat.com>
+Signed-off-by: Laurent Carlier <lordheavym@gmail.com>
+---
+ Xext/shm.c | 18 ++++++++++++++----
+ 1 file changed, 14 insertions(+), 4 deletions(-)
+
+diff --git a/Xext/shm.c b/Xext/shm.c
+index fc8441c..896a966 100644
+--- a/Xext/shm.c
++++ b/Xext/shm.c
+@@ -1302,9 +1302,14 @@ static int
+ ProcShmDispatch(ClientPtr client)
+ {
+     REQUEST(xReq);
+-    switch (stuff->data) {
+-    case X_ShmQueryVersion:
++
++    if (stuff->data == X_ShmQueryVersion)
+         return ProcShmQueryVersion(client);
++
++    if (!client->local)
++        return BadRequest;
++
++    switch (stuff->data) {
+     case X_ShmAttach:
+         return ProcShmAttach(client);
+     case X_ShmDetach:
+@@ -1461,9 +1466,14 @@ static int _X_COLD
+ SProcShmDispatch(ClientPtr client)
+ {
+     REQUEST(xReq);
+-    switch (stuff->data) {
+-    case X_ShmQueryVersion:
++
++    if (stuff->data == X_ShmQueryVersion)
+         return SProcShmQueryVersion(client);
++
++    if (!client->local)
++        return BadRequest;
++
++    switch (stuff->data) {
+     case X_ShmAttach:
+         return SProcShmAttach(client);
+     case X_ShmDetach:
+-- 
+2.17.1
diff --git a/PKGBUILD b/PKGBUILD
index 45da940..bcd6f7d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -7,7 +7,7 @@ pkgbase=xorg-server
 pkgname=('xorg-server' 'xorg-server-xephyr' 'xorg-server-xdmx' 'xorg-server-xvfb' 'xorg-server-xnest' 
          'xorg-server-xwayland' 'xorg-server-common' 'xorg-server-devel')
 pkgver=1.20.0
-pkgrel=8
+pkgrel=10
 arch=('x86_64')
 license=('custom')
 groups=('xorg')
@@ -30,7 +30,10 @@ source=(https://xorg.freedesktop.org/releases/individual/xserver/${pkgbase}-${pk
         xserver-2-2-glamor-Propagate-glamor_fds_from_pixmap-error-in-glamor_fd_from_pixmap.patch
         0001-v2-FS-58644.patch
         0002-fix-libshadow-2.patch
-        0003_Use_PictureMatchFormat_for_source-only_picture_format.diff)
+        0003_Use_PictureMatchFormat_for_source-only_picture_format.diff
+        0001-Xext-shm-Refuse-to-work-for-remote-clients.patch
+        meson-Add-configuration-of-listening-on-tcp-unix-and-local.patch
+        xserver-modesetting-use-drmmode_bo_import-for-rotate_fb.patch)
 validpgpkeys=('7B27A3F1A6E18CD9588B4AE8310180050905E40C'
               'C383B778255613DFDB409D91DB221A6900000011'
               'DD38563A8A8224537D1F90E45B8A2D50A0ECD0D3'
@@ -69,6 +72,15 @@ prepare() {
   
   # FS#i58662
   patch -Np1 -i ../0003_Use_PictureMatchFormat_for_source-only_picture_format.diff
+  
+  # Display incorrect when rotated 90 degree - FS#58637
+  patch -Np1 -i ../xserver-modesetting-use-drmmode_bo_import-for-rotate_fb.patch
+
+  # xserver by default listens on tcp sockets - FS#59025
+  patch -Np1 -i ../meson-Add-configuration-of-listening-on-tcp-unix-and-local.patch
+
+  # SSH X11 forwarding no longer works for Qt apps - FS#58962
+  patch -Np1 -i ../0001-Xext-shm-Refuse-to-work-for-remote-clients.patch
 }
 
 build() {
diff --git a/meson-Add-configuration-of-listening-on-tcp-unix-and-local.patch b/meson-Add-configuration-of-listening-on-tcp-unix-and-local.patch
new file mode 100644
index 0000000..f6999e9
--- /dev/null
+++ b/meson-Add-configuration-of-listening-on-tcp-unix-and-local.patch
@@ -0,0 +1,36 @@
+diff --git a/include/meson.build b/include/meson.build
+index f76f557..dfca3c3 100644
+--- a/include/meson.build
++++ b/include/meson.build
+@@ -153,10 +153,10 @@ conf_data.set('BUSFAULT', conf_data.get('HAVE_SIGACTION'))
+ conf_data.set('_XTYPEDEF_POINTER', '1')
+ conf_data.set('_XITYPEDEF_POINTER', '1')
+ 
++conf_data.set('LISTEN_TCP', get_option('listen_tcp'))
++conf_data.set('LISTEN_UNIX', get_option('listen_unix'))
++conf_data.set('LISTEN_LOCAL', get_option('listen_local'))
+ # XXX: Configurable?
+-conf_data.set('LISTEN_TCP', '1')
+-conf_data.set('LISTEN_UNIX', '1')
+-conf_data.set('LISTEN_LOCAL', '1')
+ conf_data.set('XTRANS_SEND_FDS', '1')
+ 
+ conf_data.set('TCPCONN', '1')
+diff --git a/meson_options.txt b/meson_options.txt
+index 86fca46..3453b8d 100644
+--- a/meson_options.txt
++++ b/meson_options.txt
+@@ -45,6 +45,13 @@ option('vendor_name_short', type: 'string', value: 'X.Org')
+ option('vendor_web', type: 'string', value: 'http://wiki.x.org')
+ option('os_vendor', type: 'string', value: '')
+ 
++option('listen_tcp', type: 'boolean', value: false,
++       description: 'Listen on TCP by default')
++option('listen_unix', type: 'boolean', value: true,
++       description: 'Listen on Unix by default')
++option('listen_local', type: 'boolean', value: true,
++       description: 'Listen on local by default')
++
+ option('int10', type: 'combo', choices: ['stub', 'x86emu', 'vm86', 'auto', 'false'],
+        value: 'auto',
+        description: 'Xorg int10 backend (default: usually x86emu)')
diff --git a/xserver-modesetting-use-drmmode_bo_import-for-rotate_fb.patch b/xserver-modesetting-use-drmmode_bo_import-for-rotate_fb.patch
new file mode 100644
index 0000000..5913e44
--- /dev/null
+++ b/xserver-modesetting-use-drmmode_bo_import-for-rotate_fb.patch
@@ -0,0 +1,18 @@
+diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
+index 859a21a9d..ec11b3f56 100644
+--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
+@@ -1794,11 +1794,8 @@ drmmode_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
+         return NULL;
+     }
+ 
+-    ret = drmModeAddFB(drmmode->fd, width, height, crtc->scrn->depth,
+-                       drmmode->kbpp,
+-                       drmmode_bo_get_pitch(&drmmode_crtc->rotate_bo),
+-                       drmmode_bo_get_handle(&drmmode_crtc->rotate_bo),
+-                       &drmmode_crtc->rotate_fb_id);
++    ret = drmmode_bo_import(drmmode, &drmmode_crtc->rotate_bo,
++                            &drmmode_crtc->rotate_fb_id);
+ 
+     if (ret) {
+         ErrorF("failed to add rotate fb\n");
-- 
GitLab