If we have both root and DRM master then drop the latter because we
don't need both and holding onto it can interfere with running other
programs.

From a discussion with deltasquared on IRC.
---
It would be marginally better to check whether we have CAP_SYS_ADMIN rather 
than just whether we are effectively root, but the capabilities interface is a 
lot more complex to query and this is already sufficient to cover the reported 
case.

 libavdevice/kmsgrab.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavdevice/kmsgrab.c b/libavdevice/kmsgrab.c
index d0de774871..53280da0f5 100644
--- a/libavdevice/kmsgrab.c
+++ b/libavdevice/kmsgrab.c
@@ -263,6 +263,13 @@ static av_cold int kmsgrab_read_header(AVFormatContext 
*avctx)
     ctx->device = (AVHWDeviceContext*) ctx->device_ref->data;
     ctx->hwctx  = (AVDRMDeviceContext*)ctx->device->hwctx;
 
+    if (geteuid() == 0 && drmIsMaster(ctx->hwctx->fd)) {
+        // If we have both root and DRM master then drop the latter
+        // because we don't need both and holding onto it can interfere
+        // with running other programs.
+        drmDropMaster(ctx->hwctx->fd);
+    }
+
     err = drmSetClientCap(ctx->hwctx->fd,
                           DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
     if (err < 0) {
-- 
2.25.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to