HEX
Server: Apache
System: Linux a16-asgard6.hospedagemuolhost.com.br 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: maoristu4c3dbd03 (1436)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/rhsmlib/dbus/__pycache__/dbus_utils.cpython-39.opt-1.pyc
a

X�Zh��
@s�ddlZddlZddlmmZddlZe�e�Z	dd�Z
dd�Zdd�Zdd	�Z
d
d�Zdd
�Zdd�Zddd�Zeejejejejejejejejejejejd�Zdd�Zdd�Z dd�Z!dd�Z"dS)�Nc
Cs�zJtd|d��(}|��d�dd���}Wd�n1s>0YWn8ty�}z t�d||f�WYd}~dSd}~00|S)zGet command for pid from /procz/proc/%d/cmdline�rr�� Nz+Unable to get cmdline of PID: %s, error: %s)�open�	readlines�replace�strip�	Exception�logZwarning)�pid�f�cmd�err�r�=/usr/lib64/python3.9/site-packages/rhsmlib/dbus/dbus_utils.py�command_of_pids:rc
Cs||�dd�}t�|d�}zt|�|��}WnLty>YdStjjyv}zt�	d|���WYd}~dSd}~00|S)zTGet pid from sender string using
    org.freedesktop.DBus.GetConnectionUnixProcessID�org.freedesktop.DBus�/org/freedesktop/DBusNzD-Bus raised exception: )
�
get_object�dbus�	Interface�intZGetConnectionUnixProcessID�
ValueError�
exceptionsZ
DBusExceptionr
�debug)�bus�sender�dbus_obj�
dbus_ifacerrrrr�
pid_of_sender(srcCsD|�dd�}t�|d�}zt|�|��}Wnty>YdS0|S)zSGet user id from sender string using
    org.freedesktop.DBus.GetConnectionUnixUserrrN)rrrrZGetConnectionUnixUserr)rrrr�uidrrr�
uid_of_sender=sr!cCs,zt�|�}Wnty"YdS0|dS)zGet user for uid from pwdNr)�pwd�getpwuidr	)r Zpwsrrr�user_of_uidKs
r$c
Csr|�dd�}t�|d�}z|�|�}Wn6ty\}zt�d|���WYd}~dSd}~00d�tt	t
|���S)ziGet SELinux context from sender string using
    org.freedesktop.DBus.GetConnectionSELinuxSecurityContextrrzCould not get SELinux context: N�)rrrZ#GetConnectionSELinuxSecurityContextr	r
r�join�map�chr�dbus_to_python)rrrr�context�excrrr�context_of_senderUsr,cCstt||��S)zReturn command of D-Bus sender)rr�rrrrr�command_of_senderesr.cCstt||��S�N)r$r!r-rrr�user_of_senderksr0cCsd|dur|}�n�t|tj�r(t|�}�n~t|tj�r@t|�}�nft|tj�rXt|�}�nNt|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��r4tdd�t|���D��}nrt|t��s�t|t��s�t|t��s�t|t��s�t|t��s�t|t��s�t|t��s�t|t��r�|}ntd|��|du�r`|tk�r�t|t��rJ|tk�r�t|t��rJ|tk�r�t|t��rJ|tk�rt|t��rJ|tk�rt|t��rJ|tk�r4t|t��rJ|tk�r`t|t��s`td|t|�|f��|S)NcSsg|]}t|��qSr�r)��.0�xrrr�
<listcomp>��z"dbus_to_python.<locals>.<listcomp>cSsg|]}t|��qSrr1r2rrrr5�r6css"|]\}}t|�t|�gVqdSr/r1)r3�k�vrrr�	<genexpr>�r6z!dbus_to_python.<locals>.<genexpr>zUnhandled %sz%s is %s, expected %s)�
isinstancer�Boolean�bool�String�str�
ObjectPath�Byte�Int16�Int32�Int64�UInt16�UInt32�UInt64r�Double�floatZArray�Struct�tuple�
Dictionary�dict�list�items�bytes�	TypeError�type)�objZ
expected_typeZ
python_objrrrr)os�
�
�
�
�
�
�
�	

��������

��������������	r))�s�o�tr4�u�i�n�q�d�y�bcCs|S)z|
    If we have something which is not a simple type we return the original
    value un-wrapped.
    :param v:
    :return:r)r8rrr�
_pass_through�sr]cCst�|t�|�Sr/)�	_type_map�getr])rU�valuerrr�
_dbus_type�sracCsxt�|�}|rt|D]R}|jd|kr|D]:}d|d|d|df}t�d|�|�t�|��q(qtj|dd�S|S)	a$
    Given xml that describes the interface, add property values to the XML
    for the specified interface.
    :param xml:         XML to edit
    :param interface:   Interface to add the properties too
    :param props:       Output from get_properties
    :return: updated XML string
    �namez,<property type="%s" name="%s" access="%s"/>
Zp_tZp_nameZp_accesszintro xml temp buf=%s�utf8)�encoding)�EtZ
fromstringZattribr
r�appendZtostring)ZxmlZ	interfaceZprops�root�c�pZtemprrr�add_properties�s	
�rjcCs6|��D]\}}t|t�rt|�||<qtj|dd�S)N�sv)Z	signature)rNr:rL�dict_to_variant_dictrrK)Zin_dict�keyr`rrrrl�s
rl)N)#Zloggingr"Zxml.etree.ElementTreeZetreeZElementTreererZ	getLogger�__name__r
rrr!r$r,r.r0r)rLr=r?rFrCrErBrArDrGr@r;r^r]rarjrlrrrr�<module>s:


:�