Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/apport/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/apport/__pycache__/report.cpython-310.pyc
o

�v�f��@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZe
jdkrndZddlmZddlmZddlmZeefnd	ZddlmZddlmZe Zddl!Z!ddl"Z"ddl#Z"dd
l$m%Z&ddl'm(Z(ej)�*dd
�Z+de+Z,de+Z-dZ.dZ/dZ0dZ1gd�Z2dd�Z3d+dd�Z4d+dd�Z5dd�Z6d+dd�Z7dd �Z8d!d"�Z9d#d$�Z:d%d&�Z;d'd(�Z<Gd)d*�d*e!j=�Z>dS),z;Representation of and data collection for a problem report.�N)�
ExpatError�3F)�URLError)�urlopen)�unquoteT)�impl)�kill_pkttyagent�APPORT_DATA_DIRz/usr/share/apportz%s/package-hooks/z%s/general-hooks/z/optz~/.apport-ignore.xmlz/etc/apport/blacklist.dz/etc/apport/whitelist.d)�sh�bash�dash�csh�tcshzpython*zruby*�phpzperl*zmono*�awkcCsTzt�|�Wn
tyYdSwt�|�D]}||vr'|�|�t||�qdS)z7Recursively add dependencies of package to depends_set.N)�	packaging�get_version�
ValueError�get_dependencies�add�_transitive_dependencies)�package�depends_set�d�r�//usr/lib/python3/dist-packages/apport/report.pyr9s�

��rcCs,ts
|dur
tj||d�St�d||f�S)zrUse readlink() to resolve link.

    Return a string representing the path to which the symbolic link points.
    N��dir_fd�/proc/%s/%s)�_python2�os�readlink)�path�pidrrrr�_read_proc_linkFsr$c
Cs�z>ts|durtj|tjtjB|d�}nd||f}t�|d��}|����jddd�Wd�WS1s7wYWdSt	t
fyX}zdt|�WYd}~Sd}~ww)	zXRead file content.

    Return its content, or return a textual error if it failed.
    Nrr�rb�UTF-8�replace��errors�Error: )rr �open�O_RDONLY�	O_CLOEXEC�io�read�strip�decode�OSError�IOError�str)r"r#r�	proc_file�fd�errr�_read_proc_fileQs(���r8c
s�d}trdSz%td�fdd�d��}|����}Wd�W|S1s$wYW|SttfyE}zdt|�WYd}~Sd}~ww)	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 filezDError: python2 does not provide a secure way to read /proc maps file�mapscstj||�d�S)Nr)r r+)r"�mode��proc_pid_fdrr�<lambda>nsz_read_maps.<locals>.<lambda>)�openerNr*)rr+r/r0r2r3r4)r<r9r6r7rr;r�
_read_mapsbs�����r?cCs�tj|tjtj|d�}z|j|dd�d}Wntjy4|��|��\}}tdt|�|j	|f��w|j	dkr<|S|rF|j
ddd�}nd	}td
t|�|j	|f��)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.
    )�stdout�stderr�envi)�input�timeoutrz0Error: command %s timedout with exit code %i: %sr&r'r(�z.Error: command %s failed with exit code %i: %s)�
subprocess�Popen�PIPE�STDOUT�communicate�TimeoutExpired�killr2r4�
returncoder1)�commandrCrB�sp�out�errsrrr�_command_outputus(
���
�rRc	CsTtr|j�d�s
dSnd|jvrdS|jD]�}|jtjjjkr�|j	dkr�z|jdj
}Wn	ty5Yqw||vr=dS|��|�
�r�|jdjtjjjkr�|jdj
}tr]|�d�}||}t|tj�rs|��}tsr|�d�}nt|t�rts|�d�}zt�|�}Wn	ty�Yqw|�|�s�dSqtr�|jdj
�d�S|jdj
S)zxCheck if given report matches the given bug pattern XML DOM node.

    Return the bug URL on match, otherwise None.
    �urlN�re�keyrr&)r�
attributes�has_key�
childNodes�nodeType�xml�dom�Node�ELEMENT_NODE�nodeName�	nodeValue�KeyError�	normalize�
hasChildNodes�	TEXT_NODE�encode�
isinstance�problem_report�CompressedValue�	get_value�bytesrT�compile�	Exception�search)�report�pattern�crU�regexp�v�re_crrr�_check_bug_pattern�sP�

�

�

�
�rsc	Csdztr|�d�}tjj�|�}WnttfyYdSw|�d�D]
}t	||�}|r/|Sq"dS)Nr&rn)
rrdrZr[�minidom�parseStringr�UnicodeEncodeError�getElementsByTagNamers)rm�patternsr[rnrSrrr�_check_bug_patterns�s
�
�rycCsJ|jD]}|jtjjjkr|j��dkr|��|�	|�qt
|�qdS)z6Recursively remove whitespace from given XML DOM node.rEN)rXrYrZr[r\rcr_r0�unlink�removeChild�_dom_remove_space)�noderorrrr|�s

�r|c
Cstj�|�sdSi}zNt|��}tt|��|d�|�Wd�n1s%wYz|d||�WWdStyX}zt|��	d�rK|d|�n�WYd}~WdSd}~wwt
ybYdSty�tj�tj�
|��d�dd�}t��|d	|<t�d
|�t��YdSw)NF�exec�add_infoz
add_info()Tr�-�_�
HookError_zhook %s crashed:)r r"�existsr+r~rjr/�	TypeErrorr4�
startswith�
StopIterationrk�splitext�basenamer'�	traceback�
format_exc�apport�error�	print_exc)rm�ui�hook�symbr6r7�hooknamerrr�	_run_hook�s6
����� 
�r�cCs�|r$tj��}|�dd��tj�}|�tj�|dd�<tj�|�|d<nd}ztjd|g|d��	��
�WStjy?YdSw)z-Return path of command, preferring extra_path�PATHrErN�which�rB)r �environ�copy�get�split�pathsep�joinrF�check_outputr1r0�CalledProcessError)rN�
extra_pathrB�partsrrr�_which_extrapath�s
�r�c@s>eZdZdZdFdd�Zdd�Zdd	�ZdGd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Ze
dd��Zddgfdd�Zdgdfdd�ZdGdd�ZdHdd�Zd d!�ZdHd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!dGd>d?�Z"d@dA�Z#dBdC�Z$e%dHdDdE��Z&dS)I�Reportz�A problem report specific to apport (crash or bug).

    This class wraps a standard ProblemReport and adds methods for collecting
    standard debugging data.�CrashNcCs tj�|||�d|_d|_dS)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)rf�
ProblemReport�__init__r#�_proc_maps_cache)�self�type�daterrrr�s	
zReport.__init__cCsxd}t�|�}|r|dd�|�7}zt�|�s/t�|�}|r(|d|7}W|S|d7}W|SW|Sty;Y|Sw)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.
        rEz [modified: %s]� z
 [origin: %s]z [origin: unknown])r�get_modified_filesr��is_distro_package�get_package_originr)r�r�suffix�mod�originrrr�_customized_package_suffixs$



��
��z!Report._customized_package_suffixcCsFzt�|�}Wntyd}Ynwd||pd|�|�f|d<|S)aAdd 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).
        N�%s %s%sz(not installed)�Package)rrrr�)r�r�versionrrr�add_package6s	�

�zReport.add_packagec
Cs|sd|vr|ddkr|d}ntj�|d�}|sdS|�|�}|s(d|vr;z	t�|�|d<Wn	ty:Ynw|s?dSt�|�|d<tg�}t	||�d|d	<t
|�D]/}zt�|�}Wn	tyiYqWw|d	rv|d	d
7<|d	d|||�|�f7<qWdS)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�PackageArchitecturerE�Dependencies�
r�)
r��	fileutils�find_file_packager�r�
get_sourcer�get_architecture�setr�sortedrr�)r�rr��dependencies�deprqrrr�add_package_infoIs>


�
�
��zReport.add_package_infoc
Cs�d|�d�|�d�|�dd�f|d<|�d�}tddd	|g�|d
<tdd|g�|d<tdd
d	|g�|d|<ddl}td|��
}|�|�}Wd�n1sQwYd|vrj|d}tdd
d	|g�|d|<g}d|vr�|dD]}|d|�d�}	|	r�|	|vr�|�|	�qt|D]}
tdd
d	|
g�|d|
<q�|�d�r�d}t�|t|�dd���}|r�|�	d�r�|�	d�|d<|�	d�r�|�	d�|d<dSdSdSdSdS)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.
        z
%s %s (%s)�namer��channel�unknown�Snap�snap�changesz
--abs-timezSnap.Changes�connectionszSnap.Connections�infozSnap.Info.%srNz/snap/%s/current/meta/snap.yaml�base�plugszdefault-provider�contactzX^https?:\/\/.*launchpad\.net\/((?:[^\/]+\/\+source\/)?[^\/]+)(?:.*field\.tags?=([^&]+))?rE��
SnapSource��SnapTags)
r�rR�yamlr+�	safe_load�appendrTrlr�group)
r�r��snapnamer��f�	snap_metar��	providers�plug�dp�provider�p�mrrr�
add_snap_info~sL

�
��
��
�
��

�zReport.add_snap_infocCsdd|vr
dtj��|d<d|vr$t��}d|d|d|df|d<d|vr0t��|d<d	Sd	S)
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
        �
DistroReleasez%s %s�Unamez%s %s %srr���ArchitectureN)r�r�get_os_versionr �uname�get_system_architecture)r��urrr�add_os_info�s	�zReport.add_os_infocsRt�t���d��fdd�t��D�}|��|r#d�|�|d<dSd|d<dS)zoAdd information about the user.

        This adds:
        - UserGroups: system groups the user is in
        rcs(g|]\}}}}�|vr|dkr|�qS)i�r)�.0r�r��gid�memb��userrr�
<listcomp>�s�z(Report.add_user_info.<locals>.<listcomp>r��
UserGroupszN/AN)�pwd�getpwuidr �geteuid�grp�getgrall�sortr�)r��groupsrr�r�
add_user_info�szReport.add_user_infoc	sxd|vrdStj�|d��tt�fdd�t��sdSd}|d��D]}z
|�dd�\}}Wn	ty8Yq#w|dkrA|}nq#|sFdS|d	�d
�}gd�}t	|�dkr�|d�
d
�r�|�
d�r�|ddkr�t	|�dkr�|�|d�}|r�|d|d<||d<dSd|d|d<dS|d=t	|�dkr�|d�
d
�s^t	|�dkr�|d�
d�r�d|vr�tj�|d|d�|d<t�
|dtj�r�|d|d<tj�|d�|d<d|v�r|�k�r|D]-}t�
||dtj��r||d}	tj�tj�|	��|k�r|d|d<|	|d<nq�d|v�r8tj�|d�dk�r:|d|d<|��}
|
�r2|
|d<dSd|d<dSdSdS)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�Ncst��|�S�N)�fnmatch)�i��exebasenamerrr=�sz+Report._check_interpreted.<locals>.<lambda>�
ProcStatus�	r�zName:�ProcCmdline�)z	/usr/bin/z
/usr/sbin/z/bin/z/sbin/r�r��pythonz-m��InterpreterPathz)Cannot determine path of python module %s�UnreportableReason�.�ProcCwdr�twistdz&Cannot determine twistd client program)r r"r��any�filter�interpreters�
splitlinesr�r�lenr��_python_module_pathr��access�R_OK�realpath�_twistd_executable)r�r��line�krq�cmdargs�bindirsr"r��argvexe�exerr�r�_check_interpreted�sj��"��� 	�zReport._check_interpretedcCs�|d�d�dd�}|ro|d�dd�}|d�d�s*|d�d	�s*|d�d
�r8t|�dkr4|dS|dSt|d�dkrh|dddkrh|dddkrh|ddd�}d|vsdd
|vsdd|vrh|dS|�d�|s
dS)z5Determine the twistd client program from ProcCmdline.rrr�Nr�=r�z--filez--pythonz--sourcer�r��y�s)r�r�r�pop)r��args�arg�optsrrrrs*0
�zReport._twistd_executablecCs8ztj�|�}Wn
tyYdSw|durdS|jS)z%Determine path of given Python moduleN)�	importlib�util�	find_spec�ImportErrorr�)�module�specrrrr/s�zReport._python_module_pathc
Cs�|sO|s|jp
t��}|jst|�|_t|�}tsOzt�d|tjtjBtj	B�}Wn$t
yN}z|jtjtj
fvr?td��|jtjkrItd���d}~wwz
td||�|d<Wn	t
ybYnw|j|||d�td||�|d	<td
||��d�|d<t|�|d
<d|vr�z
td||�|d<Wn$t
y�}z|jtjtj
fvr�td��|jtjkr�td���d}~wwdD]}|d�d|�r�|dtd|�d�|d<nq�tj�|d�s�td|d��|��ttt�|d�j��|d<|d�dd��dd��dd�|d<zt��dk�r td||�}|dk�r ||d<Wntt
f�y-Ynw|�||�}|�r?|d|d<dSdS)a�Add /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
        - _LogindSession: logind cgroup path, if present (Used for filtering
          out crashes that happened in a session that is not running any more)
        �/proc/%sznot accessiblezinvalid processN�cwdr)r#r<�extraenv�statusr��cmdlinerr�ProcMapsr�r)�rofs�rwfs�	squashmnt�
persistmntz/%s/z/%sz%s does not exist�ExecutableTimestamp�\z\\r�z\ rzattr/current�
unconfined�ProcAttrCurrent�_LogindSession) r#r �getpid�intr4rr+r,�O_PATH�O_DIRECTORYr2�errno�EPERM�EACCESr�ENOENTr$�add_proc_environr8�rstripr?r�rr"r�r�stat�st_mtimer'�getuidr3�get_logind_session)r�r#r<r*r7r��val�retrrr�
add_proc_info:sx
"������$
���zReport.add_proc_infocCsgd�|}|s#|st��}t|�}ts#t�d|tjtjBtjB�}d|d<td||��	dd�}|�
d�r<||d<dS|�d	�D]�}|�d
d�d|vrb|drY|dd7<|d|7<qA|�
d
�r�|�d
d�d}d|vswd|vr�|dr�|dd7<|dd7<qA|dkr�|dr�|dd7<|dd7<qA|�
d�r�|dr�|dd7<|dd7<qA|�
d�r�|dr�|dd7<|dd7<qA|�
d�r�|dr�|dd7<|dd7<qA|�
d��r|�d
d�d|d<qAdS)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
        )�SHELL�TERM�LANGUAGE�LANG�LC_CTYPE�
LC_COLLATE�LC_TIME�
LC_NUMERIC�LC_MONETARY�LC_MESSAGES�LC_PAPER�LC_NAME�
LC_ADDRESS�LC_TELEPHONE�LC_MEASUREMENT�LC_IDENTIFICATION�LOCPATHr(rE�ProcEnvironr�r��\nzError:rrr�rzPATH=z/homez/tmpzPATH=(custom, user)zG/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/gameszPATH=(custom, no user)zXDG_RUNTIME_DIR=zXDG_RUNTIME_DIR=<set>zLD_PRELOAD=zLD_PRELOAD=<set>zLD_LIBRARY_PATH=zLD_LIBRARY_PATH=<set>zXDG_CURRENT_DESKTOP=�CurrentDesktopN)r r7r4rr+r,r9r:r8r'r�r�)r�r#r*r<�	safe_varsrBrr�rrrr?�sZ�

�


��zReport.add_proc_environc
	Cs*d|vrdSd}d}z�t|dd�r't��\}}t�||d�t�|�d}|d��d}dd	||g}ztj|tj	tj	tj
d
�}WntyXYW|rVt�|�dSdSw|j
�d�|j
�d�|j
�d
�|j
�d�|j��}	|��dk}|r�|	|d<W|r�t�|�|S|r�t�|�ww)zWAdd information from kernel crash.

        This needs a VmCore in the Report.
        �VmCoreNF�findTr�r��crashz/usr/lib/debug/boot/vmlinux-%s)�stdinr@rAz	bt -a -f
zps
zrunq
zquit
r�
Stacktrace)�hasattr�tempfile�mkstempr �write�closer�rFrGrHrIr2rzr`r@r/�wait)
r��debugdir�unlink_corerFr6�core�kverrNr�rPrrr�add_kernel_crash_info�sT
�
���
�
��zReport.add_kernel_crash_infocCs�d|vsd|vr
dSdddddd	d
d�}|�||�\}}|s)ttjt�tj�d��|gd
�7}g}|��D]\}}|�|�|ddd|g7}q5|�d�|ddg7}t||d�j	ddd�}	d|	vsed|	vr�d|	vrvd�
dd�|	��D��}
nd|	vr�d�
dd�|	��D��}
n|	��d}
d|
��}||d<t
|��|	�d�d�d �r�ttjt�tj�d!��t�d"tj�}|�|	�}
|
�d�|
D]}|�d#d$���||�d�<q�d%|vr�d&|d%vr�|d%|d'<|d%=d(|vr�|d(�d)�r�|d(|d'<|d(=d'|v�r't�d*|d'�}|�r$|�d+�|d'<|d'�d,��r#|d'dd-�|d'<n|d'=d.|v�r=|��|��}|�r?||d/<dSdSdS)0a<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 IOError 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�Disassemblyra�ThreadStacktrace�AssertionMessage�GLibAssertionMessage�NihAssertionMessagezgdb not found in retracing env)z--batch�--exzset backtrace limit 2000rtzp -99�	separatorr�r&r'r(z%is truncated: expected core file sizezis not a core dump�warning:r�cS�g|]}d|vr|�qS)rvr�r�rrrrr�0��z'Report.add_gdb_info.<locals>.<listcomp>�Warning:cSrw)rzrrxrrrr�3ryrzInvalid core dump: rzNo such file or directory.z&executable file for coredump not foundz^\$\d+\s*=\s*-99$z

z
.
rrz"ERROR:rqrs�$z(^\$\d+\s+=\s+0x[0-9a-fA-F]+\s+"(.*)"\s*$r�rZ���ra�StacktraceAddressSignature)�gdb_command�FileNotFoundErrorr;r>r �strerror�itemsr�rRr1r�r
r0r3r��endswithrTrj�	MULTILINErr'r��matchr��_gen_stacktrace_top�crash_signature_addresses)r��rootdir�gdb_sandbox�gdb_reports�gdb_cmdr��
value_keysr��cmdrP�warnings�reason�part_rer��partr��addr_signaturerrr�add_gdb_info�s���

�


��
�zReport.add_gdb_infocCsdtgd��}dgd}d}d}d}d}t�d�}t�d�}t�d�}	|d	��D]~}
|�|
�}|s9|�|
�}|s9q(|r=|r�|�d
�rQ|�d
���d�d�d}nd}|ra|�d
�s^|dvr_q(d}|�d�sj||vr�d}d}dgd}|�d�rzd}|dkr�d}q(d}|�d
�p�|�d�}
|
��d}|t|�kr�|	�|�s�|
||<|d7}q(d�	|��
�|d<dS)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�_XErrorrE�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)$rar��(N�_X)�handle_response�handle_error�XWindowEventrTr�r�r��
StacktraceTop)r�rTrjr
r�r�r�r�rr�r0)r��unwind_functions�toptrace�depth�unwound�	unwinding�unwinding_xerror�bt_fn_re�bt_fn_noaddr_re�ignore_functions_rerr��fn�frame�functionrrrr�esP








�zReport._gen_stacktrace_topcCs|�|||�}t�|S)a�Run hook script for collecting package specific data.

        A hook script needs to be in _hook_dir/<Package>.py or in
        _common_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.
        )�_add_hooks_infor)r�r�r�
srcpackagerFrrr�add_hooks_info�szReport.add_hooks_infoc
	Cs�|s|�d�}|r|��d}d|vrd||d<dS|s"|�d�}|r6|��d}d|vr6d||d<dStg}d}tj�|�dd	��}|�t�rM|}n&|rsztj	�
|�D]}|�t�rgtj�|�rg|}nqVWn	tyrYnw|r�t
|�t
t�kr�|�tj�|d
dd��tj�|�}t
|�t
t�ks}t�td
�D]}t|||�r�dSq�|r�|D]}	t||tj�|	|d��r�dSq�|r�|D]}	t||tj�|	d|��r�dSq�dS)Nr�r�/zinvalid Package: %srr�zinvalid SourcePackage: %sr�rE�sharer�z
package-hooksz/*.pyTz.pyzsource_%s.pyF)r�r��	_hook_dirr r"rr��_opt_dirr�r�	get_files�isfilerrr�r��dirname�glob�_common_hook_dirr�)
r�r�rr��	hook_dirs�opt_path�	exec_pathr�r��hook_dirrrrr��sb


������zReport._add_hooks_infoc	Csj|sdSzt|�}|��jddd�}|��Wnttfy#YdSwd|vr*dSt||�}|r3|SdS)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)rr/r1rfr3rry)r�rSr�rxrrr�search_bug_patterns�s�
zReport.search_bug_patternsc	
CsNt�t���d}t�d|�}d}d}d}zBz"t�|tjtjB�}t�	|�}t
�|j�r7t�
|d�}|�d�}WnttfyCYnwW|durN|��n|durWt�|�n|dura|��w|durkt�|�ww|dkr{tj���ddd�}n z	tjj�|�}Wnty�}z
tdtt|�f��d}~ww|j��t|j�|S)	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��~rEN�riP�r�z%s has invalid format: %s)r�r�r r��_ignore_filer'r+�
O_NOFOLLOWr,�fstatrA�S_ISREG�st_mode�fdopenr/r3r2rfrZr[�getDOMImplementation�createDocumentrtrurrr4�documentElementrar|)	r��homedir�ifpath�contentsr6r��str[r7rrr�_get_ignore_domsJ

���

��
���

zReport._get_ignore_domc	Csd|vsJ�zGt�t�D]?}z4ttj�t|���!}|D]}|��|dkr1Wd�WWdSqWd�n1s<wYWqtyKYqwWn	tyVYnwzHt	�}t�t
�D]2}z'ttj�t
|���}|D]	}|�|���qoWd�n1s�wYWq`ty�Yq`w|r�|d|vr�WdSWn	ty�Ynwz|��}Wnt
tfy�t�d�t��YdSwztt�|d�j�}Wn
ty�YdSwz!|�d�D]}|�d�|dkr�t|�d��|kr�WdSq�WdSt
tf�y
YdSw)	a\Check if current report should not be presented.

        Reports can be suppressed by per-user blacklisting in
        ~/.apport-ignore.xml (in the real UID's home) and
        /etc/apport/blacklist.d/. For environments where you are only
        interested in crashes of some programs, you can also create a whitelist
        in /etc/apport/whitelist.d/, 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�NTzCould not get ignore file:F�ignore�program�mtime)r �listdir�_blacklist_dirr+r"r�r0r3r2r��_whitelist_dirrr�rr`r�r�r�r�r8rArBrw�getAttribute�float)r�r�r6r�	whitelistr[�	cur_mtimer�rrr�
check_ignoredEs~�������������
������zReport.check_ignoredc
Cs.d|vsJ�|��}zttt�|d�j��}Wnty2}z|jtjkr-WYd}~dS�d}~ww|�	d�D]}|�
d�|dkrK|�d|�nq8|�d�}|�d|d�|�d|�|j
�|�t�t���d}t�d|�}t|d��}|j|d	d
d�Wd�n1s�wY|��dS)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��wz  r�)�	addindent�newl)r�r4r8r rArBr2r;r>rwr��setAttribute�
createElementr��appendChildr�r�r�r�r'r+�writexmlrz)r�r[r�r7r�r��ignore_file_pathr6rrr�mark_ignore�s2���
�zReport.mark_ignorecCsT|�d�sdSdd�|d��D�}t|�dkr|�d�dkS|�d�t|�dkS)	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�FcSsg|]}|�d��qS)�??)r�)r�r�rrrr��sz0Report.has_useful_stacktrace.<locals>.<listcomp>rTrg@)r�r
r�count)r��
unknown_fnrrr�has_useful_stacktrace�s
zReport.has_useful_stacktracecCs<|�dd���D]}|�d�d��}|dkr|SqdS)z(Return topmost function in StacktraceTopr�rEr�rr�N)r�r
r�r0)r�r�fnamerrr�stacktrace_top_function�s�zReport.stacktrace_top_functionc	Cs\|�d�dkrd|vrd|vrdtj�|d�|dfSd|vrvd|vrvd|vrvddd	d
dd�}|��}|r<d
|}nd}d}d|vr\d|vr\|d|dkr\|ddkr\d|d}dtj�|d�|�|�d�d|�d��||fSd|v�rd|v�r|d��}t|�dkr�dSt|�dkr�dtj�|d�|dfSt�d�}t|�d}d}|dkr�|�	||�}|r�|�
d�}	|�
d�}n|d8}|dks�tj�|d�}
|d}|�d�d}t�	d t�|�|�}|r�|�
d�}
nd}
|d!k�r	|	|dk�rd"}n|	}nd#|}d$|
||f}|
�r|d%|
7}|S|�d&�d'k�rFd'|v�rFd(|d'}|�d)��rD|d*|d)��d7}|S|�d&�d+k�rqd,|v�rq|d,}|�
d-��rg|�d.d�d}|S|�d.d�d}|S|�d&�d+k�r�d/|v�r�d}d0|v�r�|d1|d0d27}||d/d37}d4|v�r�|d5|d4d67}|d.7}|SdS)7aZCreate 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.
        �Signal�6r�rqz%s assert failure: %sr��SIGILL�SIGABRT�SIGFPE�SIGSEGV�SIGPIPE)�4r��8�11�13z in %s()rEr�r��allz [non-native %s package]z%s crashed with %s%s%szsignal �	Tracebackr�Nrz%s crashed with %srz^\s*File\s*"(\S+)".* in (.+)$r�r�����:z
^%s: (.+)$�<module>�__main__z%s()z%s crashed with %s in %sz: %sr�r�z$package %s failed to install/upgrade�ErrorMessagez: �
KernelOops�OopsTextz$------------[ cut here ]------------r��Failure�MachineType�[z] z failure�NonfreeKernelModulesz [non-free: �])r�r r"r�r�r
rrTrjr�r�r��escaper�)r��signal_namesr��
arch_mismatch�trace�trace_rer�r�r��module_pathr"�	last_line�	exception�message�context�title�oopsrrr�standard_title�s���
,��


�
���

zReport.standard_titlecCs�g}|�dd�d|�dd���D]-}|sq|��dd�\}}t�|�}|dur?|dkr?|dur?t�||�dkr?|�|�q|S)	z=Return list of obsolete packages in Package and Dependencies.r�rEr�r�Nr��Noner)r�r
r�r�get_available_version�compare_versionsr�)r��obsoleter�pkg�ver�availrrr�obsolete_packagesWs$
(
�zReport.obsolete_packagescCs�d|vr|ddvrdSd|vr8|ddkr8d}t�d�}|d��D]}|�|�}|r5|d	|�d
�7}q#|S|�d�dkrTd
|vrT|dd	|d
}t�dd|�Sd|vr�d|vr�d|d|df}t�d�}|d��}t|�dkrydS|D]}|�|�}|r�|d	|�d
�p�|�d�7}q{dS|Sd|v�r1|d��}d}t|�d
kr�t�d|d�}|r�|dd	|�d
�SdSt|�dkr�dSt�d�}|D]7}|�|�}|�r|�d�dkr�|d	|�d�7}q�|�d
�}	tj	�
|	�r�tj	�|	�}	|d|	|�d�f7}q�|d�d	�d}
z
|
d|d7}
Wn
t
�y&Ynw|dd	|
|S|ddk�rmd |v�rmd!|d v�sKd"|d v�rm|d }|�d#��r]|d$|d#7}|�d%��rk|d$|d%7}|Sd&|v�r�d'}g}|d&�d(�D]d}|�d)��r�t�d*|�}
|
�r�|
�d
�}|�s�Jd+|��|�|�|�d,��r�|�|�}|�r�|�|��q}|�d-��r�d.}�q}|�r�d}|�r�|dd/k�r�|�|�}|�r�|�|��q}d'}�q}|�r�d	�|�SdS)0a�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�)r�r�Nrar��kernelz^\s*\#\d+\s\[\w+\]\s(\w+)r�r�r�r�rqz0x[0-9a-f]{6,}�ADDRr�z%s:%sz.^(?:([\w:~]+).*|(<signal handler called>)\s*)$r�r�rEz(\w+): rrz)^\s+File "([^"]+).*line (\d+).*\sin (.*)$r�z:%s@%sr�z(%s)�_PythonExceptionQualifierr�r��suspend�resumer�z:%szdmi.bios.versionr�Fr�zBUG: unable to handlez^BUG: unable to handle (.*) at z.could not parse expected problem type line: %szIP: zCall Trace:Tr�)rTrjr
r�r�r��subrr r"�islinkrr�r`r�rlr��_extract_function_and_addressr�)r��sig�regexrr�r��linesr�loc_rer��exc_name�
in_trace_bodyr��parsedr�rrr�crash_signatureds�

�





��




�

��
zReport.crash_signaturecCs>t�d|�}|r|�d�}|sJd|��|ddkr|SdS)Nz\[.*\] (.*)$r�z,could not parse expected call trace line: %sr�?)rTrlr�)r�rr%r�rrrr�s
z$Report._extract_function_and_addresscCsd|vsd|vsd|vrdSd|dvrdSg}d}|d��D]:}|�d�rR|��d}|�d	�s3q t|d
�}|dkr=q |�|�}|rN|�|�dd
��n|d7}t|�dkrZnq |dkrit|�|dkridS|dkrst|�dks}|dkrt|�dkrdSd|d|dd�|�fS)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.
        r-rar�NzErrno 13r�#r��0x�ir�z..�r�r�z%s:%s:%sr�)	r
r�r�r8�_address_to_offsetr�r'rr�)r��stack�failedr�addr�offsetrrrr��s<



�(�z Report.crash_signature_addressesc		Cs�g}t��dkr\t�t���}t|d�dkr(|�t�dt�	|d��df�|�t�dt�	|d��df�|d�
d�D]}|��}t|�dkr[|�t�d	t�	|��d
f�q@t��d}t|�dkrw|�t�dt�	|��df�z|d
=Wn	t
y�Ynw|D]I}|�d�o�|dv}|s�d|vs�|dvr�t||d�s�q�|D])\}}t||�tkr�|�|||jddd���d�||<q�|�|||�||<q�q�dS)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.
        rr�z\b%s\b�usernamer�z/home/usernamer��,z(\b|\s)%s\bz\1User Namer��hostnamer�Proc)�ProcCpuinfor-r��ProcInterrupts�ProcModulesra)r��
PythonArgs�Title�
JournalErrors�isspacer&r'r(N)r rCr�r�r�rr�rTrjrr�r0r�r`r�rbr�rirr1rd)	r��replacementsr�rr4r�
is_proc_fieldrn�replrrr�	anonymize7s<""�
�&��zReport.anonymizec
Cs*d|vsJ�|�d|d�}d}d|vr|dt��krd}|r(tj�|dd�nd}td	|�}|s3d
S|g}d}|sKtd|�}	|	rE|	g}ntj�	d�|r�d
}
|dd|dd|dd|dd||
||
fg7}|r�d|||
||
|f}d|}||d||
fd�}|�
dd||
f�|dd|g7}|d|}|dd|g7}d|v�rt|dd�r�tj
dd�\}
}t�tj|�t�	|
|d�t�|
�n?t|dd ��rtj
dd�\}
}t�tj|�t�|
�t|d!��}|d�	|�Wd�n1s�wYn|dd}|dd"|g7}||fS)#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�rFr�T�usr�binN�gdb)rErEz
gdb-multiarchzWARNING: Please install gdb-multiarch for processing reports from foreign architectures. Results with "gdb" will be very poor.
zx86_64-linux-gnurtz)set debug-file-directory %s/usr/lib/debugzset solib-absolute-prefix zadd-auto-load-safe-path z-set solib-search-path %s/lib/%s:%s/usr/lib/%sz)%s/lib:%s/lib/%s:%s/usr/lib/%s:%s/usr/libz%s/usrz%s/usr/lib/%s/gconv)�LD_LIBRARY_PATH�
PYTHONHOME�
GCONV_PATHrz%s/lib/%s/ld-linux-x86-64.so.2z#set data-directory %s/usr/share/gdbr�z	file "%s"rmr^�apport_core_)�prefix�	gzipvalue�wbz
core-file )r�rr�r r"r�r��sysrAre�insertrbrcrd�atexit�registerrzrfr+)r��sandboxr��
executable�	same_arch�gdb_sandbox_bin�gdb_pathrNr��ma�native_multiarch�ld_lib_path�pyhomer6rjr�rrrr~as�
��

�
��������

��zReport.gdb_commandcCsB|��|jD]\}}}||kr||krd|||fSqdS)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.
        z%s+%xN)�_build_proc_maps_cacher�)r�r0�start�end�elfrrrr-�s�zReport._address_to_offsetcCs�|jrdSd|vsJ�g|_t�d�}t�d�}|d��D]4}|��s%q|�|�}|s:|�|�r2q|s:Jd|��|j�t|�d�d�t|�d�d�|�d	�f�qdS)
z_Generate self._proc_maps_cache from ProcMaps field.

        This only gets done once.
        Nr-z-^([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*r�r)	r�rTrjr
r0r�r�r8r�)r��fmt�fmt_unknownrr�rrrrX�s$



��zReport._build_proc_maps_cachec	Cs�ts|durtjdtj|d�}nd|}zPt�|��6}|D]!}|��}d|vr>|�d�r>d|vr>|�dd�ddd	�}nq	Wd�WdSWd�n1sSwYt�d
|�j	}W||fSt
tfypYdSw)z�Get logind session path and start time.

        Return (session_id, session_start_timestamp) if process is in a logind
        session, or None otherwise.
        N�cgrouprz/proc/%s/cgroupz
name=systemd:z.scopez	/session-r�i����z/run/systemd/sessions/)rr r+r,r.r0r�r�rArBr3r2)�klassr#r<�cgroup_filer�r�
my_session�session_start_timerrrrD�s(���	��zReport.get_logind_session)r�Nr��NN)'�__name__�
__module__�__qualname__�__doc__r�r�r�r�r�r�r�rr�staticmethodrrGr?rlr�r�r�r�r�r�r�r�r�r�rrr&rr�r@r~r-rX�classmethodrDrrrrr�sN


5+M

Z
;
)m
>;+-F.


	>
*Y r�rc)?rgrFrc�os.pathr rTr�r�r.r�r�r�r;rKrM�importlib.utilr"rA�xml.domrZ�xml.dom.minidom�xml.parsers.expatrr�r�urllib.errorr�urllib.requestr�urllib.parser�urllibr3rfr��apport.fileutils�apport.packaging_implrr�apport.hookutilsrr�r��	_data_dirr�r�r�r�r�r�rrr$r8r?rRrsryr|r�r�r�r�rrrr�<module>sN@@




/

Spamworldpro Mini