diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-04-09 18:51:23 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-04-09 18:55:18 +0100 |
commit | e0c93a3e53a624beb5d3a15631237ac33b8c92cd (patch) | |
tree | 7fd6217b51bff8ef27a16ed7df08a9f57f2ccf2f | |
parent | dba43d370b984e262f6fe5920b38b433f4bd392b (diff) |
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>
-rw-r--r-- | src/intel_device.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/intel_device.c b/src/intel_device.c index a55f62b2..43372284 100644 --- a/src/intel_device.c +++ b/src/intel_device.c @@ -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; |