intel: If a non-root user starts X, don't release master

SET_MASTER and DROP_MASTER are only available to the root user. If we
are started as an ordinary user, and we are master by virtue of being
the first user of the device, never release our fd or master.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-04-09 18:51:23 +01:00
parent dba43d370b
commit e0c93a3e53
1 changed files with 16 additions and 0 deletions

View File

@ -270,6 +270,18 @@ static int get_fd(struct xf86_platform_device *dev)
}
#endif
static int is_master(int fd)
{
drmSetVersion sv;
sv.drm_di_major = 1;
sv.drm_di_minor = 1;
sv.drm_dd_major = -1;
sv.drm_dd_minor = -1;
return drmIoctl(fd, DRM_IOCTL_SET_VERSION, &sv) == 0;
}
int intel_open_device(int entity_num,
const struct pci_device *pci,
struct xf86_platform_device *platform)
@ -316,6 +328,10 @@ int intel_open_device(int entity_num,
if (hosted())
master_count++;
/* Non-root user holding MASTER, don't let go */
if (geteuid() && is_master(fd))
master_count++;
dev->fd = fd;
dev->open_count = master_count;
dev->master_count = master_count;