관리-도구
편집 파일: polkit.cpython-39.pyc
a ,�g� � @ s, d dl Z d dlZej�� ZG dd� d�ZdS )� 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� } z�t�d| � z| j� |�} W nB tjjy� } z&t�d | � W Y d}~W Y d}~d S d}~0 0 | dkr�W Y d}~dS W Y d}~dS W Y d}~n d}~0 0 |�rdS dS ) 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 ZCheckAuthorizationr � exceptionsZ DBusException� ValueError�log�errorr Z get_unix_user) r ZsenderZ action_id�details�flagsZcancellation_idZsubject�ret�e�uidr r r �check_authorization s&