Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /usr/lib/python2.7/site-packages/slip/dbus/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/site-packages/slip/dbus/polkit.pyo
�
�i�Zc@s�dZddlZddlmZddlmZddddd	d
gZd�ZdZdefd
��YZ	de	ddd�Zdejfd��YZ
defd��YZe�Zd�Zeid�ZdS(smThis module contains convenience decorators and functions for using
PolicyKit with dbus services and clients.i����N(t	decorator(tmethod_call_no_timeouttrequire_authtenable_proxytAUTHFAIL_DONTCATCHtNotAuthorizedExceptiontAreAuthorizationsObtainabletIsSystemBusNameAuthorizedAsynccs�fd�}|S(s�Decorator for DBus service methods.

    Specify that a user needs a specific PolicyKit authorization `polkit_auth´
    to execute it.cst|d��|S(Nt_slip_polkit_auth_required(tsetattr(tmethod(tpolkit_auth(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pytrequire_auth_decorator)s((RR((Rs4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR#ssBorg.fedoraproject.slip.dbus.service.PolKit.NotAuthorizedException.cBseZRS((t__name__t
__module__(((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR4scsE���fd��|dk	r.t�|�S�fd�}|SdS(s�Decorator for DBus proxy methods.

    Let's you (optionally) specify either a result value or an exception type
    and a callback which is returned, thrown or called respectively if a
    PolicyKit authorization doesn't exist or can't be obtained in the DBus
    mechanism, i.e. an appropriate DBus exception is thrown.

    An exception constructor may and a callback must accept an `action_id´
    parameter which will be set to the id of the PolicyKit action for which
    authorization could not be obtained.

    Examples:

    1) Return `False´ in the event of an authorization problem, and call
    `error_handler´:

        def error_handler(action_id=None):
            print "Authorization problem:", action_id

        class MyProxy(object):
            @polkit.enable_proxy(authfail_result=False,
                                 authfail_callback=error_handler)
            def some_method(self, ...):
                ...

    2) Throw a `MyAuthError´ instance in the event of an authorization problem:

        class MyAuthError(Exception):
            def __init__(self, *args, **kwargs):
                action_id = kwargs.pop("action_id")
                super(MyAuthError, self).__init__(*args, **kwargs)
                self.action_id = action_id

        class MyProxy(object):
            @polkit.enable_proxy(authfail_exception=MyAuthError)
            def some_method(self, ...):
                ...cs�y|||�SWn�tjk
r�}|j�}|jt�sG�n|tt�}�dk	rs�d|�n�dk	r�y�d|�}Wn��}nX|�n�tkr��n�SXdS(Nt	action_id(tdbust
DBusExceptiont
get_dbus_namet
startswithtAUTH_EXC_PREFIXtlentNoneR(tfunctptktetexc_nameRtaf_exc(tauthfail_callbacktauthfail_exceptiontauthfail_result(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt
_enable_proxyds$
	cs
t�|�S(N(R(R(R (s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pytdecorate�sN(RR(RRRRR!((R RRRs4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR7s
-
cBseZdZdZd�ZRS(sqException which a DBus service method throws if an authorization
    required for executing it can't be obtained.sAorg.fedoraproject.slip.dbus.service.PolKit.NotAuthorizedExceptioncOs4|jjd||_tt|�j||�dS(Nt.(t	__class__t_dbus_error_nametsuperRt__init__(tselfRRR((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR&�s(R
Rt__doc__R$R&(((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR�stPolKitcBs�eZdZdZdZdZd
Zd
Zd
Z	d
Z
ed��Ze
d��Ze
d��Ze
d��Ze
d��Zd	�Zd
�Zd�Zeid�ZRS(s"Convenience wrapper around polkit.sorg.freedesktop.PolicyKit1s%/org/freedesktop/PolicyKit1/Authoritys$org.freedesktop.PolicyKit1.AuthoritycCsM||jkrItjrItjjtj�dt_dt_dt_ndS(N(t
_dbus_nameR)t_PolKit__bustremove_signal_receivert_PolKit__signal_receiverRt_PolKit__interface(tclstnamet	old_ownert	new_owner((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt_on_name_owner_changed�s
		cCsItjsBtj�t_tjjd|jdddd�t_ntjS(Nthandler_functiontsignal_nametNameOwnerChangedtdbus_interfacesorg.freedesktop.DBus(R)R+Rt	SystemBustadd_signal_receiverR3R-(R'((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt_bus�s		cCs%tjs|jj�t_ntjS(N(R)t_PolKit__bus_nameR:tget_unique_name(R'((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt	_bus_name�s	cCs[tjsTy1tj|jj|j|j�|j�t_WqTtj	k
rPqTXntjS(N(
R)R.Rt	InterfaceR:t
get_objectR*t
_dbus_patht_dbus_interfaceR(R'((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt
_interface�s	cCs
t|j�S(N(tboolRB(R'((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt_polkit_present�scCsN|jjdd�}tj|d�}y|j|�}Wn
d}nX|S(Nsorg.freedesktop.DBuss/org/freedesktop/DBus(R:R?RR>tGetConnectionUnixUserR(R'tsystem_bus_namet
bus_objectt
bus_interfacetuid((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt__dbus_system_bus_name_uid�s	
cCsN|js
tS|jjdi|jd6f|idd�\}}}|pM|S(Nssystem-bus-nameR0it(RDtTrueRBtCheckAuthorizationR=(R't
authorizationt
is_authorizedtis_challengetdetails((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt__authorization_is_obtainable�s		csG�js
tSt|t�r(|g}nt�fd�|t�}|S(Ncs|o�j|�S(N(t$_PolKit__authorization_is_obtainable(txty(R'(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt<lambda>�s(RDRLt
isinstancet
basestringtreduce(R'tauthorizationst
obtainable((R's4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR�s	c	
s�|js.�|dkp*|j|�dk�Sd}|rG|dO}n�fd�}|jjdi|d6f|||dd|d|d	t�dS(
Niics|\}}}�|�dS(N((targsRORPRQ(t
reply_handler(s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pytreply_cb�sssystem-bus-nameR0RKR]t
error_handlerttimeout(RDRt!_PolKit__dbus_system_bus_name_uidRBRMR(	R'RFRR]R_t	challengeRQtflagsR^((R]s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR�s	

N(R
RR(R*R@RARR.R+R;R-tclassmethodR3tpropertyR:R=RBRDRaRSRRLR(((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR)�s"
	
		cCs
tj|�S(N(t__polkitR(RZ((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyRscCstj||||||�S(N(RfR(RFRR]R_RbRQ((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyR
s(R(RRt	constantsRt__all__RRtobjectRRRRRR)RfRRLR(((s4/usr/lib/python2.7/site-packages/slip/dbus/polkit.pyt<module>s			On		

ZeroDay Forums Mini