3 À<×e˜ ã @ s, d dl Z d dlZejjƒ ZG dd„ dƒZdS )é Nc @ s e Zd Zdd„ Zdd„ ZdS )Úpolkitc C s4 t jƒ | _| 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 ú/usr/lib/python3.6/polkit.pyÚ__init__ s zpolkit.__init__c C sâ |dks|dkrdS i }d}d}dd|if}y| j j|||||ƒd }W nŒ tjjtfk rÔ } zhtjd| ƒ y| jj |ƒ} W n2 tjjk r² } ztjd | ƒ dS d}~X nX | dkrÀd S dS W Y dd}~X nX |rÞdS 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_idZdetailsÚflagsZcancellation_idZsubjectÚretÚeZuidr r r Úcheck_authorization s&