aboutsummaryrefslogtreecommitdiff
path: root/render/allocator
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-09-03 10:03:27 +0200
committerSimon Zeni <simon@bl4ckb0ne.ca>2021-09-03 11:44:12 -0400
commit7df2ae88facad7e8e186261750645ce51a898993 (patch)
tree74e61dea1391291e1e0bd64b67b5d04daec390c2 /render/allocator
parent00c2bae1d3569f76cf318be789679dd50401577c (diff)
render/allocator: use legacy authentication for primary nodes
Closes: https://github.com/swaywm/wlroots/issues/3156
Diffstat (limited to 'render/allocator')
-rw-r--r--render/allocator/allocator.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/render/allocator/allocator.c b/render/allocator/allocator.c
index affc928e..23b2aca5 100644
--- a/render/allocator/allocator.c
+++ b/render/allocator/allocator.c
@@ -35,8 +35,31 @@ static int reopen_drm_node(int drm_fd) {
int new_fd = open(name, O_RDWR | O_CLOEXEC);
if (new_fd < 0) {
wlr_log_errno(WLR_ERROR, "Failed to open DRM node '%s'", name);
+ free(name);
+ return -1;
}
+
free(name);
+
+ // If we're using a DRM primary node (e.g. because we're running under the
+ // DRM backend, or because we're on split render/display machine), we need
+ // to use the legacy DRM authentication mechanism to have the permission to
+ // manipulate buffers.
+ if (drmGetNodeTypeFromFd(new_fd) == DRM_NODE_PRIMARY) {
+ drm_magic_t magic;
+ if (drmGetMagic(new_fd, &magic) < 0) {
+ wlr_log_errno(WLR_ERROR, "drmGetMagic failed");
+ close(new_fd);
+ return -1;
+ }
+
+ if (drmAuthMagic(drm_fd, magic) < 0) {
+ wlr_log_errno(WLR_ERROR, "drmAuthMagic failed");
+ close(new_fd);
+ return -1;
+ }
+ }
+
return new_fd;
}