This file is indexed.

/usr/share/aptdaemon/tests/fake-polkitd.py is in python3-aptdaemon.test 1.1.1-1ubuntu5.

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
#!/usr/bin/python3
"""Fake a PolicyKit daemon."""

from optparse import OptionParser
import sys

import dbus
import dbus.mainloop.glib
import dbus.service
from gi.repository import GLib

# Setup the DBus main loop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)


class FakePolicyKitDaemon(dbus.service.Object):

    def __init__(self, allowed_actions):
        self.allowed_actions = allowed_actions
        bus_name = dbus.service.BusName("org.freedesktop.PolicyKit1",
                                        dbus.SystemBus(),
                                        do_not_queue=True)
        dbus.service.Object.__init__(self, bus_name,
                                     "/org/freedesktop/PolicyKit1/Authority")
        self.loop = GLib.MainLoop()

    def run(self):
        self.loop.run()

    @dbus.service.method("org.freedesktop.PolicyKit1.Authority",
                         in_signature='(sa{sv})sa{ss}us',
                         out_signature='(bba{ss})')
    def CheckAuthorization(self, subject, action_id, details, flags,
                           cancellation_id):
        if "all" in self.allowed_actions:
            allowed = True
        else:
            allowed = action_id in self.allowed_actions
        challenged = False
        details = {"test": "test"}
        return (allowed, challenged, details)

    @dbus.service.method("org.freedesktop.PolicyKit1.Authority",
                         in_signature='', out_signature='')
    def Quit(self):
        GLib.idle_add(self._quit)

    def _quit(self):
        self.loop.quit()
        sys.exit()


def main():
    parser = OptionParser()
    parser.add_option("-a", "--allowed-actions",
                      default="", action="store", type="string",
                      dest="allowed_actions",
                      help="Comma separated list of allowed action ids")
    options, args = parser.parse_args()
    polkitd = FakePolicyKitDaemon(options.allowed_actions.split(","))
    polkitd.run()

if __name__ == "__main__":
    main()