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ˆƒ|S)NZ_slip_polkit_auth_required)Ú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 <scs6‡‡‡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, ...): ...cs 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_proxyNcs tˆ|ƒS)N)r)r)r#rrÚdecorate”szenable_proxy..decorate)r)rr"r!r r$r)r#r r!r"rr@s 6  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&rrr)¡s zNotAuthorizedException.__init__)rrrÚ__doc__r'r)Ú __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_namer-Ú _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)r-r/rZ SystemBusZadd_signal_receiverr4r.r0)r*rrrÚ_bus½s  z PolKit._buscCstjs|jjƒt_tjS)N)r-Ú_PolKit__bus_namer5Zget_unique_name)r*rrrÚ _bus_nameÈs zPolKit._bus_namec CsFtjs@y"tj|jj|j|jƒ|jƒt_Wntj k r>YnXtjS)N) r-r1rÚ Interfacer5Ú get_objectr.Ú _dbus_pathÚ_dbus_interfacer)r*rrrÚ _interfaceÎs  zPolKit._interfacecCs t|jƒS)N)Úboolr<)r*rrrÚ_polkit_presentÙszPolKit._polkit_presentc Cs>|jjddƒ}tj|dƒ}y|j|ƒ}Wnd}YnX|S)Nzorg.freedesktop.DBusz/org/freedesktop/DBus)r5r9rr8ZGetConnectionUnixUser)r*Ú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-namer3rÚ)r>r<ÚCheckAuthorizationr7)r*Z 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)r*rrÚûsz4PolKit.AreAuthorizationsObtainable..)r>Ú isinstanceÚtupleÚlistÚsetr)r*ÚauthorizationsZ obtainabler)r*rr òs z"PolKit.AreAuthorizationsObtainableTc sd|js ˆ|dkp|j|ƒdkƒSd}|r0|dO}‡fdd„}|jjdd|if|||d||td�dS) Nrrcs|\}}}ˆ|ƒdS)Nr)ÚargsrBrCrD)Ú reply_handlerrrÚreply_cb s z7PolKit.IsSystemBusNameAuthorizedAsync..reply_cbzsystem-bus-namer3r@)rOÚ error_handlerZtimeout)r>Ú!_PolKit__dbus_system_bus_name_uidr<rAr) r*r?rrOrQÚ challengerDÚflagsrPr)rOrr s   z%PolKit.IsSystemBusNameAuthorizedAsync)rrrr+r.r:r;r1r/r6r0Ú classmethodr4Úpropertyr5r7r<r>rRrEr r rrrrr-¨s"     r-cCs tj|ƒS)N)Ú__polkitr )rMrrrr sTcCstj||||||ƒS)N)rWr )r?rrOrQrSrDrrrr s )r+Z __future__rÚ collectionsrrÚ functoolsrZ constantsrÚ__all__rrÚobjectr rrr r-rWr r rrrrÚs(     Wo