HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/firewall/__pycache__/dbus_utils.cpython-38.pyc
U

/ �^J�@s�dddddddddd	d
gZddlZddlZddlZdd
lmZddlmZejdkZ	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zddd�Zdd�Zddd	�Zdd
�ZdS)�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)�log�3c	CsRz6td|d��}|��d�dd���}W5QRXWntk
rLYdSX|S)z  Get command for pid from /proc z/proc/%d/cmdline�rr�� N)�open�	readlines�replace�strip�	Exception)�pid�f�cmd�r�5/usr/lib/python3/dist-packages/firewall/dbus_utils.pyr%s&cCsF|�dd�}t�|d�}zt|�|��}Wntk
r@YdSX|S)zW 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cCsF|�dd�}t�|d�}zt|�|��}Wntk
r@YdSX|S)zV Get user id from sender string using 
    org.freedesktop.DBus.GetConnectionUnixUser rrN)rr r!r"ZGetConnectionUnixUserr#)r$r%r&r'�uidrrrr;scCs.zt�|�}Wntk
r$YdSX|dS)z Get user for uid from pwd Nr)�pwd�getpwuidr)r(ZpwsrrrrHs
cCsR|�dd�}t�|d�}z|�|�}Wntk
r<YdSXd�ttt|���S)zl Get SELinux context from sender string using 
    org.freedesktop.DBus.GetConnectionSELinuxSecurityContext rrN�)	rr r!Z#GetConnectionSELinuxSecurityContextr�join�map�chrr)r$r%r&r'�contextrrrrQscCstt||��S)z  Return command of D-Bus sender )rr�r$r%rrrr_scCstt||��S)N)rrr0rrrrdscCs�|dkr|}�n�t|tj�r(t|�}�n�t|tj�rNtrB|�d�nt|�}�n�trjt|tj�rjt|�}�ndt|tj	�r�t|�}�nLt|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��rdd�|D�}n�t|tj��r6tdd�|D��}n�t|tj��rXdd�|��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|���|dk	�r�|tk�r�t|t��rr|tk�rt|t��rr|tk�rt|t��rr|tk�r0t|t��rr|tk�rFt|t��rr|tk�r\t|t��rr|tk�r�t|t��s�td|t|�|f��|S)	Nzutf-8cSsg|]}t|��qSr�r��.0�xrrr�
<listcomp>}sz"dbus_to_python.<locals>.<listcomp>cSsg|]}t|��qSrr1r2rrrr5scSsi|]\}}t|�t|��qSrr1)r3�k�vrrr�
<dictcomp>�sz"dbus_to_python.<locals>.<dictcomp>�Unhandled %sz%s is %s, expected %s)�
isinstancer �Boolean�bool�String�PY2�encode�str�
UTF8String�
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_objrrrrgs�
�
�
�
�
�
�

�������
������������cCs>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|jSnXt|tj��r�d|jSt|tj��rd|jSt�r*t|tj��r*dStdt|���dS)N�b�s�o�y�n�ir4�q�u�t�d�za(%s)za%sz(%s)za{%s}r9)r:r r;r=rBrCrDrErFrGrHrIrJrL�lenZ	signaturerMrOr>rArTrU)rWrrrr	�sB


cCs�|dkri}t|d�s"t|di�t|d�}i||<z|�|�}Wntk
rZi}YnX|��D]J\}}dt|�i|||<||kr�|||||d<qdd|||d<qddS)N�_fw_dbus_propertiesrV�access�read)�hasattr�setattr�getattrZGetAllrrPr	)rW�	interfacere�dip�_dict�key�valuerrrr
�s


c
Cs�t�|�}t|d�r�|�d�D]�}|�d�r|�d�|kri}t|d�rRt|d�}||kr||��D]H\}}|�d�}|�	d|�|�	d|d�|�	d|d�|�
|�qfqt�|�
��|�
�}	|��|	S)Nrdrj�name�propertyrVre)r
ZparseStringrgZgetElementsByTagNameZhasAttributeZgetAttributerirPZ
createElementZsetAttributeZappendChildrZdebug10Ztoxml�unlink)
rW�datarj�docZnoderkrmrnZpropZnew_datarrrr�s(


�


)N)N)�__all__r r)�sysZxml.domr
Zfirewall.core.loggerr�versionr>rrrrrrrrr	r
rrrrr�<module>s2�
	

	
0%