Edit File: dbus_utils.cpython-36.pyc
3 YeJ������������������@���s����d�ddddddddd d gZ�ddlZddlZddlZdd lmZ�ddlmZ�ejdk�Z dd���Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zddd�Zdd��Zddd �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)�log�3c�������������C���sP���y6t�d|��d��}|j��d�jdd�j��}W�dQ�R�X�W�n�tk rJ���dS�X�|S�)z Get command for pid from /proc z/proc/%d/cmdline�rr������ N)�open� readlines�replace�strip� Exception)�pid�f�cmd��r���� /usr/lib/python3.6/dbus_utils.pyr���%���s����&c�������������C���sD���|�j�dd�}tj|d�}yt|j|��}W�n�tk r>���dS�X�|S�)zW Get pid from sender string using org.freedesktop.DBus.GetConnectionUnixProcessID zorg.freedesktop.DBusz/org/freedesktop/DBusN)� get_object�dbus� Interface�intZGetConnectionUnixProcessID� ValueError)�bus�sender�dbus_obj� dbus_ifacer���r���r���r���r���.���s����c�������������C���sD���|�j�dd�}tj|d�}yt|j|��}W�n�tk r>���dS�X�|S�)zV Get user id from sender string using org.freedesktop.DBus.GetConnectionUnixUser zorg.freedesktop.DBusz/org/freedesktop/DBusN)r���r���r���r ���ZGetConnectionUnixUserr!���)r"���r#���r$���r%����uidr���r���r���r���;���s����c�������������C���s,���yt�j|��}W�n�tk r"���dS�X�|d�S�)z Get user for uid from pwd Nr���)�pwd�getpwuidr���)r&���Zpwsr���r���r���r���H���s ����c���������� ���C���sP���|�j�dd�}tj|d�}y|j|�}W�n�tk r:���dS�X�djttt|���S�)zl Get SELinux context from sender string using org.freedesktop.DBus.GetConnectionSELinuxSecurityContext zorg.freedesktop.DBusz/org/freedesktop/DBusN��) r���r���r���Z#GetConnectionSELinuxSecurityContextr����join�map�chrr���)r"���r#���r$���r%����contextr���r���r���r���Q���s����c�������������C���s���t�t|�|��S�)z Return command of D-Bus sender )r���r���)r"���r#���r���r���r���r���_���s����c�������������C���s���t�t|�|��S�)N)r���r���)r"���r#���r���r���r���r���d���s����c�������������C���s���|�d�kr|�}�n�t�|�tj�r(t|��}�n�t�|�tj�rNtrB|�jd�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��|�j��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|�����|d�k �r�|tk�r�t�|t���s�|tk�rt�|t���s�|tk�r t�|t���s�|tk�r8t�|t���s�|tk�rPt�|t���s�|tk�rht�|t���s�|tk�r�t�|t���r�td|t|�|f���|S�) Nzutf-8c�������������S���s���g�|�]}t�|��qS�r���)r���)�.0�xr���r���r���� <listcomp>}���s����z"dbus_to_python.<locals>.<listcomp>c�������������S���s���g�|�]}t�|��qS�r���)r���)r.���r/���r���r���r���r0������s����c�������������S���s���i�|�]\}}t�|�t�|��qS�r���)r���)r.����k�vr���r���r���� <dictcomp>����s����z"dbus_to_python.<locals>.<dictcomp>zUnhandled %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_objr���r���r���r���g���sV���� c�������������C���s>��t�|�tj�rdS�t�|�tj�r dS�t�|�tj�r0dS�t�|�tj�r@dS�t�|�tj�rPdS�t�|�tj�r`dS�t�|�tj�rpdS�t�|�tj �r�dS�t�|�tj �r�d S�t�|�tj�r�d S�t�|�tj�r�dS�t�|�tj ���r�t|�j�dkr�d |�j�S�d|�j�S�nXt�|�tj���r�d|�j�S�t�|�tj��rd|�j�S�t�r*t�|�tj��r*dS�tdt|�����d�S�)N�b�s�o�y�n�ir/����q�u�t�d����za(%s)za%sz(%s)za{%s}zUnhandled %s)r4���r���r5���r7���r<���r=���r>���r?���r@���rA���rB���rC���rD���rF����lenZ signaturerG���rI���r8���r;���rN���rO���)rQ���r���r���r���r �������sB���� c�������������C���s����|d�kri�}t�|�d�s"t|�di���t|�d�}i�||<�y|�j|�}W�n�tk rZ���i�}Y�nX�xV|j��D�]J\}}dt|�i||�|<�||kr�||�||�|�d<�qfd||�|�d<�qfW�d�S�)N�_fw_dbus_propertiesrP����access�read)�hasattr�setattr�getattrZGetAllr���rJ���r ���)rQ���� interfacer_����dipZ_dict�key�valuer���r���r���r �������s���� c������� ������C���s����t�j|�}t|�d�r�x�|jd�D�]�}|jd�r |jd�|kr i�}t|�d�rTt|�d�}||kr xX||�j��D�]H\}}|jd�}|j d|��|j d|d���|j d|d���|j |��qjW�q W�tj|j ����|j ��} |j���| S�)Nr^���rd����name�propertyrP���r_���)r ���ZparseStringra���ZgetElementsByTagNameZhasAttributeZgetAttributerc���rJ���Z createElementZsetAttributeZappendChildr���Zdebug10Ztoxml�unlink) rQ����datard����docZnodere���rf���rg���ZpropZnew_datar���r���r���r�������s&���� )N)N)�__all__r���r'����sysZxml.domr ���Zfirewall.core.loggerr����versionr8���r���r���r���r���r���r���r���r���r ���r ���r���r���r���r���r����<module>���s*��� 0%