JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/firewall/server/__pycache__/decorators.cpython-39.pyc

a

	�	i��@s�dZgd�ZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZmZdd	lmZd
d�Zdd
�Zdd�ZGdd�d�ZGdd�de�ZGdd�d�ZdS)z>This module contains decorators for use with and without D-Bus)�handle_exceptions�dbus_handle_exceptions�dbus_service_method�N)�
DBusException)�
FirewallError)�errors)�log)�FirewallDBusException�NotAuthorizedException)�
uid_of_sendercst����fdd��}|S)zTDecorator to handle exceptions and log them. Used if not conneced
    to D-Bus.
    c
sjz�|i|��WStyL}z$t�t���t�|�WYd}~n"d}~0tydt��Yn0dS�N)rr�debug1�	traceback�
format_exc�error�	Exception�	exception)�args�kwargsr��func��>/usr/lib/python3.9/site-packages/firewall/server/decorators.py�_impl0sz handle_exceptions.<locals>._impl)�	functools�wraps�rrrrrr,srcs&t����fdd��}t���|_|S)z�Decorator to handle exceptions, log and report them into D-Bus

    :Raises DBusException: on a firewall error code problems.
    c
s�z�|i|��WSty�}zjt�t|��}|tjtjtjtjfvrVt�	t|��nt�
t���t�
t|��tt|���WYd}~nfd}~0ty�}z|�WYd}~n@d}~0ty�}z t��tt|���WYd}~n
d}~00dSr)r�get_code�strrZALREADY_ENABLEDZNOT_ENABLEDZZONE_ALREADY_SETZALREADY_SETrZwarningr
rrrr	rrr)rrr�code�exrrrr@s 
� z%dbus_handle_exceptions.<locals>._impl)rr�inspectZ	signatureZ
__signature__rrrrr;srcOs|�dd�tjj|i|��S)zAdd sender argument for D-BusZsender_keyword�sender)�
setdefault�dbusZservice�method�rrrrrr`src@s&eZdZdZiZddd�Zdd�ZdS)�dbus_service_method_deprecatedzRDecorator that maintains a list of deprecated methods in dbus
    interfaces.
    NcCs*||_|jr&|j|jvr&t�|j|j<dSr)�	interface�
deprecated�set)�selfr(rrr�__init__ksz'dbus_service_method_deprecated.__init__cs4|jr|j|j��j�t����fdd��}|S)Ncs�|i|��Srrr&rrrrusz6dbus_service_method_deprecated.__call__.<locals>._impl)r(r)�add�__name__rr�r+rrrrr�__call__qs
z'dbus_service_method_deprecated.__call__)N)r.�
__module__�__qualname__�__doc__r)r,r0rrrrr'es
r'c@seZdZdZdS)�dbus_service_signal_deprecatedzRDecorator that maintains a list of deprecated signals in dbus
    interfaces.
    N)r.r1r2r3rrrrr4zsr4c@sDeZdZdZdZdZdZdZdZdZ	dd�Z
edd	��Zd
d�Z
dS)�dbus_polkit_require_authz�Decorator factory that checks if the interface/method can be used by the
    sender/user. Assumes wrapped function is a method inside a class derived
    from DbusServiceObject.
    zorg.freedesktop.PolicyKit1z%/org/freedesktop/PolicyKit1/Authorityz$org.freedesktop.PolicyKit1.AuthorityNcCs
||_dSr)�_polkit_auth_required)r+Zpolkit_auth_requiredrrrr,�sz!dbus_polkit_require_auth.__init__cCs|j�|j�d|_d|_dSr)�_busZremove_signal_receiver�_bus_signal_receiver�_interface_polkit)�cls�nameZ	old_ownerZ	new_ownerrrr�_polkit_name_owner_changed�sz3dbus_polkit_require_auth._polkit_name_owner_changedcs$t�����fdd��}�j|_|S)Ncs8t��jst��t��_t��jsHt��jjt��jdd�jd�t��_t��js�z6t�	t��j�
t��jt��j�t��j�t��_Wntj
y�Yn0�j}|s�t�
d��|�d�}|�r*t��j�rt��j�dd|if|idd	�\}}}|�s*t|d
��n$tt��j|�}|dk�r*t|d���|i|��S)
NZNameOwnerChangedzorg.freedesktop.DBus)Zhandler_functionZsignal_nameZdbus_interfaceZarg0z'Not Authorized: No action_id specified.r"zsystem-bus-namer;��Zpolkitr�uid)�typer7r$Z	SystemBusr8Zadd_signal_receiverr<�_polkit_namer9Z	InterfaceZ
get_object�_polkit_path�_polkit_interfacerr6�getZCheckAuthorizationr
r)rrZ	action_idr"�result�_r?�rr+rrr�sF


�
��



�


z0dbus_polkit_require_auth.__call__.<locals>._impl)rrr6r/rrGrr0�s+z!dbus_polkit_require_auth.__call__)r.r1r2r3rArBrCr7r8r9r,�classmethodr<r0rrrrr5�s
r5)r3�__all__r$Zdbus.servicerrr!Zdbus.exceptionsrZfirewall.errorsrZfirewallrZfirewall.core.loggerrZfirewall.server.dbusr	r
Zfirewall.dbus_utilsrrrrr'r4r5rrrr�<module>s$%
Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQeӓk yP7U*omQIs,K`)6\G3t?pgjrmۛجwluGtfh9uyP0D;Uڽ"OXlif$)&|ML0Zrm1[HXPlPR0'G=i2N+0e2]]9VTPO׮7h(F*癈'=QVZDF,d߬~TX G[`le69CR(!S2!P <0x<!1AQ "Raq02Br#SCTb ?Ζ"]mH5WR7k.ۛ!}Q~+yԏz|@T20S~Kek *zFf^2X*(@8r?CIuI|֓>^ExLgNUY+{.RѪ τV׸YTD I62'8Y27'\TP.6d&˦@Vqi|8-OΕ]ʔ U=TL8=;6c| !qfF3aů&~$l}'NWUs$Uk^SV:U# 6w++s&r+nڐ{@29 gL u"TÙM=6(^"7r}=6YݾlCuhquympǦ GjhsǜNlɻ}o7#S6aw4!OSrD57%|?x>L |/nD6?/8w#[)L7+6〼T ATg!%5MmZ/c-{1_Je"|^$'O&ޱմTrb$w)R$& N1EtdU3Uȉ1pM"N*(DNyd96.(jQ)X 5cQɎMyW?Q*!R>6=7)Xj5`J]e8%t!+'!1Q5 !1 AQaqё#2"0BR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