????

Your IP : 3.144.37.229


Current Path : /lib/python3.9/site-packages/firewall/__pycache__/
Upload File :
Current File : //lib/python3.9/site-packages/firewall/__pycache__/dbus_utils.cpython-39.pyc

a

���g�$�@s�gd�ZddlZddlZddlmZddlmZdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
ddd�Zdd�Zddd�Zdd�Zdd�ZdS))�command_of_pid�
pid_of_sender�
uid_of_sender�user_of_uid�context_of_sender�command_of_sender�user_of_sender�dbus_to_python�dbus_signature�%dbus_introspection_prepare_properties�!dbus_introspection_add_properties�N)�minidom)�logcCsdzJtd|d��(}|��d�dd���}Wd�n1s>0YWnty^YdS0|S)z  Get command for pid from /proc z/proc/%d/cmdline�rr�� N)�open�	readlines�replace�strip�	Exception)�pid�f�cmd�r�7/usr/lib/python3.9/site-packages/firewall/dbus_utils.pyr"s:rcCsD|�dd�}t�|d�}zt|�|��}Wnty>YdS0|S)zV Get pid from sender string using
    org.freedesktop.DBus.GetConnectionUnixProcessID �org.freedesktop.DBus�/org/freedesktop/DBusN)�
get_object�dbus�	Interface�intZGetConnectionUnixProcessID�
ValueError)�bus�sender�dbus_obj�
dbus_ifacerrrrr+srcCsD|�dd�}t�|d�}zt|�|��}Wnty>YdS0|S)zU Get user id from sender string using
    org.freedesktop.DBus.GetConnectionUnixUser rrN)rrr r!ZGetConnectionUnixUserr")r#r$r%r&�uidrrrr8srcCs,zt�|�}Wnty"YdS0|dS)z Get user for uid from pwd Nr)�pwd�getpwuidr)r'ZpwsrrrrEs
rcCsP|�dd�}t�|d�}z|�|�}Wnty:YdS0d�ttt|���S)zk Get SELinux context from sender string using
    org.freedesktop.DBus.GetConnectionSELinuxSecurityContext rrN�)	rrr Z#GetConnectionSELinuxSecurityContextr�join�map�chrr)r#r$r%r&�contextrrrrNsrcCstt||��S)z  Return command of D-Bus sender )rr�r#r$rrrr\srcCstt||��S)N)rrr/rrrrasrcCs`|dur|}�n�t|tj�r(t|�}�nzt|tj�r@t|�}�nbt|tj�rXt|�}�nJt|tj�s�t|tj�s�t|tj	�s�t|tj
�s�t|tj�s�t|tj�s�t|tj
�r�t|�}n�t|tj�r�t|�}n�t|tj�r�dd�|D�}n�t|tj��r
tdd�|D��}n�t|tj��r,dd�|��D�}nvt|t��s�t|t��s�t|t��s�t|t��s�t|t��s�t|t��s�t|t��s�t|t��r�|}ntdt|���|du�r\|tk�r�t|t��rF|tk�r�t|t��rF|tk�r�t|t��rF|tk�rt|t��rF|tk�rt|t��rF|tk�r0t|t��rF|tk�r\t|t��s\td|t|�|f��|S)NcSsg|]}t|��qSr�r��.0�xrrr�
<listcomp>x�z"dbus_to_python.<locals>.<listcomp>cSsg|]}t|��qSrr0r1rrrr4zr5cSsi|]\}}t|�t|��qSrr0)r2�k�vrrr�
<dictcomp>|r5z"dbus_to_python.<locals>.<dictcomp>�Unhandled %sz%s is %s, expected %s)�
isinstancer�Boolean�bool�String�str�
ObjectPath�Byte�Int16�Int32�Int64�UInt16�UInt32�UInt64r!�Double�float�Array�Struct�tuple�
Dictionary�items�bytes�list�dict�	TypeError�repr�type)�objZ
expected_typeZ
python_objrrrrds�
�
�
�
�
�
�

�������
������������rcCs$t|tj�rdSt|tj�r dSt|tj�r0dSt|tj�r@dSt|tj�rPdSt|tj�r`dSt|tj�rpdSt|tj	�r�dSt|tj
�r�d	St|tj�r�d
St|tj�r�dSt|tj
�r�t|j�dkr�d
|jSd|jSn@t|tj��r�d|jSt|tj��rd|jStdt|���dS)N�b�s�o�y�n�ir3�q�u�t�d�za(%s)za%sz(%s)za{%s}r9)r:rr;r=r?r@rArBrCrDrErFrGrI�lenZ	signaturerJrLrQrR)rTrrrr	�s>


r	cCs�|duri}t|d�s"t|di�t|d�}i||<z|�|�}WntyXi}Yn0|��D]J\}}dt|�i|||<||vr�|||||d<qbd|||d<qbdS)N�_fw_dbus_propertiesrS�access�read)�hasattr�setattr�getattrZGetAllrrMr	)rT�	interfacerb�dip�_dict�key�valuerrrr
�s


r
c
Cs�t�|�}t|d�r�|�d�D]�}|�d�r|�d�|kri}t|d�rRt|d�}||vr||��D]H\}}|�d�}|�	d|�|�	d|d�|�	d|d�|�
|�qfqt�|�
��|�
�}	|��|	S)Nrarg�name�propertyrSrb)r
�parseStringrd�getElementsByTagName�hasAttribute�getAttributerfrM�
createElement�setAttribute�appendChildr�debug10�toxml�unlink)
rT�datarg�doc�noderhrjrkZpropZnew_datarrrr�s(


�


rc
Cs>t�|�}||vr�|�d�D]t}|�d�r|�d�|kr|�d�D]L}|�d�rB|�d�||vrB|�d�}|�dd�|�dd�|�|�qBq||v�r|�d�D]t}|�d�r�|�d�|kr�|�d�D]L}	|	�d�r�|	�d�||vr�|�d�}|�dd�|�dd�|	�|�q�q�t�	|�
��|�
�}|��|S)	Nrgrl�method�
annotationzorg.freedesktop.DBus.Deprecatedrk�true�signal)r
rnrorprqrrrsrtrrurvrw)
rTrxrgZdeprecated_methodsZdeprecated_signalsryrzZmethod_noder|Zsignal_noderrr�!dbus_introspection_add_deprecated�s>

�
�


�
�
r)N)N)�__all__rr(Zxml.domr
Zfirewall.core.loggerrrrrrrrrrr	r
rrrrrr�<module>s 	

	
.#