File: //lib/python3.12/site-packages/tuned/utils/__pycache__/polkit.cpython-312.pyc
�
�]�i� � �\ � d dl Z d dlZej j � Z G d� d� Zy)� Nc � � e Zd Zd� Zd� Zy)�polkitc �� � t j � | _ | j j ddd�� | _ t j
| j d�� | _ y )Nzorg.freedesktop.PolicyKit1z%/org/freedesktop/PolicyKit1/AuthorityT)�follow_name_owner_changesz$org.freedesktop.PolicyKit1.Authority)�dbus_interface)�dbus� SystemBus�_bus�
get_object�_proxy� Interface�
_authority)�selfs �7/usr/lib/python3.12/site-packages/tuned/utils/polkit.py�__init__zpolkit.__init__ sN � ��n�n��$�)�� � �$�$�%A�Cj� IM�$� N�$�+��N�N�4�;�;�?e�f�$�/� c �� � |�|�yi }d}d}dd|if} | j j |||||� d }|rdS dS # t j j t
f$ r�}t j d|z � | j j |� } nF# t j j $ r&}t j d |z � Y d}~Y d}~y
d}~ww xY w| dk( rY d}~yY d}~yd}~ww xY w)
z�Check 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-name�namer zerror querying polkit: %sz-error using fallback authorization method: %s���� ���)
r �CheckAuthorizationr �
exceptions�
DBusException�
ValueError�log�errorr
�
get_unix_user)
r �sender� action_id�details�flags�cancellation_id�subject�ret�e�uids
r �check_authorizationzpolkit.check_authorization s� � � �^�y�(�
��'�
�%��/�
��&� 1�2�'�
�
��� +� +�G�Y���P_� `�ab� c�3� ���q��� �/�/�
'�
'�� 4� ��9�9�
(�1�
,�-��
�)�)�
!�
!�&�
)�C��
�/�/�
'�
'� ��I�I�=��A�B�
�2����
�Q�h��
���s? �"; �#C-�C(�7B�C(�C�0C�C(�C�C(�(C-N)�__name__�
__module__�__qualname__r r* � r r r r s
� �g�
r r )r �
tuned.logs�tuned�logs�getr r r. r r �<module>r3 s% �� � ��j�j�n�n���#� #r