Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ˆuAcI$ã@sÄdZddlmZddlZddlZddlmZddlmZddlm Z dd d d d d gZ dd„Z dZ Gdd „d e ƒZdeddfdd „ZGdd „d ejƒZGdd„de ƒZeƒZdd „Zdifdd „ZdS)zmThis module contains convenience decorators and functions for using PolicyKit with dbus services and clients.é)Úabsolute_importN)Ú decorator)Úreduceé)Úmethod_call_no_timeoutÚ require_authÚ enable_proxyÚAUTHFAIL_DONTCATCHÚNotAuthorizedExceptionÚAreAuthorizationsObtainableÚIsSystemBusNameAuthorizedAsynccs‡fdd„}|S)u‡Decorator for DBus service methods. Specify that a user needs a specific PolicyKit authorization `polkit_auth´ to execute it.cst|dƒst‚t|dˆƒ|S)NZ_dbus_is_methodZ_slip_polkit_auth_required)ÚhasattrÚAssertionErrorÚsetattr)Úmethod)Ú polkit_auth©ú/usr/lib/python3.6/polkit.pyÚrequire_auth_decorator/s z,require_auth..require_auth_decoratorr)rrr)rrr)s zBorg.fedoraproject.slip.dbus.service.PolKit.NotAuthorizedException.c@s eZdZdS)r N)Ú__name__Ú __module__Ú __qualname__rrrrr <scs”|dkst|tjƒst‚ˆdtfks0ˆdks0t‚ˆdksHtˆtjƒsHt‚ˆdks^tˆtƒs^t‚‡‡‡fdd„‰|dk r€tˆ|ƒS‡fdd„}|SdS)u”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, ...): ...Ncs y |||ŽStjk rš}zr|jƒ}|jtƒs2‚|ttƒd…}ˆdk rTˆ|d�ˆdk r‚yˆ|d�}Wnˆƒ}YnX|‚ˆtkrŒ‚ˆSd}~XnXdS)N)Ú action_id)ÚdbusÚ DBusExceptionZ get_dbus_nameÚ startswithÚAUTH_EXC_PREFIXÚlenr )ÚfuncÚpÚkÚeZexc_namerZaf_exc)Úauthfail_callbackÚauthfail_exceptionÚauthfail_resultrrÚ _enable_proxyvs$    z#enable_proxy.._enable_proxycs tˆ|ƒS)N)r)r)r%rrÚdecorate”szenable_proxy..decorate)Ú isinstanceÚ collectionsÚCallablerr Ú issubclassÚ Exceptionr)rr$r#r"r&r)r%r"r#r$rr@s*    cs$eZdZdZdZ‡fdd„Z‡ZS)r zqException which a DBus service method throws if an authorization required for executing it can't be obtained.zAorg.fedoraproject.slip.dbus.service.PolKit.NotAuthorizedExceptioncs(|jjd||_tt|ƒj||ŽdS)NÚ.)Ú __class__Ú_dbus_error_nameÚsuperr Ú__init__)Úselfrrr )r-rrr0¡s zNotAuthorizedException.__init__)rrrÚ__doc__r.r0Ú __classcell__rr)r-rr ™sc@sŽeZdZdZdZdZdZdZdZdZ dZ e dd„ƒZ e dd „ƒZe d d „ƒZe d d „ƒZe dd„ƒZdd„Zdd„Zdd„Zdifdd„ZdS)ÚPolKitz"Convenience wrapper around polkit.zorg.freedesktop.PolicyKit1z%/org/freedesktop/PolicyKit1/Authorityz$org.freedesktop.PolicyKit1.AuthorityNcCs4||jkr0tjr0tjjtjƒdt_dt_dt_dS)N)Ú _dbus_namer4Ú _PolKit__busZremove_signal_receiverÚ_PolKit__signal_receiverÚ_PolKit__interface)ÚclsÚnameZ old_ownerZ new_ownerrrrÚ_on_name_owner_changedµs zPolKit._on_name_owner_changedcCs0tjs*tjƒt_tjj|jdd|jd�t_tjS)NZNameOwnerChangedzorg.freedesktop.DBus)Zhandler_functionZ signal_nameZdbus_interfaceZarg0)r4r6rZ SystemBusZadd_signal_receiverr;r5r7)r1rrrÚ_bus½s  z PolKit._buscCstjs|jjƒt_tjS)N)r4Ú_PolKit__bus_namer<Zget_unique_name)r1rrrÚ _bus_nameÈs zPolKit._bus_namec CsFtjs@y"tj|jj|j|jƒ|jƒt_Wntj k r>YnXtjS)N) r4r8rÚ Interfacer<Ú get_objectr5Ú _dbus_pathÚ_dbus_interfacer)r1rrrÚ _interfaceÎs  zPolKit._interfacecCs t|jƒS)N)ÚboolrC)r1rrrÚ_polkit_presentÙszPolKit._polkit_presentc Cs>|jjddƒ}tj|dƒ}y|j|ƒ}Wnd}YnX|S)Nzorg.freedesktop.DBusz/org/freedesktop/DBus)r<r@rr?ZGetConnectionUnixUser)r1Úsystem_bus_nameZ bus_objectZ bus_interfaceZuidrrrZ__dbus_system_bus_name_uidÝs  z!PolKit.__dbus_system_bus_name_uidcCs6|js dS|jjdd|jif|iddƒ\}}}|p4|S)NTzsystem-bus-namer:rÚ)rErCÚCheckAuthorizationr>)r1Z authorizationÚ is_authorizedÚ is_challengeÚdetailsrrrZ__authorization_is_obtainableçs  z$PolKit.__authorization_is_obtainablecs8ˆjs dSt|tttfƒs |f}t‡fdd„|dƒ}|S)NTcs|o ˆj|ƒS)N)Ú$_PolKit__authorization_is_obtainable)ÚxÚy)r1rrÚûsz4PolKit.AreAuthorizationsObtainable..)rEr'ÚtupleÚlistÚsetr)r1ÚauthorizationsZ obtainabler)r1rr òs z"PolKit.AreAuthorizationsObtainableTc sd|js ˆ|dkp|j|ƒdkƒSd}|r0|dO}‡fdd„}|jjdd|if|||d||td�dS) Nrrcs|\}}}ˆ|ƒdS)Nr)ÚargsrIrJrK)Ú reply_handlerrrÚreply_cb s z7PolKit.IsSystemBusNameAuthorizedAsync..reply_cbzsystem-bus-namer:rG)rUÚ error_handlerZtimeout)rEÚ!_PolKit__dbus_system_bus_name_uidrCrHr) r1rFrrUrWÚ challengerKÚflagsrVr)rUrr s   z%PolKit.IsSystemBusNameAuthorizedAsync)rrrr2r5rArBr8r6r=r7Ú classmethodr;Úpropertyr<r>rCrErXrLr r rrrrr4¨s"     r4cCs tj|ƒS)N)Ú__polkitr )rSrrrr sTcCstj||||||ƒS)N)r]r )rFrrUrWrYrKrrrr s )r2Z __future__rr(rrÚ functoolsrZ constantsrÚ__all__rrÚobjectr rrr r4r]r r rrrrÚs(     Wo