%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/hplip/base/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/hplip/base/__pycache__/pkit.cpython-312.pyc

�

=	f�-��0�ddlZddlZddlZddl�ddl�ddlmZmZddlm	Z	ddl
Z
ddlZ
er	ddl
mZnddlmZddlZej$de�Gd�d	e
j(�ZGd
�de
j(�ZGd�d
e
j(�ZdZdZd�Zdd�ZGd�de�ZGd�de
j<j>�Z ejBe"jGdd��rGd�de �Z$Gd�de�Z%de&e'fd�Z(d�Z)y#ddlmZY��xYw) �N�)�*)�utils�password��
pluginhandler)�MainLoop�ignorec��eZdZdZy)�AccessDeniedExceptionz"com.hp.hplip.AccessDeniedExceptionN��__name__�
__module__�__qualname__�_dbus_error_name���/usr/share/hplip/base/pkit.pyrr3s��;�rrc��eZdZdZy)�UnsupportedExceptionz!com.hp.hplip.UnsupportedExceptionNr
rrrrr6s��:�rrc��eZdZdZy)�
UsageErrorzcom.hp.hplip.UsageErrorNr
rrrrr9s��0�rr�com.hp.hplipzcom.hp.hplip.installpluginc�*�tj�S�N)�dbus�	SystemBusrrr�get_service_busrAs���>�>��rc��|s
t�}|jtjd�}t	j
|tj�}|S�N�/)r�
get_object�BackendService�SERVICE_NAMEr�	Interface�INTERFACE_NAME)�bus�services  r�get_servicer)Es>�������n�n�^�8�8�#�>�G��n�n�W�n�&C�&C�D�G��Nrc�Z��eZdZ�fd�Zdd�Zdd�Zd�Zee�Zd�Z	ee	�Z
�xZS)�PolicyKitAuthenticationc�F��tt|��d|_d|_yr)�superr+�__init__�pkit�auth)�self�	__class__s �rr.z PolicyKitAuthentication.__init__Os���
�%�t�5�7���	���	rc���|dk(rtj�}tj|�}|jj||d�}tjd|�d|���|dk(S)NFzis_authorized(�) = �yes)�os�getpidr�UInt32�
policy_kit�IsProcessAuthorized�log�debug)r1�	action_id�pid�
authorizeds    r�
is_authorizedz%PolicyKitAuthentication.is_authorizedUsV���$�;��)�)�+�C��k�k�#����_�_�8�8��C��O�
��	�	�i��D�E��e�#�$rc�|�|j|�ry|xr$|j�jjxsd}t	j
|�t	j
t
j��}}|jj|||�}tjd|�d|���t|�S)NTrzobtain_authorization(r4)
r@�get_toplevel�window�xidrr8r6r7�
auth_agent�ObtainAuthorizationr;r<�bool)r1r=�widgetrDr>�granteds      r�obtain_authorizationz,PolicyKitAuthentication.obtain_authorizationas������i�(���:�&�-�-�/�6�6�:�:�?�a���;�;�s�#�T�[�[�����%=�S���/�/�5�5�i��c�J���	�	�Y��H�I��G�}�rc���|jr|jStj�jdd�}tj|d�|_|jS)Nzorg.freedesktop.PolicyKitr!)r/rrr"r%)r1r(s  r�get_policy_kitz&PolicyKitAuthentication.get_policy_kitnsJ���9�9��9�9���.�.�"�-�-�.I�3�O���N�N�7�,G�H��	��y�y�rc��|jr|jStj�jdd�|_|jS)Nz-org.freedesktop.PolicyKit.AuthenticationAgentr!)r0r�
SessionBusr")r1s r�get_auth_agentz&PolicyKitAuthentication.get_auth_agentys<���9�9��9�9���O�O�%�0�0�;�S�B��	��y�y�rr)rrrr.r@rJrL�propertyr9rOrE�
__classcell__�r2s@rr+r+Ns4����	%�
���.�)�J���.�)�Jrr+c� �eZdZefd�Zefd�Zy)�PolicyKitServicec���|s tjd�td��	t�}t	j
�}|j
dd�}t	j|d�}t	j|j|��}|j||�}|s tjd�td��|jj||d�}|dk7r tjd�td��y#t$rtjd��tj$r0}tjd	|�t|j��d}~wwxYw)
N�#Session not authorized by PolicyKitzorg.freedesktop.DBusr!z#Process not authorized by PolicyKitFr5z-Session not authorized by PolicyKit version 0rzAccessDeniedException %r)r;�errorrr+rrr"r%r8�GetConnectionUnixProcessIDr@r9�IsSystemBusNameAuthorized�warning�
DBusException�message)	r1�sender�action�policy_authr'�dbus_objectr>rI�exs	         r�check_permission_v0z$PolicyKitService.check_permission_v0�s5����I�I�;�<�'�(M�N�N�	4�1�3�K��.�.�"�C��.�.�)?��E�K��.�.��6L�M�K��+�+�k�D�D�V�L�M�C�!�/�/���<�G���	�	�?�@�+�,Q�R�R�!�,�,�F�F�v�GM�GL�N�G��%���	�	�I�J�+�,Q�R�R� ��%�	��K�K�/�0���!�!�	4��K�K�2�B�7�'��
�
�3�3��	4�s�C D�1E&�6+E!�!E&c��|r|s tjd�td��tj�}|jddd�}tj|d�}ddtj|d��if}d	d	i}tjd�}	d	}
|j||||	|
�\}}}|s tjd
�td��|S)NrVzorg.freedesktop.PolicyKit1z%/org/freedesktop/PolicyKit1/Authorityz$org.freedesktop.PolicyKit1.Authorityzsystem-bus-name�namer)�
variant_level�z-Session not authorized by PolicyKit version 1)
r;rWrrrr"r%�Stringr8�CheckAuthorization)
r1r]�
connectionr^�
system_bus�objr9�subject�details�flags�	cancel_id�ok�notuseds
             r�check_permission_v1z$PolicyKitService.check_permission_v1�s����Z��I�I�;�<�'�(M�N�N��^�^�%�
��#�#�$@�$K�$J�L���^�^�C�)O�P�
���t�{�{�6�1�=�?�
����+�����A����	�
�)�)�'�*0�*1�*/�*3�	
5�	��W�g���I�I�E�F�'�(M�N�N��	rN)rrr�POLICY_KIT_ACTIONrbrrrrrrTrT�s��1B� 4�F>O�rrT�	configure�
policy-kitc����eZdZdZdZd�fd�	Zdd�Zejjedddd��d
d	��Z
ejjedddd��d
d
��Z�xZS)r#rc���|�
t�}tt|�||�tj
j
|j|�|_t�|_
d|_tjd�y)Nrr<)rr-r#r.rr(�BusNamer$rdr	�loop�versionr;�	set_level)r1ri�pathr2s   �rr.zBackendService.__init__�s\����!�,�.�
��.�$�0��T�B����,�,�T�->�->�
�K�D�I� �
�D�I��D�L��M�M�'�"rc��|�"t�}|�tjd�y||_tj	d|z�|j
j
�y)N�/Unable to determine installed PolicyKit versionz+Starting back-end service loop (version %d))�policykit_versionr;rWrzr<ry�run�r1rzs  rr�zBackendService.run�sJ����+�-���?��I�I�O�P��"�D�L��I�I�C�g�M�N��I�I�M�M�Or�s�br]ri)�dbus_interface�in_signature�
out_signature�sender_keyword�connection_keywordc�F�|jdk(r	|j|t�nJ|jdk(r|j
||t�s$ytjd|jz�ytjd|z�	ddlm	}|j�}|j|�stjd	�yy
#t$r"}tjd|z�Yd}~yd}~wwxYw#t$r}tjd�Yd}~yd}~wwxYw)Nrz3installPlugin:  Failed due to permission error [%s]Frz+installPlugin: invalid PolicyKit version %dz#installPlugin: installing from '%s'rzFailed to Import pluginhandlerzPlugin installation failedT)
rzrb�INSTALL_PLUGIN_ACTIONrr;rWrrr<�	installerr�ImportError�PluginHandle�	copyFiles)r1�src_dirr]ri�er�	pluginObjs       r�
installPluginzBackendService.installPlugin�s��
�|�|�q� �!��,�,�V�5J�K�
����"��/�/��0:�0E�G�!��	�	�G�$�,�,�V�W���I�I�;�g�E�F�
�3�
3�
�2�2�4�I��&�&�w�/��	�	�6�7����5-�!��I�I�S�UV�V�W� ��!��"�
��	�	�:�;���
�s/�C
�C8�
	C5�C0�0C5�8	D �D�D c�b�tjd�|jj�y)NzStopping backend serviceT)r;r<ry�quit)r1�argr]ris    r�shutdownzBackendService.shutdowns"��

�I�I�0�1��I�I�N�N��rr r)NN)
rrrr&r$r.r�rr(�methodr�r�rQrRs@rr#r#�s����'��'��		#�
	�
���	�	�N�-0��/7�3?�
�
A�	�	
A�	�B
���	�	�N�-0��/7�3?�
�
A�	�	
A�	rr#c� �eZdZdd�Zd�Zd�Zy)�	PolicyKitNc�*�|�"t�}|�tjd�ytj�|_|j
j
td�|_tj|jt��|_
||_y)Nr~r!)r�)rr;r<rrr'r"rsrkr%�ifacerzr�s  rr.zPolicyKit.__init__si���?�'�)�G����	�	�K�L���>�>�#����8�8�&�&�'8�#�>����^�^�D�H�H�=N�O��
���rc�H�|jdk(r5t�}|jt�s|j	t�sy	|j
j
|�}|S#tj$r+}tjdt|�z�Yd}~yd}~wwxYw)NrzinstallPlugin: %sF)rzr+r@r�rJr�r�rr[r;r<�str)r1r�r0rpr�s     rr�zPolicyKit.installPlugin$s����<�<�1��*�,�D��%�%�&;�<��0�0�1F�G��	����)�)�'�2�B��I���!�!�	��I�I�)�C��F�2�3���	���A#�#B!�6!B�B!c�H�|jdk(r5t�}|jt�s|j	t�sy	|j
j
d�}|S#tj$r+}tjdt|�z�Yd}~yd}~wwxYw)Nrrfzshutdown: %sF)rzr+r@r�rJr�r�rr[r;r<r�)r1r0rpr�s    rr�zPolicyKit.shutdown3s����<�<�1��*�,�D��%�%�&;�<��0�0�1F�G��	����$�$�R�(�B��I���!�!�	��I�I�n�s�1�v�-�.���	�r�r)rrrr.r�r�rrrr�r�s��
��rr�Tc���tjtjdd��r$	t	�}d}d}t
j
d�d}|sd}tjd	�rd	}nd
}|�d|�d|��}	t
j
d|	z�tj|	�}
|
d
k(dfS#tj$r"}t
jd|z�Yd}~��d}~wwxYw)Nrtruz%sFz"Using PolicyKit for authenticationz5PolicyKit NOT installed when configured for use. [%s]z
--requiredz
--optionalz	hp-pluginzpython ./plugin.pyz -u z
 --reason rT)
r�to_bool�sys_conf�getr�r;r<rr[rW�which�os_utils�execute)�required�
plugin_reason�Moderk�su_sudo�	need_sudora�req�p_path�cmd�statuss           r�run_plugin_commandr�Es����}�}�X�\�\�+�|�<�=�	R��+�C��G��I��I�I�:�;��C�����{�{�;����#��#)�3�
�
>�C��I�I�d�S�j��
�
�
�c�
"�F��a�K�����!�!�!�	R��I�I�M�b�P�Q�Q��	R�s�#B,�,C!�?C�C!c��tjjd�rytjjd�ryy)Nz/usr/share/polkit-1rz/usr/share/PolicyKitr)r6r|�isdirrrrrr`s-��	�w�w�}�}�*�+��	�����-�	.��rr)*r6�os.path�sys�g�codesrfrrr�rr�dbus.service�PY3�gi._gobjectr	�gi.repository.GLib�gobject�warnings�simplefilter�DeprecationWarningr[rrrrsr�rr)�objectr+r(�ObjectrTr�r�r�r#r��PLUGIN_REASON_NONE�GUI_MODEr�rrrr�<module>r�s��.
��
����#����0�(�!������h� 2�3�<�D�.�.�<�;�4�-�-�;�1��#�#�1�#��4����3*�f�3*�nA�t�|�|�*�*�A�H�5�=�=����k�<�8�9�I�)�I�Z(��(�\!%�4F�x��6��q	0�/�s�D�D

Zerion Mini Shell 1.0