This file is indexed.

/usr/bin/sugar-backlight-setup is in sugar-session 0.106.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python

# Copyright (C) 2015 Martin Abente Lahaye <tch@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import os
import sys
from functools import cmp_to_key

from gi.repository import GUdev


class SugarBacklightSetup:

    SUGAR_LINK = '/var/run/sugar-backlight'

    def __init__(self):
        self._path = None
        self._get_best_backlight()
        self._create_link()

    def _get_best_backlight(self):
        client = GUdev.Client()
        devices = client.query_by_subsystem('backlight')

        if not devices:
            raise LookupError('No backlight devices present')

        devices.sort(key=cmp_to_key(SugarBacklightSetup._sort_criteria))
        self._path = devices[0].get_sysfs_path()

    @staticmethod
    def _sort_criteria(ldevice, rdevice):
        if ldevice.get_sysfs_attr('type') == 'firmware':
            return 1
        if ldevice.get_sysfs_attr('type') == 'platform' and \
           rdevice.get_sysfs_attr('type') == 'raw':
            return 1
        return -1

    def _create_link(self):
        if os.path.exists(self.SUGAR_LINK):
            os.unlink(self.SUGAR_LINK)
        os.symlink(self._path, self.SUGAR_LINK)


def _main():
    try:
        SugarBacklightSetup()
    except Exception as err:
        print 'Could not create device link: %s' % str(err)
        sys.exit(1)

if __name__ == '__main__':
    _main()