%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/apport/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/apport/__pycache__/report.cpython-312.pyc

�

�s�f!)�	���dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlm Z m!Z!ddl"Z#ddl$Z#ddl%Z%ddl&m'Z'ddl(m)Z*ddl+m,Z,m-Z-ej\j_dd�Z0e0�d	�Z1e0�d
�Z2dZ3ej\j_dd
�Z4dZ5dZ6dZ7dZ8gd�Z9d�Z:de;de!e;fd�Z<	d*de;de=dzde=dzde;fd�Z>	d*de;de=dzde=dzde;fd�Z?d�Z@	d+deAe;deBe;e;fdzdeCde;fd �ZDd!�ZEd"�ZFd#�ZGd$�ZHd%�ZIGd&�d'eBe;e;f�ZJGd(�d)e%j��ZLy),z;Representation of and data collection for a problem report.�N)�Iterable�Iterator)�kill_pkttyagent)�impl)�HookUI�NoninteractiveHookUI�APPORT_DATA_DIRz/usr/share/apportz/general-hooks/z/package-hooks/z/opt�APPORT_IGNORE_FILEz~/.apport-ignore.xmlz/etc/apport/report-ignorez/etc/apport/report-onlyz/etc/apport/blacklist.dz/etc/apport/whitelist.d)�sh�bash�dash�csh�tcshzpython*zruby*�phpzperl*zmono*�awkc���	tj|�tj|�D]$}||vs�|j	|�t||��&y#t$rYywxYw)z7Recursively add dependencies of package to depends_set.N)�	packaging�get_version�
ValueError�get_dependencies�add�_transitive_dependencies)�package�depends_set�ds   �//usr/lib/python3/dist-packages/apport/report.pyrrVsc������g�&��
'�
'��
0�5���K���O�O�A��$�Q��4�5������s�A�	A �A �	directory�returnc#�K�	tj|�j�D]8}	|jd��5}|D]}|j	����	ddd��:y#1swY�xYw#t
$rY�SwxYw#t
$rYywxYw�w)z?Read every file in the directory and return each stripped line.�utf-8��encodingN)�pathlib�Path�iterdir�open�strip�OSError)r�	list_file�fd�lines    r�_read_list_files_in_directoryr,bs�����	
� ���i�0�8�8�:�	�I�
��^�^�W�^�5�+�� "�+��"�j�j�l�*�+�+��	�+�+���
��
���
��
�sb�B
�&A>�A/�A#�A/� A>�"B
�#A,	�(A/�/	A;�8A>�:A;�;A>�>	B
�B
�	B
�
B
�path�pid�dir_fdc�j�|�tj||��Stjd|�d|���S)zrUse readlink() to resolve link.

    Return a string representing the path to which the symbolic link points.
    �r/�/proc/�/)�os�readlink)r-r.r/s   r�_read_proc_linkr6ps7�����{�{�4��/�/�
�;�;���u�A�d�V�,�-�-�c��	|�	d|�d|��}n7tj|tjtjz|��}t	j|d�5}|j�j
�jdd��cddd�S#1swYyxYw#t$r}d	t|�zcYd}~Sd}~wwxYw)
zXRead file content.

    Return its content, or return a textual error if it failed.
    Nr2r3r1�rb�UTF-8�replace��errors�Error: )
r4r&�O_RDONLY�	O_CLOEXEC�io�readr'�decoder(�str)r-r.r/�	proc_filer*�errors      r�_read_proc_filerG}s���	&��>�%+�C�5��$��#8�I�����b�k�k�B�L�L�&@��P�I�
�W�W�Y��
%�	G���7�7�9�?�?�$�+�+�G�I�+�F�	G�	G�	G���&��3�u�:�%�%��&�s<�AB�/B�		B�B�B�B�	C�(
B;�5C�;Cc����d}	td�fd�d��5}|j�j�}ddd�|S#1swY|SxYw#t$r}dt	|�zcYd}~Sd}~wwxYw)z�Read /proc/pid/maps.

    Since /proc/$pid/maps may become unreadable unless we are ptracing the
    process, detect this, and attempt to attach/detach.
    z%Error: unable to read /proc maps file�mapsc�4��tj||���S)Nr1)r4r&)r-�mode�proc_pid_fds  �r�<lambda>z_read_maps.<locals>.<lambda>�s���b�g�g�d�D��&M�r7r )�openerr"Nr>)r&rBr'r(rD)rLrIr*rFs`   r�
_read_mapsrO�su���3�D�&�
��M��
�	%���7�7�9�?�?�$�D�	%��K�	%��K���&��3�u�:�%�%��&�s7�A�?�A�A	�A�	A�	A-�
A(�"A-�(A-�command�env�timeoutc
�B�	tj|dd|dtjtj|��}|jdk(r|j
j�Std|�d|j�d|j
j�����#tj$rq}|j
r,d|j
j
�j���}nd}tdt|j��d|j�d	|���|�d
}~wwxYw)
z�Run command and capture its output.

    Try to execute given command (argv list) and return its stdout, or return
    a textual error if it failed.
    Fr:r;)�checkr"rQr=�stdout�stderrrR�: z with no stdoutzError: command z timed out after z secondsNrz failed with exit code )
�
subprocess�run�PIPE�STDOUT�TimeoutExpiredrUrC�rstripr(rD�cmdrR�
returncode)rPrQrR�sprF�outputs      r�_command_outputrb�s����^�^�������?�?��$�$��	
��&
�}�}����y�y���!�!�
�
�'��"9�"�-�-��I��I�I�����	!�����$�$���<�<��%�,�,�-�-�/�6�6�8�9�:�F�&�F���c�%�)�)�n�-�.��m�m�_�H�V�H�
6�
��	���s�9B�D�-A,D�Dc��d|jvry|jD�]i}|jtjj
jk(s�6|jdk(s�F	|jdj}||vry|j�|j�s��|jdjtjj
jk(s��|jdj}||}t|tj�r"|j!�}|j#d�}n!t|t$�r|j#d�}	t'j(|�}|j1|�r��jy|jdjS#t$rY���wxYw#t&j*t,t.f$rY���wxYw)zxCheck if given report matches the given bug pattern XML DOM node.

    Return the bug URL on match, otherwise None.
    �urlN�re�keyrr:)�
attributes�
childNodes�nodeType�xml�dom�Node�ELEMENT_NODE�nodeName�	nodeValue�KeyError�	normalize�
hasChildNodes�	TEXT_NODE�
isinstance�problem_report�CompressedValue�	get_value�encode�bytesre�compilerF�	TypeErrorr�search)�report�pattern�crf�regexp�v�re_cs       r�_check_bug_patternr��sv��

�G�&�&�&��
�
�
� ���:�:������2�2�2�q�z�z�T�7I�
��l�l�5�)�3�3���&� ��
�K�K�M���� �Q�\�\�!�_�%=�%=������AW�AW�%W����a��2�2���3�K���a��!?�!?�@����
�A�#�]�]�7�3�F���5�)�#�]�]�7�3�F���:�:�f�-�D��{�{�1�~��/ �2���e�$�.�.�.��)�
��
�����)�Z�8����s$�#F"�F2�"	F/�.F/�2G�Gc��	tjjj|�}|jd�D]}t||�}|s�|cSy#tjj
jtf$rYywxYw)Nr~)
rjrk�minidom�parseString�parsers�expat�
ExpatError�UnicodeEncodeError�getElementsByTagNamer�)r}�patternsrkr~rds     r�_check_bug_patternsr��s~����g�g�o�o�)�)�(�3���+�+�I�6��� ���1����J��
��
�K�K���(�(�*<�=����s�)A�-B�Bc��|jD]}}|jtjjj
k(r?|jj�dk(r"|j�|j|��st|��y)z6Recursively remove whitespace from given XML DOM node.�N)rhrirjrkrlrsror'�unlink�removeChild�_dom_remove_space)�noders  rr�r��sb��
�_�_�!���:�:������/�/�/�A�K�K�4E�4E�4G�2�4M�
�H�H�J����Q���a� �!r7c���tjj|�syi}	t|d��5}t	t|j
�|d�|�ddd�	|d||�y#1swY�xYw#t$r1}t|�jd�r|d|�n�Yd}~yd}~wwxYw#t$rYyt$r�tjjtjj|��djd	d
�}tj �|d|z<t"j$j'd|�tj(�YywxYw)
NFr r!�exec�add_infoz
add_info()Tr�-�_�
HookError_zhook %s crashed:)r4r-�existsr&r�rzrBr{rD�
startswith�
StopIteration�	Exception�splitext�basenamer;�	traceback�
format_exc�apport�loggingrF�	print_exc)r}�ui�hook�symbr*rF�hooknames       r�	_run_hookr�sA��
�7�7�>�>�$���
�D��
�$��
)�	9�R�������D�&�1�4�8�	9�	��D���V�R�(� �)	9�	9��
�	��5�z�$�$�\�2�!��Z� ��(��)���	��������7�7�#�#�B�G�G�$4�$4�T�$:�;�A�>�F�F�s�C�P��*3�*>�*>�*@��|�h�&�'������/��6������
�sS�
B6�&A-�B6� A9�-A6�2B6�9	B3�'B.�)B6�.B3�3B6�6	E)�B%E)�(E)c��d}|r?tjj|tjj	dd�g�}tj||��S)z.Return path of command, preferring extra_path.N�PATHr�)r-)r4�pathsep�join�environ�get�shutil�which)rP�
extra_pathr-s   r�_which_extrapathr�#sA���D���z�z���
�B�J�J�N�N�6�2�,F�G�H���<�<��d�+�+r7c�>�eZdZdZdd�Zdeeddfd�Zed��Z	y)	�_Environmentz)Wrapper around an environment dictionary.rNc�d�|jd�}|�y|dk(r|d=yd|vsd|vrd|d<yd|d<y)z/Anonymize PATH environment variable if present.r�NzG/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gamesz/homez/tmpz(custom, user)z(custom, no user))r�)�selfr-s  r�anonymize_pathz_Environment.anonymize_path/sM���x�x�����<���8�
8��V��
��_��$��+�D��L�.�D��Lr7�keysc�&�|D]}||vs�d||<�y)z1Anonymize given environment variables if present.z<set>N�)r�r�rfs   r�anonymize_varsz_Environment.anonymize_vars>s!���	$�C��d�{�#��S�	�	$r7c	��||jd�D�cgc]}d|vs�|jdd���c}�Scc}w)z�Read environment variables from text representation.

        The environment variables are expected to be separated by newlines.
        �
�=�)�split)�clsr��entrys   r�from_stringz_Environment.from_stringDs<���.5�m�m�D�.A�R�U�S�E�\�U�[�[��a�
 �R�
�	
��Rs�	;�;�rN)
�__name__�
__module__�__qualname__�__doc__r�rrDr��classmethodr�r�r7rr�r�,s5��3�
/�$�8�C�=�$�T�$��
��
r7r�c��eZdZdZdAdededzddfd�Zededefd��Zdededzfd	�Zdedefd
�Z	dBdedzddfd�Z
d�Zd
eddfd�ZdCd�Z
dCd�ZdCd�Zdedzfd�Zedededzfd��Z			dDdeezdzdedzdeedzddfd�ZdCd�Z			dDdedzdeedzdedzddfd�Z	dBdedeedzddfd�Zdefd�Z	dEdedzdedzddfd �Zd!�Z			dDd"edzdedzd#edzdefd$�Zd"ededzd#edzdefd%�Zd&edzdedzfd'�Z ed(��Z!defd)�Z"defd*�Z#dCd+�Z$defd,�Z%dedzfd-�Z&dedzfd.�Z'dedzfd/�Z(dedzfd0�Z)de*efd1�Z+dedzfd2�Z,ed3ededzfd4��Z-dedzfd5�Z.dCd6�Z/	dBd7edzdedzde0e*ee1eefffd8�Z2d9�Z3dCd:�Z4d;e1ee5fd<ed=eddfd>�Z6d;e1ee5fddfd?�Z7e8d@��Z9y)F�Reportz�A problem report specific to apport (crash or bug).

    This class wraps a standard ProblemReport and adds methods for collecting
    standard debugging data.
    N�problem_type�daterc�b�tjj|||�d|_d|_y)a,Initialize a fresh problem report.

        date is the desired date/time string; if None (default), the current
        local time is used.

        If the report is attached to a process ID, this should be set in
        self.pid, so that e. g. hooks can use it to collect additional data.
        N)ru�
ProblemReport�__init__r.�_proc_maps_cache)r�r�r�s   rr�zReport.__init__[s+��	�$�$�-�-�d�L�$�G�#���CG��r7rc��d}tj|�}|r|ddj|��d�z
}	tj|�s'tj|�}|r|d|�d�z
}|S|dz
}|S#t
$rY|SwxYw)z�Return a string suitable for appending to Package/Dependencies.

        If package has only unmodified files, return the empty string. If not,
        return ' [modified: ...]' with a list of modified files.
        r�z [modified: � �]z
 [origin: z [origin: unknown])r�get_modified_filesr��is_distro_package�get_package_originr)r�suffix�mod�origins    r�_customized_package_suffixz!Report._customized_package_suffixhs������*�*�7�3�����S�X�X�c�]�O�1�5�5�F�		��.�.�w�7�"�5�5�g�>����
�6�(�!�4�4�F��
��2�2�F�
�
��	�	���
�		�s�5A1�*A1�1	A>�=A>c��	tj|�}|�d|xsd�|j|���|d<|S#t$rd}Y�.wxYw)a Add Package: field.

        Determine the version of the given package (uses "(not installed") for
        uninstalled packages) and add Package: field to report.
        This also checks for any modified files.

        Return determined package version (None for uninstalled).
        Nr�z(not installed)�Package)rrrr��r�r�versions   r�add_packagezReport.add_package�sg��	��+�+�G�4�G�
�i�q��5�$5�6��.�.�w�7�8�
:�	
�Y��
����	��G�	�s�8�A�Ac���t�}t||�d}t|�D]:}	tj|�}|r|dz
}||�d|�|j
|���z
}�<|S#t
$rY�JwxYw)Nr�r�r�)�setr�sortedrrrr�)r�r�dependencies_set�dependencies�depr�s      r�_get_transitive_dependenciesz#Report._get_transitive_dependencies�s���%(�U�� ��*:�;����*�+�		O�C�
��)�)�#�.��
���$���s�e�1�Q�C��(G�(G��(L�'M�N�N�L�		O�����
��
�s�A#�#	A/�.A/c�d�|s7d|vr|ddk(r|d}n"tjj|d�}|sy|j|�}|sd|vr	t	j
|�|d<|syd|vrt	j|�|d<d|vr|j|�|d<yy#t$rY�DwxYw)	aAdd packaging information.

        If package is not given, the report must have ExecutablePath.
        This adds:
        - Package: package name and installed version
        - SourcePackage: source package name (if possible to determine)
        - PackageArchitecture: processor architecture this package was built
          for
        - Dependencies: package names and versions of all dependencies and
          pre-dependencies; this also checks if the files are unmodified and
          appends a list of all modified files
        �ExecutablePath�ProblemType�KernelCrashr�N�
SourcePackage�PackageArchitecture�Dependencies)	r��	fileutils�find_file_packager�r�
get_sourcer�get_architecturer�r�s   r�add_package_infozReport.add_package_info�s�����t�+��]�0C�}�0T��y�/�� �*�*�<�<�T�BR�=S�T�����"�"�7�+���o�T�1�
�(1�(<�(<�W�(E��_�%��� ��,�*3�*D�*D�W�*M�D�&�'���%�#'�#D�#D�W�#M�D�� �&���
��
�s�B#�#	B/�.B/c���|jd��d|jd��d|jdd��d�|d<|jd�}td	d
d|g�|d<td	d
|g�|d<td	dd|g�|d|��<ddl}td|�d�d��5}|j	|�}ddd�dvr|d}td	dd|g�|d|��<g}d|vr:|dD]2}|d|jd�}	|	s�|	|vs�"|j|	��4|D]}
td	dd|
g�|d|
��<�|jd�r!|j
|jd��yy#1swY��xYw)z�Add info about an installed Snap.

        This adds a Snap: field, containing name, version and channel.
        It adds a SnapSource: field, if the snap has a Launchpad contact
        defined.
        �namer�r�z (�channel�unknown�)�Snap�snap�changesz
--abs-time�SnapChanges�connections�SnapConnections�infoz	SnapInfo.rNz/snap/z/current/meta/snap.yamlr r!�base�plugszdefault-provider�contact)r�rb�yamlr&�	safe_load�append�add_snap_contact_info)r�r��snapnamer�f�	snap_metar�	providers�plug�dp�providers           r�
add_snap_infozReport.add_snap_info�s����x�x��� ��$�(�(�9�"5�!6�����)�Y�/�0��
3�	
�V���8�8�F�#��-�
�Y��h�7�
��]��#2�6�=�(�2S�"T��
��'6�
�V�\�8�4�(
��y��
�
#�$�	�
�F�8�*�$;�<�w�
O�	*�ST����q�)�I�	*��Y���V�$�D�'6����t�4�(�D�9�T�F�#�$��	��i��!�'�*�
)���w�'��-�1�1�2D�E���"�I�-��$�$�R�(�
)�"�	�H�+:����x�8�,�D�9�X�J�'�(�	�
�8�8�I���&�&�t�x�x�	�':�;��%	*�	*�s�E"�"E+�snap_contactc���d}tj|tjj	|��}|rJ|jd�r9|jd�|d<|jd�r|jd�|d<d}tj|tjj	|��}|r.|jd�|d<|jd�|d<d	|d
<yy)aLoad report with information about where it should be filed.

        Parse project (e.g. 'subiquity') or source package string
        (e.g. 'ubuntu/+source/gnome-calculator') from snap 'contact'.
        Additionally, extract any tag/tags defined in the contact URL.
        ze^https?:\/\/.*launchpad\.net\/(?:distros/)?((?:[^\/]+\/\+source\/)?[^\/]+)(?:.*field\.tags?=([^&]+))?r��
SnapSource��SnapTagsz'^https?://.*github\.com/([^/]+)/([^/]+)�SnapGitOwner�SnapGitNamezsnap-github�CrashDBN)rer|�urllib�parse�unquote�group)r�r�p�ms    rrzReport.add_snap_contact_info�s���
J�	
�
�I�I�a����-�-�l�;�<��������!"�����D����w�w�q�z�#$�7�7�1�:��Z� �
7���I�I�a����-�-�l�;�<���#$�7�7�1�:�D�� �"#�'�'�!�*�D���+�D��O�
r7c��d|vr+tjj�\}}|�d|��|d<d|vr*tj�}|d�d|d�d|d��|d<d|vrtj
�|d<yy)	aAdd operating system information.

        This adds:
        - DistroRelease: NAME and VERSION from /etc/os-release, or
          'lsb_release -sir' output
        - Architecture: system architecture in distro specific notation
        - Uname: uname -srm output
        �
DistroReleaser��Unamerr��ArchitectureN)r�r�get_os_versionr4�uname�get_system_architecture)r��osname�	osversion�us    r�add_os_infozReport.add_os_infos����$�&� &� 0� 0� ?� ?� A��F�I�'-�h�a�	�{�$;�D��!��$�����
�A� ��t�f�A�a��d�V�1�Q�q�T�F�3�D��M���%�#,�#D�#D�#F�D�� �&r7c
��	tjtj��d}t
jj�}tj�D����cgc]\}}}}||vr||kr|��}}}}}|j�|rdj|�|d<yd|d<y#t$rYywxYwcc}}}}w)zoAdd information about the user.

        This adds:
        - UserGroups: system groups the user is in
        rNr��
UserGroupszN/A)�pwd�getpwuidr4�geteuidrpr�r��get_sys_gid_max�grp�getgrall�sortr�)r��user�sys_gid_maxr�r�gid�memb�groupss        r�
add_user_infozReport.add_user_info$s���	��<�<��
�
��-�a�0�D��&�&�6�6�8��'*�l�l�n�
�
�"��a��d��t�|��{� 2�
�
��
�
	���
��!$���&�!1�D���"'�D�����	��	��
s�*B,�#B;
�,	B8�7B8c���d|vrytjj|d��tt	�fd�t
��syd}|dj
�D]!}	|jdd�\}}|dk(s�|}n|sy|djd	�}gd
�}t|�dk\r�|djd�r}|jd
�rF|ddk(r>t|�dk\r0|j|d�}|r|d|d<||d<yd|d��|d<y|d=t|�dk\r|djd�r�}t|�dk\r�|djd�r-d|vr)tjj|d|d�|d<tj|dtj�r-|d|d<tjj|d�|d<d|vr�|�k7r�|D]�}tj||dztj�s�.||dz}	tjjtjj|	��|k(r
|d|d<|	|d<nd|vrLtjj|d�dk(r&|d|d<|j!�}
|
r|
|d<yd|d<yyy#t$rY��nwxYw)z�Check if process is a script.

        Use ExecutablePath, ProcStatus and ProcCmdline to determine if
        process is an interpreted script. If so, set InterpreterPath
        accordingly.
        r�Nc�0��tj�|�S�N)�fnmatch)�i�exebasenames �rrMz+Report._check_interpreted.<locals>.<lambda>Os���G�O�O�K��$C�r7�
ProcStatus�	r�zName:�ProcCmdline�)z	/usr/bin/z
/usr/sbin/z/bin/z/sbin/rr��pythonz-m��InterpreterPathz'Cannot determine path of python module �UnreportableReason�.�ProcCwdr�twistdz&Cannot determine twistd client program)r4r-r��any�filter�interpreters�
splitlinesr�r�lenr��_python_module_pathr��access�R_OK�realpath�_twistd_executable)r�r�r+�kr��cmdargs�bindirsr-r�argvexe�exer>s           @r�_check_interpretedzReport._check_interpreted>s����4�'���g�g�&�&�t�,<�'=�>��
�6�C�\�R�S������&�1�1�3�	�D�
����D�!�,���A��G�|����	����}�%�+�+�D�1��@���'�l�a��G�A�J�$9�$9�#�$>����x�(�W�Q�Z�4�-?�C��L�TU�DU��/�/���
�;���.2�3C�.D�D�*�+�-1�D�)�*�
�B�'�!�*��N��-�.����
��'�l�a��G�A�J�$9�$9�#�$>� �w�<�1���q�z�$�$�S�)�i�4�.?��W�W�\�\�$�y�/�7�1�:�F���
��y�y����R�W�W�-�*.�/?�*@��&�'�)+���)9�)9�'�!�*�)E��%�&��D�(�T�[�-@��
���9�9�Q����^�R�W�W�5��'�!�*�n�G��w�w�'�'����(8�(8��(A�B�d�J�26�7G�2H��.�/�18��-�.��

�
��%���� � ��&6�!7�8�H�D�&*�+;�&<�D�"�#��)�)�+�C��),��%�&�-U��)�*�E�
&��c�
��
�s�J=�=	K
�	K
c��|djd�dd}|r�|djdd�}|djd�s(|djd	�s|djd
�rt|�dk(r|dS|dSt|d�dkDr/|dddk(r$|dddk7r|ddd}d|vsd
|vsd|vr|dS|jd�|r��y)z5Determine the twistd client program from ProcCmdline.rArBrNrr�r�z--filez--pythonz--sourcer�r	�y�s)r�r�rN�pop)r��args�arg�optss    rrSzReport._twistd_executable�s����M�"�(�(��.�q�r�2����q�'�-�-��Q�'�C��A��!�!�(�+��q�6�$�$�Z�0��q�6�$�$�Z�0��s�8�q�=��q�6�M��A�w���3�q�6�{�Q��3�q�6�!�9��#3��A��q�	�S�8H��1�v�a�b�z���$�;�#��+������7�N��H�H�Q�K��"r7�modulec�~�	tjj|�}|�y|jS#t$rYywxYw)z&Determine path of given Python module.N)�	importlib�util�	find_spec�ImportErrorr�)ra�specs  rrOzReport._python_module_path�sC��	��>�>�+�+�F�3�D��<���{�{���	�	��	�s�0�	<�<r.rL�extraenvc��t|t�rt|�}|s�|s"|jxst	j
�}|js||_	t	jd|��tjtjztjz�}	td||�|d<|j!|||��t#d||�|d	<t#d
||�j%d�|d<t'|�|d
<d|vr	td||�|d<dD]3}|dj)d|�d��s�|dt+d|���d|d<ntj,j/|d�st|d�d���|j1�|j3�|dj5dd�j5dd�j5dd�|d<	t	j6�dk(rt#d||�}|dk7r||d<yyy#t$r}td�|�d}~wt$r/}|jtjk(rtd�|��d}~wwxYw#t$rY���wxYw#t$r}td�|�d}~wt$r/}|jtjk(rtd�|��d}~wwxYw#t$rYywxYw)aAdd /proc/pid information.

        If neither pid nor self.pid are given, it defaults to the process'
        current pid and sets self.pid.

        This adds the following fields:
        - ExecutablePath: /proc/pid/exe contents; if the crashed process is
          interpreted, this contains the script path instead
        - InterpreterPath: /proc/pid/exe contents if the crashed process is
          interpreted; otherwise this key does not exist
        - ExecutableTimestamp: time stamp of ExecutablePath, for comparing at
          report time
        - ProcEnviron: A subset of the process' environment (only some standard
          variables that do not disclose potentially sensitive information,
          plus the ones mentioned in extraenv)
        - ProcCmdline: /proc/pid/cmdline contents
        - ProcStatus: /proc/pid/status contents
        - ProcMaps: /proc/pid/maps contents
        - ProcAttrCurrent: /proc/pid/attr/current contents, if not "unconfined"
        - CurrentDesktop: Value of $XDG_CURRENT_DESKTOP, if present
        r2znot accessibleNzinvalid process�cwdrH)r.rLrh�statusr?�cmdlinerBrA�ProcMapsr�rX)�rofs�rwfs�	squashmnt�
persistmntr3z does not exist�\z\\r�z\ rzattr/current�
unconfined�ProcAttrCurrent)rtrD�intr.r4�getpidr&r?�O_PATH�O_DIRECTORY�PermissionErrorrr(�errno�ENOENTr6�add_proc_environrGr]rOr�rNr-r�rY�_add_executable_timestampr;�getuid)r�r.rLrhrFr�vals       r�
add_proc_infozReport.add_proc_info�s���:�c�3���c�(�C����h�h�-�"�)�)�+���8�8����	
� �g�g��S�E�N�B�K�K�"�)�)�$;�b�n�n�$L���	�-�e�S�+�F�D��O�	
���#�;���R�,�X�s�K�H��\��-�i��k�J�Q�Q�RV�W��]��%�k�2��Z���4�'�
�)8���[�)Q��%�&�=�	�A��$�%�0�0�1�Q�C�q��:�)-�.>�)?��a��s�G���)O��%�&��	��w�w�~�~�d�#3�4�5���%5� 6�7��G�H�H�	
���!��&�&�(�
���
�W�T�6�
"�
�W�S�%�
 �
�W�T�3�
�		
�]��	��y�y�{�a��%�n�c�;�G���,�&�.1�D�*�+�'� ��c#�
>� �!1�2��=���
��;�;�%�,�,�.�$�%6�7�U�B���
���	��	��#�
>� �!1�2��=���
��;�;�%�,�,�.�$�%6�7�U�B���
��B�	��	�sm�A	H� I�I.�.K�	I�H � I�,*I�I�	I+�*I+�.	J>�7J�J>�*J9�9J>�	K
�K
c�r�tttj|d�j��|d<y)Nr��ExecutableTimestamp)rDrur4�stat�st_mtime)r�s rr}z Report._add_executable_timestamps,��&)�#�b�g�g�d�;K�6L�.M�.V�.V�*W�&X��
"�#r7c�x�|s_|stj�}tjd|��tjtjztj
z�}	t
tjj|��}|j||�y#t$r}d|��|d<Yd}~yd}~wwxYw)a�Add environment information.

        If pid is not given, it defaults to the process' current pid.

        This adds the following fields:
        - ProcEnviron: A subset of the process' environment (only some standard
          variables that do not disclose potentially sensitive information,
          plus the ones mentioned in extraenv)
        - CurrentDesktop: Value of $XDG_CURRENT_DESKTOP, if present
        r2r>�ProcEnvironN)r4rvr&r?rwrxr�r�r��get_process_environr(�_add_environ)r�r.rhrLr�rFs      rr|zReport.add_proc_environs��� ���i�i�k���'�'��������b�i�i� 7�"�.�.� H��K�	�"�6�#3�#3�#G�#G��#T�U�G�	
���'�8�,���	�$+�E�7�"3�D�����	�s�#(B�	B9�'B4�4B9r�c�P�hd�}|hd�z}|r|t|�z}|j�|j|�d|vr|d|d<djt	|j��D��cgc]!\}}||vr|�d�|j
dd�z��#c}}�|d<ycc}}w)	N>�
LD_PRELOAD�LD_LIBRARY_PATH�XDG_RUNTIME_DIR>�LANGr��TERM�SHELL�LC_NAME�LC_TIME�LOCPATH�LANGUAGE�LC_CTYPE�LC_PAPER�
LC_ADDRESS�
LC_COLLATE�
LC_NUMERIC�LC_MESSAGES�LC_MONETARY�LC_TELEPHONE�LC_MEASUREMENT�LC_IDENTIFICATION�XDG_CURRENT_DESKTOP�CurrentDesktopr�r��\nr�)r�r�r�r�r��itemsr;)r�r�rhr��	safe_varsrf�values       rr�zReport._add_environ6s���N��"�&
�
�	�(���X��&�I���� ����~�.� �G�+�%,�-B�%C�D�!�"�"�i�i�#)�����"9�
��C���)�#��%�q�	�E�M�M�$��6�6�
�
��]���
s�0&B"
c�f�d|vryd}d}	t|dd�rGtj�\}}tj||d�tj
|�d}|dj
�d}dd|��g}	tj|dd	tjtj�
�}|jdk(}|r|j|d<|rtj|�|S#t$rY|rtj|�yywxYw#|rtj�wwxYw)
zWAdd information from kernel crash.

        This needs a VmCore in the Report.
        �VmCoreF�findTr r��crashz/usr/lib/debug/boot/vmlinux-sbt -a -f
ps
runq
quit
)rT�inputrUrVr�
Stacktrace)�hasattr�tempfile�mkstempr4�write�closer�rXrYrZr[r(r�r_rU)r��unlink_core�retr*�core�kverrPr�s        r�add_kernel_crash_infozReport.add_kernel_crash_info^s,��
�4�������	 ��t�H�~�v�.�%�-�-�/�
��T�����T�(�^�,������"����=�&�&�(��+�D��">�t�f� E�t�L�G�	
�"�����7�%�?�?�%�,�,����"�"�a�'�C��%*�\�\��\�"���	�	�$���
���
����	�	�$���
����	�	�$���s0�A4D�6C/�6 D�/	D�8D�D�D�D0�rootdir�gdb_sandboxc���d|vsd|vrydddddd	d
d�}|j||�\}}d|d
<|gd�z
}g}|j�D]\}}|j|�|ddd|gz
}�!|jd�|ddgz
}t||��}	d|	vsd|	vr�d|	vr3dj	|	j�D�
cgc]	}
d|
vs�|
��c}
�}nJd|	vr3dj	|	j�D�
cgc]	}
d|
vs�|
��c}
�}n|	j�d}d|j
�z}||d<t|��|	jdd��d}
|
jd�r<ttjtjtj�d��tj dtj"�}|j|	�}|j%d�|D]4}|j'd d!�j
�||j%d�<�6d"|vrd#|d"vr|d"|d$<|d"=d%|vr|d%j)d&�r|d%|d$<|d%=d$|vrRtj*d'|d$�}|r4|j-d�|d$<|d$jd(�r|d$dd)|d$<n|d$=d*|vr)|j/�|j1�}|r||d+<yyycc}
wcc}
w),a<Add information from gdb.

        This requires that the report has a CoreDump and an
        ExecutablePath. This adds the following fields:
        - Registers: Output of gdb's 'info registers' command
        - Disassembly: Output of gdb's 'x/16i $pc' command
        - Stacktrace: Output of gdb's 'bt full' command
        - ThreadStacktrace: Output of gdb's 'thread apply all bt full' command
        - StacktraceTop: simplified stacktrace (topmost 5 functions) for inline
          inclusion into bug reports and easier processing
        - AssertionMessage: Value of __abort_msg, __glib_assert_msg, or
          __nih_abort_msg if present

        The optional rootdir can specify a root directory which has the
        executable, libraries, and debug symbols. This does not require
        chroot() or root privileges, it just instructs gdb to search for the
        files there.

        Raises a OSError if the core dump is invalid/truncated, or OSError if
        calling gdb fails, or FileNotFoundError if gdb or the crashing
        executable cannot be found.
        �CoreDumpr�Nzinfo registersz	x/16i $pczbt fullzthread apply all bt fullzprint __abort_msg->msgzprint __glib_assert_msgzprint (char*) __nih_abort_msg)�	Registers�Disassemblyr��ThreadStacktrace�AssertionMessage�GLibAssertionMessage�NihAssertionMessagez/nonexistent�HOME)z--batch�--exzset backtrace limit 2000z-iexzset debuginfod enable offr�zp -99�	separator)rQz%is truncated: expected core file sizezis not a core dumpzwarning:r�zWarning:rzInvalid core dump: rFr�)�maxsplitzNo such file or directory.z&executable file for coredump not foundz^\$\d+\s*=\s*-99$z

z
.
r�z"ERROR:r�r��$z(^\$\d+\s+=\s+0x[0-9a-fA-F]+\s+"(.*)"\s*$r����r��StacktraceAddressSignature)�gdb_commandr�rrbr�rMr'r(r��endswith�FileNotFoundErrorrzr{r4�strerrorrerz�	MULTILINEr]r;r��matchr�_gen_stacktrace_top�crash_signature_addresses)r�r�r��gdb_reports�gdb_cmdr��
value_keysr�r^�outr+�warnings�reason�
first_line�part_re�parts�partr�addr_signatures                   r�add_gdb_infozReport.add_gdb_info�s\��6�T�!�%5�T�%A��*�&�#� :� 8�$=�#B�
�� �+�+�G�[�A����(�����
�	
���
�$�*�*�,�	6�I�D�#����d�#������5�5�G�	6�	���+�&��F�G�$�$���g�7�3��
4�s�:�#�s�*��S� ��9�9�&)�n�n�&6�M�d�*��:L�T�M����s�"��9�9�&)�n�n�&6�M�d�*��:L�T�M����>�>�+�A�.��*�X�^�^�-=�=�F�)/�D�%�&��&�/�!��Y�Y�t�a�Y�0��3�
����;�<�#�������E�L�L�)�8��
��*�*�1�2�<�<�@���
�
�c�"��
�	�	�!���	L�D�&*�l�l�6�7�&C�&I�&I�&K�D�����"�#�	L�
"�T�)��D�!7�8�8�+/�0F�+G��'�(��+�,�!�D�(��)�*�5�5�c�:�+/�0E�+F��'�(��*�+���%����;�T�BT�=U��A��+,�7�7�1�:��'�(��*�+�4�4�U�;�/3�4F�/G��"�/M�D�+�,��+�,��4���$�$�&�!�;�;�=�N��5C��1�2�� ��mN��Ns�7	K�K�.	K�8Kc��tgd��}dgdz}d}d}d}d}tjd�}tjd�}tjd�}	|d	j�D�]0}
|j	|
�}|s|j	|
�}|s�+|r|r�|jd
�r5|jd
�j
�dj
d�d}nd}|r|jd
�s|dvr��d}|jd�s||vr%d}d}dgdz}|jd�rd}|dk(rd}��d}|jd
�xs|jd�}
|
j
�d}|t|�ks��|	j	|�r��'|
||<|dz
}��3dj|�j�|d<y)z�Build field StacktraceTop as the top five functions of Stacktrace.

        Signal handler invocations and related functions are skipped since they
        are generally not useful for triaging and duplicate detection.
        )�g_logv�g_log�	IA__g_log�
IA__g_logv�g_assert_warning�IA__g_assert_warning�
__GI_abort�_XErrorr��rFzD^#(\d+)\s+(?:0x(?:\w+)\s+in\s+\*?(.*)|(<signal handler called>)\s*)$z0^#(\d+)\s+(?:(.*)|(<signal handler called>)\s*)$z,^(__.*_s?sse\d+(?:_\w+)?|__kernel_vsyscall)$r�r�(N�_X>�XWindowEvent�handle_error�handle_responserDTr�r�r��
StacktraceTop)r�rerzrMr�rr�r�rNr�r')r��unwind_functions�toptrace�depth�unwound�	unwinding�unwinding_xerror�bt_fn_re�bt_fn_noaddr_re�ignore_functions_rer+r�fn�frame�functions               rr�zReport._gen_stacktrace_tops����	
�
���4�!�8�������	� ���:�:�S�
���*�*�?�
��!�j�j�;�
����&�1�1�3�*	�D����t�$�A��#�)�)�$�/�����i��7�7�1�:������)�)�+�A�.�4�4�S�9�!�<�B��B�$��}�}�T�*�b�5�/�
!�',�$��7�7�1�:��'7�!7� $�I��E� "�t�a�x�H��w�w�q�z�#'���Y��+/�(��!�	��G�G�A�J�,�!�'�'�!�*�E��{�{�}�Q�'�H��s�8�}�$�-@�-F�-F�x�-P�"'������
��U*	�V!%�	�	�(� 3� 9� 9� ;��_�r7r��
srcpackagec�|�|�
t�}|j|||�}|jdd�t�|S)a�Run hook script for collecting package specific data.

        A hook script needs to be in PACKAGE_HOOK_DIR/<Package>.py or in
        GENERAL_HOOK_DIR/*.py and has to contain a function 'add_info(report,
        ui)' that takes and modifies a Report, and gets an UserInterface
        reference for interactivity.

        return True if the hook requested to stop the report filing process,
        False otherwise.
        N�	_HooksRun)r�_add_hooks_infor]r)r�r�rr�r�s     r�add_hooks_infozReport.add_hooks_infoQs>�� �:�%�'�B��"�"�2�w�
�;������d�#����
r7c���|s|jd�}|r |j�d}d|vr	d|��|d<y|s|jd�}|r |j�d}d|vr	d|��|d<ytg}d}tjj|jd	d
��}|j
t�r|}n`|r^	tjj|�D];}|j
t�s�tjj|�s�9|}n|r�t|�tt�k\rl|jtjj|ddd
��tjj!|�}t|�tt�k\r�lt#t%j$t&dz��D]}t)|||�s�y|r7|D]2}	t)||tjj|	|dz��s�2y|r8|D]3}	t)||tjj|	d|�d���s�3yy#t$rY��BwxYw)Nr�rr3zinvalid Package: rFFr�zinvalid SourcePackage: r�r��sharer�z
package-hooksz/*.pyTz.py�source_)r�r��PACKAGE_HOOK_DIRr4r-rRr��_opt_dirr�r�	get_files�isfilerrNrr��dirnamer��glob�GENERAL_HOOK_DIRr�)
r�r�rr��	hook_dirs�opt_path�	exec_pathr	r��hook_dirs
          rr�zReport._add_hooks_infohs5����h�h�y�)�G���m�m�o�a�(�G��g�~�/@��	�-J��)�*������/�2�J��#�)�)�+�A�.�J��j� �/F�z�l�-S��)�*��%�&�	����G�G�$�$�T�X�X�.>��%C�D�	�����)� �H�
�
��)�)�3�3�G�<��A��|�|�H�-�"�'�'�.�.��2C�#$������h�-�3�x�=�0�� � ��G�G�L�L��7�H�o�N���7�7�?�?�8�4��	�h�-�3�x�=�0��4�9�9�%5��%?�@�A�	�D���r�4�(��	�
�%�
 ���T�2�r�w�w�|�|�H�g��o�'N�O��
 �
�%�
 ����"�b�g�g�l�l�8�w�z�l�#�5N�O�� �	
 ���=�
��
�s�>7I�6I�I�	I�Irdc�2�|sy	tjj|�5}|j�j	dd��}ddd�dvryt||�}|r|Sy#1swY�xYw#t
tjjf$rYywxYw)aCheck bug patterns loaded from the specified url.

        Return bug URL on match, or None otherwise.

        The url must refer to a valid XML document with the following syntax:
        root element := <patterns>
        patterns := <pattern url="http://bug.url"> *
        pattern := <re key="report_key">regular expression*</re> +

        For example:
        <?xml version="1.0"?>
        <patterns>
            <pattern url="http://bugtracker.net/bugs/1">
                <re key="Foo">ba.*r</re>
            </pattern>
            <pattern url="http://bugtracker.net/bugs/2">
                <re key="Package">^\\S* 1-2$</re>
                <!-- test for a particular version -->
                <re key="Foo">write_(hello|goodbye)</re>
            </pattern>
        </patterns>
        Nr:r;r<z<title>404 Not Found)	r�request�urlopenrBrCr(rF�URLErrorr�)r�rdr	r�s    r�search_bug_patternszReport.search_bug_patterns�s���0��	����'�'��,�
L��"�<�<�>�0�0���0�K��
L�"�X�-��!�$��1����J��
L�
L������.�.�/�	��	�s(�A0�"A$�A0�$A-�)A0�0#B�Bc�>�tjtj��d}tjd|�}d}d}d}	tj|tjtjz�}tj|�}tj|j�r'tj|d�}|jd�}|�|j!�n|�tj |�	|dk(r0t"j$j'�j)ddd�}n*	t"j$j*j-|�}|j8j;�t=|j8�|S#t$rY��wxYw#|�|j!�w|�tj |�wwxYw#t"j.j0j2$r#}t5t�dt7|����|�d}~wwxYw)	z�Read ignore list XML file and return a DOM tree.

        Return an empty DOM tree if file does not exist.

        Raises ValueError if the file exists but is invalid XML.
        r��~r�N�riP�r�z has invalid format: )r,r-r4r.�_ignore_filer;r&�
O_NOFOLLOWr?�fstatr��S_ISREG�st_mode�fdopenrBr(r�rjrk�getDOMImplementation�createDocumentr�r�r�r�r�rrD�documentElementrqr�)�homedir�ifpath�contentsr*r	�strkrFs        r�_get_ignore_domzReport._get_ignore_dom�s����,�,�r�z�z�|�,�Q�/���%�%�c�7�3����
����
	�����������!<�=�B����"��B��|�|�B�J�J�'��I�I�b�#�&���6�6�%�=���}����	���������r�>��'�'�.�.�0�?�?��h�PT�U�C�
��g�g�o�o�1�1�(�;��	���%�%�'��#�-�-�.��
��1�	��	���}����	�������� ���;�;�$�$�/�/�
� �#�n�$9�#�e�*��F�����
�s=�BF�9)G�	F�F"�F�F"�"-G�'H�9H�Hc��t|d�}|jd�}|r|S	tj|�jS#t
$rd|��cYSwxYw)N�Signal�
SignalNamezsignal )rur��signal�Signalsr�r)r��
signal_number�signal_names   r�_get_signal_namezReport._get_signal_names]���D��N�+�
��h�h�|�,�����	-��>�>�-�0�5�5�5���	-��]�O�,�,�	-�s�A�A�Ac���d|vsJ�|dtt�vs|dtt�vryttt��}|ttt
��z}|r|d|vry	|j
�}	ttj |d�j"�}	|j'd�D]9}|j)d�|dk(s�t+|j)d��|k\s�9y	y#ttf$r6tjjd�tj�YywxYw#t$$rYywxYw#ttf$rYywxYw)a^Check if current report should not be presented.

        Reports can be suppressed by per-user denylisting in
        ~/.apport-ignore.xml (in the real UID's home) and
        /etc/apport/report-ignore/. For environments where you are only
        interested in crashes of some programs, you can also create an
        allowlist in /etc/apport/report-only/, everything which does not
        match gets ignored then.

        This requires the ExecutablePath attribute. Throws a ValueError if the
        file has an invalid format.

        Privileges may need to be dropped before calling this.
        r�TzCould not get ignore file:F�ignore�program�mtime)r,�
_DENYLIST_DIR�_LEGACY_DENYLIST_DIRr��_ALLOWLIST_DIR�_LEGACY_ALLOWLIST_DIRrrrpr�r�rFr�r�rur4r�r�r(r��getAttribute�float)r��	allowlistrk�	cur_mtimer's     r�
check_ignoredzReport.check_ignoreds{�� �4�'�'�'�� �!�%B��&
�
�
�"�
#�'D� �(
�
���5�n�E�F�	��S�6�7L�M�N�N�	���.�/�y�@��	��&�&�(�C�	��B�G�G�D�)9�$:�;�D�D�E�I�	��2�2�8�<�
$���&�&�y�1�T�:J�5K�K��V�0�0��9�:�i�G�#�
$���)�H�%�	��N�N� � �!=�>����!��	���	��	���H�%�	���	�sI�.C:�?+E�++E�E�5E�7E�:AD?�>D?�	E�
E�E#�"E#c�8�d|vsJ�|j�}	tttj|d�j
��}|jd�D]-}|jd�|dk(s�|jd|�nT|jd�}|jd|d�|jd|�|jj|�tj tj"��d}t$j'd|�}t)|dd	�
�5}|j+|dd�
�ddd�|j-�y#t$r(}|jtjk(rYd}~y�d}~wwxYw#1swY�NxYw)a~Ignore future crashes of this executable.

        Add a ignore list entry for this report to ~/.apport-ignore.xml, so
        that future reports for this ExecutablePath are not presented to the
        user any more.

        Throws a ValueError if the file already exists and has an invalid
        format.

        Privileges may need to be dropped before calling this.
        r�Nr'r(r)r�r�wr r!z  r�)�	addindent�newl)rrDrur4r�r�r(rzr{r�r.�setAttribute�
createElementr�appendChildr,r-r.rr;r&�writexmlr�)	r�rkr)rFr'�er�ignore_file_pathr*s	         r�mark_ignorezReport.mark_ignoreIsp�� �4�'�'�'��"�"�$��	���B�G�G�D�)9�$:�;�D�D�E�F�E��.�.�x�8�		/�F��"�"�9�-��6F�1G�G��#�#�G�U�3��		/��!�!�(�+�A�
�N�N�9�d�+;�&<�=�
�N�N�7�E�*����+�+�A�.��,�,�r�z�z�|�,�Q�/��'�/�/��W�=��
�"�C�'�
:�	8�b��L�L��t�$�L�7�	8�	�
�
���5�	��{�{�e�l�l�*����		��.	8�	8�s)�4E�.F�	F
�%F�F�F
�Fc��|jd�sy|dj�D�cgc]}|jd���}}t|�dkr|j	d�dk(S|j	d�t|�dzkScc}w)aCheck whether StackTrace can be considered 'useful'.

        The current heuristic is to consider it useless if it either is shorter
        than three lines and has any unknown function, or for longer traces, a
        minority of known functions.
        r�F�??rDTrg@)r�rMr�rN�count)r�r	�
unknown_fns   r�has_useful_stacktracezReport.has_useful_stacktracevs����x�x��(��26��2G�2R�2R�2T�U�Q�a�l�l�4�(�U�
�U��z�?�Q���#�#�D�)�Q�.�.�����%��Z��3�)>�>�>��Vs�Bc��|jdd�j�D]-}|jd�dj�}|dk7s�+|cSy)z)Return topmost function in StacktraceTop.r�r�r�rr?N)r�rMr�r')r�r+�fnames   r�stacktrace_top_functionzReport.stacktrace_top_function�sQ���H�H�_�b�1�<�<�>�	�D��J�J�s�O�A�&�,�,�.�E���}���	�
r7c���|dj�}t|�dkryt|�dkr*tjj	|d��d|d��Stjd�}t|�dz
}d}|dk\rD|j||�}|r#|jd�}|jd	�}n|dz}|dk\r�Dtjj	|d�}|d
}|jd�d}	tjdtj|	��d
�|�}|r|jd�}
nd}
|dk(r|dk(rd}n|}n|�d�}|�d|	�d|��}|
r|d|
��z
}|S)N�	Tracebackr�rDr�� crashed with rz^\s*File\s*"(\S+)".* in (.+)$r�r����:�^z: (.+)$�<module>�__main__�()� in rW)rMrNr4r-r�rerzr�rr��escape)
r��trace�trace_rer=r�r�module_pathr-�	last_line�	exception�message�context�titles
             r�_get_python_exception_titlez"Report._get_python_exception_title�s����[�!�,�,�.���u�:��>���u�:��>��7�7�#�#�D�)9�$:�;�<� ��q��
�,�
�
�:�:�>�?����J��N�����1�f����u�Q�x�(�A���g�g�a�j���7�7�1�:���
��F�A�
�1�f��w�w����%5� 6�7���"�I�	��O�O�C�(��+�	��H�H�q����9�-�.�g�6�	�B����g�g�a�j�G��G��z�!��d�#3�4�4�$��&��!�
�"�o�G��&��y�k��g�Y�?����r�'��^�#�E��r7c��|j�}|rd|�d�}nd}d}d|vr d|vr|d|dk7r|ddk7r	d|d�d�}tjj|d	��d
|j	��|�|��S)NrOrNr�r"r��allz
 [non-native z	 package]r�rH)rEr4r-r�r%)r�r��
arch_mismatchs   r�_get_signal_crash_titlezReport._get_signal_crash_title�s���
�
)�
)�
+��
���t�2��B��B��
��d�"�%��-��^�$��-B�(C�C��*�+�u�4�+�D�1F�,G�+H�	�R�M��w�w����%5� 6�7�8��T�2�2�4�5�b�T�-��
J�	
r7c���|jd�dk(r2d|vr.d|vr*tjj|d��d|d��Sd|vrd|vrd|vr|j	�Sd|vrd|vr|j�S|jd�d	k(r<d	|vr8d
|d	�d�}|jd�r|d
|dj
�dzz
}|S|jd�dk(rHd|vrD|d}|jd�r|jdd�d}|S|jdd�d}|S|jd�dk(r<d|vr8d}d|vr|d|dzdzz
}||ddzz
}d|vr|d|dzdzz
}|dz
}|Sy) aZCreate an appropriate title for a crash database entry.

        This contains the topmost function name from the stack trace and the
        signal (for signal crashes) or the Python exception (for unhandled
        Python exceptions).

        Return None if the report is not a crash or a default title could not
        be generated.
        r�6r�r�z assert failure: r�rGr�r�zpackage z failed to install/upgrade�ErrorMessagerWrI�
KernelOops�OopsTextz$------------[ cut here ]------------r�rr�r�Failurer��MachineType�[z] z failure�NonfreeKernelModulesz [non-free: r�N)	r�r4r-r�r]rYrMr�r�)r�rX�oopss   r�standard_titlezReport.standard_title�s���
�H�H�X��#�%� �D�(�"�d�*��7�7�#�#�D�)9�$:�;�<�=��+�,�-�/�
�
�t�� 0�D� 8�_�PT�=T��/�/�1�1��$��#3�t�#;��3�3�5�5��8�8�M�"�i�/�I��4E��t�I��/�/I�J�E��x�x��'����^� 4� ?� ?� A�"� E�E�E���L��8�8�M�"�l�2�z�T�7I��
�#�D����E�F��
�
�4��+�A�.���L��
�
�4��+�A�.���L��8�8�M�"�l�2�y�D�7H��E���$���t�M�2�2�T�9�9���T�)�_�z�1�1�E�%��-���$�/E�*F�F��L�L���T�M�E��L�r7c�J�g}|jdd�dz|jdd�zj�D]g}|s�|j�dd\}}tj|�}|��4|dk7s�:|��=tj
||�dks�W|j
|��i|S)	z=Return list of obsolete packages in Package and Dependencies.r�r�r�r�Nr�Noner)r�rMr�r�get_available_version�compare_versionsr)r��obsoleter+�pkg�ver�avails      r�obsolete_packageszReport.obsolete_packagess������H�H�Y��#�d�*�T�X�X�n�b�-I�I�
�*�,�
	%�D����z�z�|�B�Q�'�H�C���3�3�C�8�E����6�M��%��.�.�s�E�:�Q�>�����$�
	%��r7c�D�d|vr|ddvryd|vrd|ddk(r\d}tjd�}|dj�D]-}|j|�}|s�|d	|j	d
�zz
}�/|S|jd�dk(r)d
|vr%|dd	z|d
z}tjdd|�Sd|vr�d|vr�|d�d	|d��}tjd�}|dj�}t|�dkry|D]A}|j|�}|r+|d	|j	d
�xs|j	d�zz
}�Ay|Sd|v�r_|dj�}d}t|�d
k(r6tjd|d�}|sy|dd	z|j	d
�zSt|�dkrytjd�}|D]�}|j|�}|s�|j	d�dk7r|d	|j	d�zz
}�C|j	d
�}	tjj|	�rtjj|	�}	|d	|	�d|j	d���z
}��|djd	�d}
	|
d|d�d�z
}
|dd	z|
z|zS|ddk(rQd |vrMd!|d vsd"|d vr?|d }|jd#�r|d	|d#��z
}|jd$�r|d	|d$��z
}|Sd%|v�r	d&}g}|d%jd'�D]�}|jd(�rFtjd)|�}
|
r.|
j	d
�}|s
Jd*|����|j!|�|jd+�r&|j#|�}|s�|j!|���|jd,�rd-}��|s��d}|r.|dd.k(r&|j#|�}|s��|j!|���d&}��|rd	j%|�Sy#t$rY���wxYw)/a�Get a signature string for a crash.

        This is suitable for identifying duplicates.

        For signal crashes this the concatenation of ExecutablePath, Signal
        number, and StacktraceTop function names, separated by a colon. If
        StacktraceTop has unknown functions or the report lacks any of those
        fields, return None. In this case, you can use
        crash_signature_addresses() to get a less precise duplicate signature
        based on addresses instead of symbol names.

        For assertion failures, it is the concatenation of ExecutablePath
        and assertion message, separated by colons.

        For Python crashes, this concatenates the ExecutablePath, exception
        name, and Traceback function names, again separated by a colon.

        For suspend/resume failures, this concatenates whether it was a suspend
        or resume failure with the hardware identifier and the BIOS version, if
        it exists.
        r�r�>rar�Nr�r��kernelz^\s*\#\d+\s\[\w+\]\s(\w+)rJr�rr_r�z0x[0-9a-f]{6,}�ADDRr�z.^(?:([\w:~]+).*|(<signal handler called>)\s*)$rrGr�z(\w+): rrDz)^\s+File "([^"]+).*line (\d+).*\sin (.*)$rL�@rIr��_PythonExceptionQualifierr�rarc�suspend�resumerdzdmi.bios.versionrbFr�zBUG: unable to handlez^BUG: unable to handle (.*) at z,could not parse expected problem type line: zIP: zCall Trace:Tr�)rerzrMr�rr��subrNr4r-�islinkrRr�rpr�r|r�_extract_function_and_addressr�)r��sig�regexr+rr��linesrQ�loc_rer	�exc_name�
in_trace_bodyr��parsedr�s               r�crash_signaturezReport.crash_signature#s���2�4�'��
�&�*G�G���4��D��$7�=�$H��C��J�J�;�<�E��\�*�5�5�7�
.���K�K��%����3�!�'�'�!�*�-�-�C�
.��J��8�8�H���$�);�t�)C��'�(�3�.��6H�1I�I�C��6�6�+�V�S�9�9��d�"�x�4�'7��*�+�,�A�d�8�n�-=�>�C��z�z�"S�T�H���)�4�4�6�E��5�z�A�~���
 ���N�N�4�(����3�!�'�'�!�*�":�����
�;�;�C� �

 ��J��$����%�0�0�2�E��C��5�z�Q���H�H�Z��q��2�����,�-��3�a�g�g�a�j�@�@��5�z�A�~���Z�Z� L�M�F��

4���L�L��&����w�w�q�z�Z�/��s�Q�W�W�Q�Z�/�/���G�G�A�J���7�7�>�>�!�,� "��� 0� 0�� 3�A���1�#�Q�q�w�w�q�z�l�3�3��

4��R�y���s�+�A�.�H�
��a��%@� A�B�!�D�D���(�)�C�/�(�:�S�@�@��
��,�.�9��3D��D��O�+�x�4�	�?�/J��9�o���8�8�M�*��Q�t�M�2�3�4�4�C��8�8�.�/��Q�t�$6�7�8�9�9�C��
����!�M��E��Z�(�.�.�t�4�
.���?�?�#:�;��Y�Y�'H�$�O�F�� &���Q���!�Q�I�$��P�Q�!����U�+��?�?�6�*� �>�>�t�D�E�����U�+��_�_�]�3�$(�M�"� �E���Q��3�� $� B� B�4� H�� �!�L�L��/�(-�
�3
.�4��x�x���&���]�
��
�s�P�	P�Pr+c��tjd|�}|r'|jd�}|s
Jd|����|ddk7r|Sy)Nz\[.*\] (.*)$r�z*could not parse expected call trace line: r�?)rer|r)r+r�r�s   rr{z$Report._extract_function_and_address�sJ�����?�D�1����L�L��O�E��M�F�t�f�M�M�5��Q�x�3����r7c�B�d|vsd|vsd|vryd|dvryg}d}|dj�D]�}|jd�rq|j�d}|jd	�s�9t|d
�}|dkr�K|j	|�}|r"|j|j
dd
��n|dz
}t|�dk\s��n|dkDrt|�|zdkry|dk(rt|�dks|dkDrt|�dkry|d�d|d�ddj|���S)a�Compute heuristic duplicate signature for a signal crash.

        This should be used if crash_signature() fails, i. e. Stacktrace does
        not have enough symbols.

        This approach only uses addresses in the stack trace and does not rely
        on symbol resolution. As we can't unwind these stack traces, we cannot
        limit them to the top five frames and thus will end up with several or
        many different signatures for a particular crash. But these can be
        computed and synchronously checked with a crash database at the client
        side, which avoids having to upload and process the full report. So on
        the server-side crash database we will only have to deal with all the
        equivalence classes (i. e. same crash producing a number of possible
        signatures) instead of every single report.

        Return None when signature cannot be determined.
        rmr�rNzErrno 13r�#r��0x�irJz..�r!rD�r�)	rMr�r�ru�_address_to_offsetrr;rNr�)r��stack�failedr+�addr�offsets      rr�z Report.crash_signature_addresses�sH��$�T�!�\��%=��QU�AU����j�)�)��������&�1�1�3�	�D����s�#��z�z�|�A������t�,���4��}���&�=���0�0��6����L�L�����T�!:�;��a�K�F�
�5�z�R���-	�4�A�:�#�e�*�v�-��1��
�a�K�C��J��N���
�s�5�z�A�~���'�(�)��4��>�*:�!�C�H�H�U�O�;L�M�Mr7c	���g}tj�dkD�r-tjtj��}t|d�dk\r@|j
tjdtj|d��d��df�|j
tjdtj|d��d��df�|djd�D]^}|j�}t|�dkDs�"|j
tjd	tj|��d��d
f��`tj�d}t|�dk\r=|j
tjdtj|��d��df�	|d
=|D]�}|jd�xr|dv}|s	d|vs|dvs�%t||d�s�5|D]i\}}t!||t"�r9|j%|||j'dd���j)d�||<�R|j%|||�||<�k��y#t$rY��wxYw)z�Remove user identifying strings from the report.

        This particularly removes the user name, host name, and IPs
        from attributes which contain data read from the environment, and
        removes the ProcCwd attribute completely.
        rrz\b�usernamer�z/home/usernamer!�,z(\b|\s)z\1User Namer��hostnamerH�Proc)�ProcCpuinformr?�ProcInterrupts�ProcModulesr�>�TitlerG�
PythonArgs�
JournalErrors�isspacer:r;r<N)r4r~r,r-r.rNrrerzrPr�r'r$rpr�r�rtryryrCrx)	r��replacementsrr\r�rT�
is_proc_fieldr~�repls	         r�	anonymizezReport.anonymize�s6����
�9�9�;��?����R�Z�Z�\�*�A��1�Q�4�y�A�~��#�#�R�Z�Z�2�b�i�i��!��o�5F�b�0I�%J�J�$W�X�������r�"�)�)�A�a�D�/�!2�"�5�6�8H�I�
��q�T�Z�Z��_�
���G�G�I���q�6�A�:� �'�'����w�r�y�y��|�n�B�$?�@�.�Q��
��8�8�:�a�=���x�=�A��������r�"�)�)�H�2E�1F�b�,I�!J�J� W�X�	��Y���	=�A��L�L��0��Q�?�6�M���1�$��M�M��t�A�w�	�2��%1�=�M�G�T�!�$�q�'�5�1�")�+�+� �$�q�'�.�.���.�"K�#� �&��/��Q��#*�+�+�d�D��G�"<��Q��
=�	=���	��	�s�+I�	I"�!I"�sandboxc���d|vsJ�|jd|d�}d}d|vr|dtj�k(rd}|r!tjj|dd�nd}t
d	|�}|s<ttjtjtj�d
��|g}i}|s1t
d|�}	|	r|	g}ntjjd�|r�d
}
|dd|�d�dd|zdd|zdd|�d|
�d|�d|
��gz
}|r:|�d|�d|
�d|�d|
�d|�d�}|�d�}|||||�d|
�d�d�z}dg|dd|dd|�d�gz
}tjj||z�s;|jd�r*tjj||d dz�r|d d}||z}|dd!|�d"�gz
}d#|v�r&t!|d#d$�rlt#j$d%�&�\}
}t'j(tj*|�tj|
|d#�tj,|
�n�t/|d#t0j2�r|t#j$d%�&�\}
}t'j(tj*|�tj,|
�t5|d'�5}|d#j|�ddd�n|d#d}|dd(|zgz
}||fS#1swY�xYw))a"Build gdb command for this report.

        This builds a gdb command for processing the given report, by setting
        the file to the ExecutablePath/InterpreterPath, unpacking the core dump
        and pointing "core-file" to it (if the report has a core dump), and
        setting up the paths when calling gdb in a package sandbox.

        When available, this calls "gdb-multiarch" instead of "gdb", for
        processing crash reports from foreign architectures.

        Return argv list for gdb and any environment variables.
        r�rEFr"T�usr�binN�gdbzgdb not found in retracing envz
gdb-multiarchzWARNING: Please install gdb-multiarch for processing reports from foreign architectures. Results with "gdb" will be very poor.
zx86_64-linux-gnur�zset debug-file-directory z/usr/lib/debugzset solib-absolute-prefix zadd-auto-load-safe-path zset solib-search-path z/lib/rJz	/usr/lib/z/lib:z/usr/libz/usrz/gconv)r�r��
PYTHONHOME�
GCONV_PATHzld-linux-x86-64.so.2rzset data-directory z/usr/share/gdbrDzfile "�"r�r��apport_core_)�prefix�wbz
core-file )r�rr%r4r-r�r�r�rzr{r��sysrVr�r�r�r�r�r��atexit�registerr�r�rtrurvr&)r�r�r��
executable�	same_arch�gdb_sandbox_bin�gdb_pathrPr��ma�native_multiarch�ld_lib_path�pyhomer*r�r	s                rr�zReport.gdb_command2s`��" �4�'�'�'��X�X�/��6F�1G�H�
��	��d�"��^�$�	�(I�(I�(K�K��I�8C�B�G�G�L�L��e�U�3��	�$�E�?�;���#�������E�L�L�)�0��
��*��"$���!�/�?�C�B���$���
�
� � �+���1����+�G�9�N�C��,�w�6��*�W�4��(��	��7G�6H��G�9�I�&6�%7�9��
�G��"�m�$�#�}�E�*:�);���}�I�.>�-?���}�H�.��(�=��-���'2�'�"(�%0�M��;K�:L�F�"S�	��� 6�6������F�&9�+��n�$U�V�V���7�7�>�>�'�J�"6�7��(�(��0��w�w�~�~�g�
�1�2��&>�?�%/���^�
� �:�-�J��F�f�Z�L��2�3�3������t�J�'��0�%�-�-�^�D�
��T�����	�	�4�0�����T�*�-�.�������D��,�n�.L�.L�M�%�-�-�^�D�
��T�����	�	�4�0�������$��%�.����$�*�*�1�-�.�.��J�'��*�����t� 3�4�4�G�����.�.�s�0K$�$K-c��|j�|jD]!\}}}||cxkr|ks�n�|�d||z
d��cSy)a^Resolve a memory address to an ELF name and offset.

        This can be used for building duplicate signatures from non-symbolic
        stack traces. These often do not have enough symbols available to
        resolve function names, but taking the raw addresses also is not
        suitable due to ASLR. But the offsets within a library should be
        constant between crashes (assuming the same version of all libraries).

        This needs and uses the "ProcMaps" field to resolve addresses.

        Return 'path+offset' when found, or None if address is not in any
        mapped range.
        �+�xN)�_build_proc_maps_cacher�)r�r��start�end�elfs     rr�zReport._address_to_offset�sU��	
�#�#�%�#�4�4�	1�O�E�3����#��#���a��u��Q�/�0�0�	1�r7c	��|jryd|vsJ�g|_tjd�}tjd�}|dj�D]�}|j	�s�|j|�}|s|j|�r�9|s
Jd|z��|jj
t|jd�d�t|jd�d�|jd	�f���y)
z_Generate self._proc_maps_cache from ProcMaps field.

        This only gets done once.
        Nrmz-^([0-9a-fA-F]+)-([0-9a-fA-F]+).*\s{2,}(\S.*$)z ^([0-9a-fA-F]+)-([0-9a-fA-F]+)\szcannot parse ProcMaps line: r�r�rrD)	r�rerzrMr'r�rrur)r��fmt�fmt_unknownr+rs     rr�zReport._build_proc_maps_cache�s���
� � ���T�!�!�!� "����j�j�I�J���j�j�!D�E����$�/�/�1�
	�D��:�:�<���	�	�$��A���$�$�T�*���?�8�4�?�?�q��!�!�(�(��Q�W�W�Q�Z��$�c�!�'�'�!�*�b�&9�1�7�7�1�:�F�
�
	r7�coredump�coredump_keyrfc�p�|j|�}t|t�sJ�|j�||<yr;)r�rtrDr])r�r�r�rfr�s     r�_add_str_from_coredumpzReport._add_str_from_coredump�s1�����\�*���%��%�%�%��L�L�N��S�	r7c�H�|jd�}|rt|t�sJ�||d<y|jd�}|r,t|t�sJ�	t	j
|�|d<yy#t$r,tjt�jd|�YywxYw)N�COREDUMPr��COREDUMP_FILENAMEz:Ignoring COREDUMP_FILENAME '%s' because it does not exist.)r�rtryrDru�CompressedFiler�r��	getLoggerr��warning)r�r��dump�filenames    r�#_add_coredump_from_systemd_coredumpz*Report._add_coredump_from_systemd_coredump�s����|�|�J�'����d�E�*�*�*�#�D�����<�<� 3�4����h��,�,�,�
�#1�#@�#@��#J��Z� ���%�
��!�!�(�+�3�3�P���
�s�A,�,2B!� B!c�F�|jd�}t|tj�sJ�|tj|j����}|jd�}t|t�sJ�||_|jd�}t|t�sJ�t|�|d<|j|dd�|j|dd	�|j|d
d�|j|dd
�|j|dd�|j|dd�|jd�}t|t�sJ�|jtj|��|j�|jd�dk7r|j|�|S)a]Convert the givin systemd coredump into a problem report.

        The following keys are not used:
         * COREDUMP_CGROUP (str)
         * COREDUMP_COMM (str)
         * COREDUMP_CONTAINER_CMDLINE (str)
         * COREDUMP_GID (int)
         * COREDUMP_HOSTNAME (str)
         * COREDUMP_OPEN_FDS (str)
         * COREDUMP_OWNER_UID (str)
         * COREDUMP_PACKAGE_JSON (str)
         * COREDUMP_PACKAGE_NAME
         * COREDUMP_PACKAGE_VERSION
         * COREDUMP_PROC_AUXV (bytes)
         * COREDUMP_PROC_CGROUP (str)
         * COREDUMP_PROC_LIMITS (str)
         * COREDUMP_PROC_MOUNTINFO (str)
         * COREDUMP_RLIMIT (str)
         * COREDUMP_ROOT (str)
         * COREDUMP_SESSION
         * COREDUMP_SLICE (str)
         * COREDUMP_UID (int)
         * COREDUMP_UNIT (str)
         * COREDUMP_USER_UNIT (str)
         * MESSAGE (str)
        �COREDUMP_TIMESTAMP)r��COREDUMP_PID�COREDUMP_SIGNALr�COREDUMP_SIGNAL_NAMEr �COREDUMP_CMDLINErA�COREDUMP_EXEr��COREDUMP_CWDrH�COREDUMP_PROC_MAPSrm�COREDUMP_PROC_STATUSr?�COREDUMP_ENVIRON�COREDUMP_TRUNCATED�1)r�rt�datetime�time�asctime�	timetuplerur.rDr�r�r�r�r}r�)r�r�r�r}r.r#r�s       r�from_systemd_coredumpzReport.from_systemd_coredump�sp��8�|�|�0�1���$�� 1� 1�2�2�2��$�,�,�t�~�~�'7�8�9���l�l�>�*���#�s�#�#�#���
� ���%6�7�
��-��-�-�-��}�-��x���%�%�h�0F��U��%�%�h�0B�M�R��%�%�h��@P�Q��%�%�h��	�J��%�%�h�0D�j�Q��%�%�h�0F��U��,�,�1�2���'�3�'�'�'����L�4�4�W�=�>��(�(�*��:�:�*�+�s�2��6�6�x�@��
r7)�CrashNr;r�)NNN�NN):r�r�r�r�rDr��staticmethodr�r�r�r�rrr)r8rYrSrOrurr�r}r|r�r��boolr�r�r�rr�r�rrr%r2r=rBrErYr]rh�listrqr�r{r�r��tuple�dictr�r�r��objectr�r�r�r�r�r7rr�r�Ts.���H�S�H�#��*�H�PT�H���C��C����.�3��3��:��*�C��C��&$N��d�
�$N�d�$N�L(<�T,�#�,�$�,�4G�$'�4RV�h�C�$�J��0��C��C�$�J����!%�"&�)-�	^�
�3�Y��
�^��4�Z�^��3�-�$�&�	^�

�^�@Y�
�)-�"&�	-�
�4�Z�-��3�-�$�&�-��4�Z�	-�

�-�>GK�&
�#�&
�/7��}�t�/C�&
�	
�&
�P"�t�"�JEI�~D��T�z�~D�7:�T�z�~D�	
�~D�@M<�b!�"�!%�	��T�M���t����$�J�	�

��.B��B�#&��:�B�;>��:�B�	
�B�H)�s�T�z�)�c�D�j�)�V�.��.�`-�#�-�5�t�5�n+�Z?�t�?�"��t���-�S�4�Z�-�^
��t��
�,9��d�
�9�v�4��9��&N��t��N�`��C��C�$�J����:N�3��:�:N�x7=�t>B�o ��T�z�o �03�d�
�o �	�t�C�y�$�s�C�x�.�(�	)�o �b�,�B#��S�&�[�)�#�9<�#�CF�#�	
�#��D��f��<M��RV��$�6��6r7r�r�)Ni)Mr�r�r�rzr<rr0�importlib.utilrcrAr�r4r#r,rer�r!r�rXr�r�r�r��urllib.errorr�urllib.parse�urllib.request�xml.domrj�xml.dom.minidom�xml.parsers.expat�collections.abcrr�apport.fileutilsr��apport.loggingru�apport.hookutilsr�apport.packaging_implrr�	apport.uirrr�r��	_data_dirrr�r�rr*r,r+r-rLrrDr,rur6rGrOr�r�r/rbr�r�r�r�r�r�r�r�r�r7r�<module>r�s���A������
��	��	��
�	�
�
���
����������.����,�3�2��J�J�N�N�,�.A�B�	��[��0���[��0�����z�z�~�~�2�4J�K��,�
�*��0��1����&	5�
�S�
�X�c�]�
�=A�
.�

�
.��$�J�
.�/2�T�z�
.��
.�=A�&�

�&��$�J�&�/2�T�z�&��&�&�*MQ�#�
�#�Y�#�!�#�s�(�^�d�2�#�DI�#��#�L!/�H�!��:,� 
�4��S��>� 
�PV�^�
)�
)�Vr7

Zerion Mini Shell 1.0