HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/firewall/server/__pycache__/decorators.cpython-310.pyc
o

bhAb��@s�dZgd�ZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZmZdd	lmZd
d�Zdd
�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|��WSty'}zt�t���t�|�WYd}~dSd}~wty4t��YdSw�N)rr�debug1�	traceback�
format_exc�error�	Exception�	exception)�args�kwargsr��func��</usr/lib/python3/dist-packages/firewall/server/decorators.py�_impl0s��z 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|��WStyC}z/t�t|��}|tjtjtjtjfvr+t�	t|��nt�
t���t�
t|��tt|���d}~wtyP}z|�d}~wtye}z
t��tt|���d}~wwr)r�get_code�strr�ALREADY_ENABLED�NOT_ENABLED�ZONE_ALREADY_SET�ALREADY_SETr�warningr
rrrr	rrr)rrr�code�exrrrr@s(
�����z%dbus_handle_exceptions.<locals>._impl)rr�inspect�	signature�
__signature__rrrrr;srcOs|�dd�tjj|i|��S)zAdd sender argument for D-Bus�sender_keyword�sender)�
setdefault�dbus�service�method�rrrrrr`src@s&eZdZdZiZddd�Zdd�ZdS)�dbus_service_method_deprecatedzRDecorator that maintains a list of deprecated methods in dbus
    interfaces.
    NcCs2||_|jr|j|jvrt�|j|j<dSdSdSr)�	interface�
deprecated�set)�selfr1rrr�__init__ks�z'dbus_service_method_deprecated.__init__cs4|jr
|j|j��j�t����fdd��}|S)Ncs�|i|��Srrr/rrrrusz6dbus_service_method_deprecated.__call__.<locals>._impl)r1r2�add�__name__rr�r4rrrrr�__call__qs
z'dbus_service_method_deprecated.__call__r)r7�
__module__�__qualname__�__doc__r2r5r9rrrrr0es

r0c@seZdZdZdS)�dbus_service_signal_deprecatedzRDecorator that maintains a list of deprecated signals in dbus
    interfaces.
    N)r7r:r;r<rrrrr=zsr=c@sDeZdZdZdZdZdZdZdZdZ	dd�Z
edd	��Zd
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)r4�polkit_auth_requiredrrrr5�s
z!dbus_polkit_require_auth.__init__cCs|j�|j�d|_d|_dSr)�_bus�remove_signal_receiver�_bus_signal_receiver�_interface_polkit)�cls�name�	old_owner�	new_ownerrrr�_polkit_name_owner_changed�sz3dbus_polkit_require_auth._polkit_name_owner_changedcs$t�����fdd��}�j|_|S)Ncs0t��jst��t��_t��js$t��jjt��jdd�jd�t��_t��jsOzt�	t��j�
t��jt��j�t��j�t��_Wn
tj
yNYnw�j}|sYt�
d��|�d�}|r�t��jr�t��j�dd|if|idd	�\}}}|st|d
��ntt��j|�}|dkr�t|d���|i|��S)
N�NameOwnerChangedzorg.freedesktop.DBus)�handler_function�signal_name�dbus_interface�arg0z'Not Authorized: No action_id specified.r*zsystem-bus-namerF���polkitr�uid)�typerAr,�	SystemBusrC�add_signal_receiverrI�_polkit_namerD�	Interface�
get_object�_polkit_path�_polkit_interfacerr?�get�CheckAuthorizationr
r)rr�	action_idr*�result�_rR�rr4rrr�sJ


�
���





�
�
z0dbus_polkit_require_auth.__call__.<locals>._impl)rrr?r8rr`rr9�s+z!dbus_polkit_require_auth.__call__)r7r:r;r<rVrYrZrArCrDr5�classmethodrIr9rrrrr>�s
r>)r<�__all__r,�dbus.servicerrr&�dbus.exceptionsr�firewall.errorsr�firewallr�firewall.core.loggerr�firewall.server.dbusr	r
�firewall.dbus_utilsrrrrr0r=r>rrrr�<module>s&%