a ]i @ s, d dl Z d dlZej ZG dd dZdS ) Nc @ s e Zd Zdd Zdd ZdS )polkitc C s4 t | _| jjdddd| _t j| jdd| _d S )Nzorg.freedesktop.PolicyKit1z%/org/freedesktop/PolicyKit1/AuthorityT)Zfollow_name_owner_changesz$org.freedesktop.PolicyKit1.Authority)Zdbus_interface)dbusZ SystemBus_busZ get_object_proxyZ Interface _authority)self r 6/usr/lib/python3.9/site-packages/tuned/utils/polkit.py__init__ s zpolkit.__init__c C s |du s|du rdS i }d}d}dd|if}z| j |||||d }W n tjjtf y } ztd| z| j |} W nB tjjy } z&td | W Y d}~W Y d}~d S d}~0 0 | dkrW Y d}~dS W Y d}~dS W Y d}~n d}~0 0 |rdS dS ) zCheck authorization, return codes: 1 - authorized 2 - polkit error, but authorized with fallback method 0 - unauthorized -1 - polkit error and unauthorized by the fallback method -2 - polkit error and unable to use the fallback method NF zsystem-bus-namenamer zerror querying polkit: %sz-error using fallback authorization method: %s ) r ZCheckAuthorizationr exceptionsZ DBusException ValueErrorlogerrorr Z get_unix_user) r ZsenderZ action_iddetailsflagsZcancellation_idZsubjectreteuidr r r check_authorization s&