sna: Check for access to backlight interface

Before attaching properties to any connector, check that we can indeed
control the backlight through the sysfs interface by doing an access
check. If the xserver is started without root privileges, we cannot
write through /sys/class/backlight and so should take care not to
advertise that we can.

Reported-by: Hans de Geode <hdegeode@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-02-13 16:18:43 +00:00
parent 83d17cded8
commit 611490a176
1 changed files with 8 additions and 0 deletions

View File

@ -447,6 +447,14 @@ sna_output_backlight_get_max(xf86OutputPtr output)
char path[1024], val[BACKLIGHT_VALUE_LEN];
int fd, max = 0;
/* We are used as an initial check to see if we can
* control the backlight, so first test if we can set values.
*/
sprintf(path, "%s/%s/brightness",
BACKLIGHT_CLASS, sna_output->backlight_iface);
if (access(path, R_OK | W_OK))
return -1;
sprintf(path, "%s/%s/max_brightness",
BACKLIGHT_CLASS, sna_output->backlight_iface);
fd = open(path, O_RDONLY);