| Server IP : 104.21.84.107 / Your IP : 104.23.197.209 Web Server : Apache/2.4.63 (Ubuntu) System : Linux adminpruebas-Virtual-Machine 6.14.0-37-generic #37-Ubuntu SMP PREEMPT_DYNAMIC Fri Nov 14 22:10:32 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.4.5 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/apport/package-hooks/ |
Upload File : |
"""Apport integration to provide better problem reports."""
# Copyright (C) 2010-2011 Sebastian Heinlein <[email protected]>
#
# Licensed under the GNU General Public License Version 2
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
__author__ = "Sebastian Heinlein <[email protected]>"
import os
import re
import apport
import apport.hookutils
import apt_pkg
apt_pkg.init()
def add_info(report):
"""Collect and append additional information about a crash.
Note: Please consider that aptdaemon also manually creates
apport reports for failed transaction which don't result
in a crash of aptdaemon, see aptdaemon.crash
:param report: The apport report of an aptdaemon crash
"""
# Attach apt configuration
report["AptConfig"] = apt_pkg.config.dump()
# Attach the sources list
sources_list = ""
etc_main = os.path.join(apt_pkg.config.find_dir("Dir::Etc"),
apt_pkg.config.find_file("Dir::Etc::sourcelist"))
try:
with open(etc_main) as fd_main:
sources_list += fd_main.read()
except:
pass
dir_parts = os.path.join(apt_pkg.config.find_dir("Dir::Etc"),
apt_pkg.config.find_dir("Dir::Etc::Sourceparts"))
for filename in os.listdir(dir_parts):
if not filename.endswith(".list"):
continue
try:
with open(os.path.join(dir_parts, filename)) as fd_part:
sources_list += fd_part.read()
except:
continue
# Remove passwords from the sources list
report["SourcesList"] = re.sub("://\w+?:\w+?@", "://USER:SECRET@",
sources_list)
# Add some logging data
apport.hookutils.attach_file_if_exists(report, "/var/log/apt/history.log"
"AptHistoryLog")
apport.hookutils.attach_file_if_exists(report, "/var/log/apt/term.log",
"AptTermLog")
apport.hookutils.attach_file_if_exists(report, "/var/log/dpkg.log",
"DpkgLog")
report["SysLog"] = apport.hookutils.recent_syslog(re.compile("AptDaemon"))
# vim:ts=4:sw=4:et