관리-도구
편집 파일: dbus_utils.cpython-39.opt-1.pyc
a �������g�$����������������������@���s����g�d��Z�ddlZddlZddlmZ�ddlmZ�dd��Zdd��Zd d ��Z dd��Z d d��Zdd��Zdd��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)�logc�����������������C���sd���zJt�d|��d��(}|���d��dd����}W�d����n1�s>0����Y��W�n�ty^���Y�dS�0�|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����:r���c�����������������C���sD���|���dd�}t�|d�}zt|�|��}W�n�ty>���Y�dS�0�|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_ifacer���r���r���r���r���+���s����r���c�����������������C���sD���|���dd�}t�|d�}zt|�|��}W�n�ty>���Y�dS�0�|S�)zU Get user id from sender string using org.freedesktop.DBus.GetConnectionUnixUser r���r���N)r���r���r ���r!���ZGetConnectionUnixUserr"���)r#���r$���r%���r&����uidr���r���r���r���8���s����r���c�����������������C���s,���zt��|��}W�n�ty"���Y�dS�0�|d�S�)z Get user for uid from pwd Nr���)�pwd�getpwuidr���)r'���Zpwsr���r���r���r���E���s ����r���c�����������������C���sP���|���dd�}t�|d�}z|�|�}W�n�ty:���Y�dS�0�d�ttt|���S�)zk Get SELinux context from sender string using org.freedesktop.DBus.GetConnectionSELinuxSecurityContext r���r���N��) r���r���r ���Z#GetConnectionSELinuxSecurityContextr����join�map�chrr���)r#���r$���r%���r&����contextr���r���r���r���N���s����r���c�����������������C���s���t�t|�|��S�)z Return command of D-Bus sender )r���r����r#���r$���r���r���r���r���\���s����r���c�����������������C���s���t�t|�|��S�)N)r���r���r/���r���r���r���r���a���s����r���c�����������������C���s`��|�d�u�r|�}�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|�����|d�u�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�)Nc�����������������S���s���g�|�]}t�|��qS�r����r�����.0�xr���r���r���� <listcomp>x��������z"dbus_to_python.<locals>.<listcomp>c�����������������S���s���g�|�]}t�|��qS�r���r0���r1���r���r���r���r4���z���r5���c�����������������S���s���i�|�]\}}t�|�t�|��qS�r���r0���)r2����k�vr���r���r���� <dictcomp>|���r5���z"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_objr���r���r���r���d���s����� � � � � � � ������� ������������r���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�n@t�|�tj���r�d|�j�S�t�|�tj��rd|�j�S�tdt|�����d�S�)N�b�s�o�y�n�ir3����q�u�t�d����za(%s)za%sz(%s)za{%s}r9���)r:���r���r;���r=���r?���r@���rA���rB���rC���rD���rE���rF���rG���rI����lenZ signaturerJ���rL���rQ���rR���)rT���r���r���r���r �������s>���� r ���c�����������������C���s����|d�u�ri�}t�|�d�s"t|�di���t|�d�}i�||<�z|��|�}W�n�tyX���i�}Y�n0�|���D�]J\}}dt|�i||�|<�||v�r�||�||�|�d<�qbd||�|�d<�qbd�S�)N�_fw_dbus_propertiesrS����access�read)�hasattr�setattr�getattrZGetAllr���rM���r ���)rT���� interfacerb����dip�_dict�key�valuer���r���r���r �������s���� r ���c����������� ������C���s����t��|�}t|�d�r�|�d�D�]�}|�d�r|�d�|kri�}t|�d�rRt|�d�}||v�r||����D�]H\}}|�d�}|� d|��|� d|d���|� d|d���|� |��qfqt�|� ����|� ��} |����| S�)Nra���rg����name�propertyrS���rb���)r ����parseStringrd����getElementsByTagName�hasAttribute�getAttributerf���rM���� createElement�setAttribute�appendChildr����debug10�toxml�unlink) rT����datarg����doc�noderh���rj���rk���ZpropZnew_datar���r���r���r�������s(���� � r���c����������� ������C���s>��t��|�}||v�r�|�d�D�]t}|�d�r|�d�|kr|�d�D�]L}|�d�rB|�d�||�v�rB|�d�}|�dd��|�dd��|�|��qBq||v��r|�d�D�]t}|�d�r�|�d�|kr�|�d�D�]L} | �d�r�| �d�||�v�r�|�d�}|�dd��|�dd��| �|��q�q�t� |� ����|� ��}|����|S�) Nrg���rl����method� annotationzorg.freedesktop.DBus.Deprecatedrk����true�signal)r ���rn���ro���rp���rq���rr���rs���rt���r���ru���rv���rw���) rT���rx���rg���Zdeprecated_methodsZdeprecated_signalsry���rz���Zmethod_noder|���Zsignal_noder���r���r����!dbus_introspection_add_deprecated����s>���� � � � � r���)N)N)�__all__r���r(���Zxml.domr ���Zfirewall.core.loggerr���r���r���r���r���r���r���r���r���r ���r ���r���r���r���r���r���r����<module>���s ��� .#