backlight: Drop rights before executing pkexec
authorHans de Goede <hdegoede@redhat.com>
Mon, 17 Feb 2014 12:16:53 +0000 (13:16 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 17 Feb 2014 18:38:54 +0000 (18:38 +0000)
Event though we've failed to open the backlight normally, we may still be
running under a suid-root xserver, so drop any elevated rights before
executing what we hope will be pkxec.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/backlight.c

index 0501070..688819d 100644 (file)
@@ -295,9 +295,14 @@ static int __backlight_helper_init(struct backlight *b, char *iface)
 
        switch ((b->pid = fork())) {
        case 0:
+               if (setgid(getgid()) || setuid(getuid()))
+                       _exit(127);
+
                close(fds[1]);
-               dup2(fds[0], 0);
+               if (dup2(fds[0], 0))
+                       _exit(127);
                close(fds[0]);
+
                if (use_pkexec) {
                        execlp("pkexec", "pkexec",
                               LIBEXEC_PATH "/xf86-video-intel-backlight-helper",