summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Nagy <robert@cvs.openbsd.org>2020-12-21 09:06:15 +0000
committerRobert Nagy <robert@cvs.openbsd.org>2020-12-21 09:06:15 +0000
commit0416214f76d23c09447eb2c6b3a85274b6612ad4 (patch)
tree32a4331a4c6446741d01c66dec93704bf1fa33a8
parent961d060510d3671457787d39fde3a0666bb69c79 (diff)
unbreak DRI3 support by using priv_open_device() to open the devices
priv_open_device() has to be used in case the X server is running privilege separated ok kettenis@, jsg@, matthieu@
-rw-r--r--driver/xf86-video-amdgpu/src/amdgpu_dri3.c10
-rw-r--r--driver/xf86-video-ati/src/radeon_dri3.c10
2 files changed, 16 insertions, 4 deletions
diff --git a/driver/xf86-video-amdgpu/src/amdgpu_dri3.c b/driver/xf86-video-amdgpu/src/amdgpu_dri3.c
index ed1e2f967..09e21126f 100644
--- a/driver/xf86-video-amdgpu/src/amdgpu_dri3.c
+++ b/driver/xf86-video-amdgpu/src/amdgpu_dri3.c
@@ -41,6 +41,12 @@
#include <errno.h>
#include <libgen.h>
+#ifdef X_PRIVSEP
+extern int priv_open_device(const char *);
+#else
+#define priv_open_device(n) open(n,O_RDWR|O_CLOEXEC)
+#endif
+
static int open_master_node(ScreenPtr screen, int *out)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
@@ -49,7 +55,7 @@ static int open_master_node(ScreenPtr screen, int *out)
drm_magic_t magic;
int fd;
- fd = open(info->dri2.device_name, O_RDWR | O_CLOEXEC);
+ fd = priv_open_device(info->dri2.device_name);
if (fd < 0)
return BadAlloc;
@@ -93,7 +99,7 @@ static int open_render_node(ScreenPtr screen, int *out)
AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
int fd;
- fd = open(pAMDGPUEnt->render_node, O_RDWR | O_CLOEXEC);
+ fd = priv_open_device(pAMDGPUEnt->render_node);
if (fd < 0)
return BadAlloc;
diff --git a/driver/xf86-video-ati/src/radeon_dri3.c b/driver/xf86-video-ati/src/radeon_dri3.c
index f8f91c4b4..fc74d7e0f 100644
--- a/driver/xf86-video-ati/src/radeon_dri3.c
+++ b/driver/xf86-video-ati/src/radeon_dri3.c
@@ -41,6 +41,12 @@
#include <errno.h>
#include <libgen.h>
+#ifdef X_PRIVSEP
+extern int priv_open_device(const char *);
+#else
+#define priv_open_device(n) open(n,O_RDWR|O_CLOEXEC);
+#endif
+
static int open_master_node(ScreenPtr screen, int *out)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
@@ -49,7 +55,7 @@ static int open_master_node(ScreenPtr screen, int *out)
drm_magic_t magic;
int fd;
- fd = open(info->dri2.device_name, O_RDWR | O_CLOEXEC);
+ fd = priv_open_device(info->dri2.device_name);
if (fd < 0)
return BadAlloc;
@@ -93,7 +99,7 @@ static int open_render_node(ScreenPtr screen, int *out)
RADEONEntPtr pRADEONEnt = RADEONEntPriv(scrn);
int fd;
- fd = open(pRADEONEnt->render_node, O_RDWR | O_CLOEXEC);
+ fd = priv_open_device(pRADEONEnt->render_node);
if (fd < 0)
return BadAlloc;