%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.9/site-packages/cockpit/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.9/site-packages/cockpit/__pycache__/polkit.cpython-39.pyc

a

��j�!�@s�ddlZddlZddlZddlZddlZddlmZmZmZm	Z	ddl
mZddlm
Z
mZdZdZdZe�e�Ze	eeee
ffZGdd	�d	ej�ZGd
d�d�ZdS)�N)�Dict�List�Sequence�Tuple)�AskpassHandler)�Variant�busz/run/polkit/agent-helper.socketz'/usr/lib/polkit-1/polkit-agent-helper-1z/PolkitAgentc	s�eZdZed��fdd�Zej�dgd��eeee	eefee
edd�dd	��Zeedd
�dd�Z
eedd
�d
d�Zejejdd�dd�Z�ZS)�.org_freedesktop_PolicyKit1_AuthenticationAgent��	respondercst���||_dS�N)�super�__init__r��selfr��	__class__��2/usr/lib/python3.9/site-packages/cockpit/polkit.pyr&s
z7org_freedesktop_PolicyKit1_AuthenticationAgent.__init__�)�srrza{ss}rz	a(sa{sv})N)�	action_id�message�	icon_name�details�cookie�
identities�returnc	�s�t�d||||||�t��}|D]8\}}	|dkr"d|	vr"|	dj|kr"t�d|	|�qlq"t�d|�dSt�|�j}
z|�	|
|�IdHWn.t
y�t�d�|�|
|�IdHYn0dS)Nz[BeginAuthentication: action %s, message "%s", icon %s, details %s, cookie %s, identities %rz	unix-user�uidz,Authentication subject %s matches our uid %dz*Not supporting authentication as any of %sz:Socket helper not available, falling back to legacy helper)�logger�debug�os�geteuid�value�warning�pwd�getpwuid�pw_name�_authenticate_socket�OSError�_authenticate_suid_helper)rrrrrrrZmy_uidZ	auth_type�subject�	user_namerrr�begin_authentication+s �
zCorg_freedesktop_PolicyKit1_AuthenticationAgent.begin_authentication)r,rrc�st�dt�tjt||tjjtjjd�IdH}|jdus<J�|jdusJJ�zxz|�	|j|j�IdHWntj
y�t�d�Yn0Wz|��Wnty�Yn0|�
�IdH}t�d|�n<z|��Wnty�Yn0|�
�IdH}t�d|�0dS)z.Authenticate using legacy setuid helper binaryz!Trying legacy polkit helper at %s)�stdin�stdoutN�Cancelled authenticationzhelper exited with code %i)rr �HELPER_PATH�asyncioZcreate_subprocess_exec�
subprocess�PIPEr.r/�_communicate�CancelledErrorZ	terminate�ProcessLookupError�wait)rr,rZprocess�resrrrr*Es.
��zHorg_freedesktop_PolicyKit1_AuthenticationAgent._authenticate_suid_helperc	�s�t�dt�t�t�IdH\}}z�z>|�|�d|�d����|��IdH|�||�IdHWntj	y~t�d�Yn0W|�
�|��IdHt�d�n"|�
�|��IdHt�d�0dS)z:Authenticate using socket-activated helper (polkit >= 127)z+Trying socket-activated polkit helper at %sN�
r0zsocket connection closed)rr �
HELPER_SOCKETr2Zopen_unix_connection�write�encode�drainr5r6�closeZwait_closed)rr,r�reader�writerrrrr(Zs�zCorg_freedesktop_PolicyKit1_AuthenticationAgent._authenticate_socket)r.r/rc	�s:g}|2�z(3dHW}t�d|�|�����d�\}}}|�d�r�|�d�rRd}|j�d�|�|d�IdH}|�	�|dur�t�d|�t
�d��t�d	|�|�|�
��|�d
�~|��IdHt�d�q|dvr�|�|�q|d
k�rt�d��q6q|dk�r t�d��q6qt�d|��q6q6dS)NzRead line from helper: %s� Z
PAM_PROMPTZPasswordrr:z/got PAM_PROMPT %s, but do_askpass returned Nonezno password givenz1got PAM_PROMPT %s, do_askpass returned a password�
z(got PAM_PROMPT, wrote password to helper)Z
PAM_TEXT_INFOZ	PAM_ERROR�SUCCESSzAuthentication succeeded�FAILUREzAuthentication failedz&Unknown line from helper, aborting: %s)rr �strip�decode�	partition�
startswithrZ
do_askpass�join�clearr2r6r<r=r>�appendr$)	rr.r/�messages�lineZcommand�_r#�passwdrrrr5ks8







z;org_freedesktop_PolicyKit1_AuthenticationAgent._communicate)�__name__�
__module__�__qualname__rrrZ	InterfaceZMethod�strrr�Identityr-r*r(r2�StreamWriter�StreamReaderr5�
__classcell__rrrrr	%s�r	c@s.eZdZdZed�dd�Zdd�Zdd�Zd	S)
�PolkitAgentz}Register polkit agent when required

    Use this as a context manager to ensure that the agent gets unregistered again.
    r
cCs||_d|_dSr)r�
agent_slotrrrrr�szPolkitAgent.__init__c
�s�ztj��|_Wn4tyD}zt�d|�|WYd}~Sd}~00zddttj	dd�if|_
Wn ty�t�d�|YS0t
|j�}|j�t|�|_t�tjd�}|j�ddd	d
d|j
|t�IdHt�d|j
|�|S)
Nz>cannot connect to system bus, not registering polkit agent: %szunix-sessionz
session-idZXDG_SESSION_IDrz4XDG_SESSION_ID not set, not registering polkit agent�org.freedesktop.PolicyKit1�%/org/freedesktop/PolicyKit1/Authority�$org.freedesktop.PolicyKit1.AuthorityZRegisterAuthenticationAgentz
(sa{sv})ssz%Registered agent for %r and locale %s)rZBusZdefault_system�
system_busr)rr$rr!�environr+�KeyErrorr r	rZ
add_object�AGENT_DBUS_PATHrZ�locale�	setlocale�LC_MESSAGES�call_method_async)r�eZagent_objectZlocale_namerrr�
__aenter__�s.


�
zPolkitAgent.__aenter__c	�sB|jr>|j�ddddd|jt�IdH|j��t�d|j�dS)Nr[r\r]ZUnregisterAuthenticationAgentz	(sa{sv})szUnregistered agent for %r)rZr^rer+ra�cancelrr )rZ	_exc_typeZ
_exc_valueZ
_tracebackrrr�	__aexit__�s�

zPolkitAgent.__aexit__N)rQrRrS�__doc__rrrgrirrrrrY�srY)r2rbZloggingr!r%�typingrrrrZcockpit._vendor.fernyrZcockpit._vendor.systemd_ctypesrrr;r1raZ	getLoggerrQrrTrUZObjectr	rYrrrr�<module>s

m

Zerion Mini Shell 1.0