How to get root suggestions for my application?

My application should do some privileged work. I searched everywhere, but I can not find anything useful. I know that I want to use Policykit1 and dbus, because all the other alternatives that I found are no longer used.

This is the code I got so far:

import dbus
import os

bus = dbus.SystemBus()
proxy = bus.get_object('org.freedesktop.PolicyKit1', '/org/freedesktop/PolicyKit1/Authority')
authority = dbus.Interface(proxy, dbus_interface='org.freedesktop.PolicyKit1.Authority')

system_bus_name = bus.get_unique_name()

subject = ('system-bus-name', {'name' : system_bus_name})
action_id = 'org.freedesktop.policykit.exec'
details = {}
flags = 1            # AllowUserInteraction flag
cancellation_id = '' # No cancellation i


result = authority.CheckAuthorization(subject, action_id, details, flags, cancellation_id)

os.makedirs('/usr/local/share/somefolder')

I cannot create a directory, what am I doing wrong?

+3
source share
1 answer

, /usr/local/share/somefolder. sudo . , .

-, , root (, sudo), sudo ./myscript.py.

+1

Source: https://habr.com/ru/post/1753975/


All Articles