Submit
Path:
~
/
/
lib
/
python3
/
dist-packages
/
File Content:
apport_python_hook.py
'''Python sys.excepthook hook to generate apport crash dumps.''' # Copyright (c) 2006 - 2009 Canonical Ltd. # Authors: Robert Collins <robert@ubuntu.com> # Martin Pitt <martin.pitt@ubuntu.com> # # 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. See http://www.gnu.org/copyleft/gpl.html for # the full text of the license. import os import sys CONFIG = '/etc/default/apport' def enabled(): '''Return whether Apport should generate crash reports.''' # This doesn't use apport.packaging.enabled() because it is too heavyweight # See LP: #528355 import re try: with open(CONFIG) as f: conf = f.read() return re.search(r'^\s*enabled\s*=\s*0\s*$', conf, re.M) is None except IOError: # if the file does not exist, assume it's enabled return True def apport_excepthook(exc_type, exc_obj, exc_tb): '''Catch an uncaught exception and make a traceback.''' # create and save a problem report. Note that exceptions in this code # are bad, and we probably need a per-thread reentrancy guard to # prevent that happening. However, on Ubuntu there should never be # a reason for an exception here, other than [say] a read only var # or some such. So what we do is use a try - finally to ensure that # the original excepthook is invoked, and until we get bug reports # ignore the other issues. # import locally here so that there is no routine overhead on python # startup time - only when a traceback occurs will this trigger. try: # ignore 'safe' exit types. if exc_type in (KeyboardInterrupt, ): return # if python apt modules are not built for the python version than it # is not supported. LP: #1774843 try: import apt_pkg # make pyflakes happy apt_pkg.DATE except ImportError: return # do not do anything if apport was disabled if not enabled(): return try: from cStringIO import StringIO StringIO # pyflakes except ImportError: from io import StringIO import re, traceback from apport.fileutils import likely_packaged, get_recent_crashes # apport will look up the package from the executable path. try: binary = os.path.realpath(os.path.join(os.getcwd(), sys.argv[0])) except (TypeError, AttributeError, IndexError): # the module has mutated sys.argv, plan B try: binary = os.readlink('/proc/%i/exe' % os.getpid()) except OSError: return # for interactive python sessions, sys.argv[0] == ''; catch that and # other irregularities if not os.access(binary, os.X_OK) or not os.path.isfile(binary): return # filter out binaries in user accessible paths if not likely_packaged(binary): return import apport.report pr = apport.report.Report() # special handling of dbus-python exceptions if hasattr(exc_obj, 'get_dbus_name'): name = exc_obj.get_dbus_name() if name == 'org.freedesktop.DBus.Error.NoReply': # NoReply is an useless crash, we do not even get the method it # was trying to call; needs actual crash from D-BUS backend (LP #914220) return elif name == 'org.freedesktop.DBus.Error.ServiceUnknown': dbus_service_unknown_analysis(exc_obj, pr) else: pr['_PythonExceptionQualifier'] = name # disambiguate OSErrors with errno: if exc_type == OSError and exc_obj.errno is not None: pr['_PythonExceptionQualifier'] = str(exc_obj.errno) # append a basic traceback. In future we may want to include # additional data such as the local variables, loaded modules etc. tb_file = StringIO() traceback.print_exception(exc_type, exc_obj, exc_tb, file=tb_file) pr['Traceback'] = tb_file.getvalue().strip() pr.add_proc_info(extraenv=['PYTHONPATH', 'PYTHONHOME']) pr.add_user_info() # override the ExecutablePath with the script that was actually running pr['ExecutablePath'] = binary if 'ExecutableTimestamp' in pr: pr['ExecutableTimestamp'] = str(int(os.stat(binary).st_mtime)) try: pr['PythonArgs'] = '%r' % sys.argv except AttributeError: pass if pr.check_ignored(): return mangled_program = re.sub('/', '_', binary) # get the uid for now, user name later user = os.getuid() pr_filename = '%s/%s.%i.crash' % (os.environ.get( 'APPORT_REPORT_DIR', '/var/crash'), mangled_program, user) crash_counter = 0 if os.path.exists(pr_filename): if apport.fileutils.seen_report(pr_filename): # flood protection with open(pr_filename, 'rb') as f: crash_counter = get_recent_crashes(f) + 1 if crash_counter > 1: return # remove the old file, so that we can create the new one with # os.O_CREAT|os.O_EXCL os.unlink(pr_filename) else: # don't clobber existing report return if crash_counter: pr['CrashCounter'] = str(crash_counter) with os.fdopen(os.open(pr_filename, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o640), 'wb') as f: pr.write(f) finally: # resume original processing to get the default behaviour, # but do not trigger an AttributeError on interpreter shutdown. if sys: sys.__excepthook__(exc_type, exc_obj, exc_tb) def dbus_service_unknown_analysis(exc_obj, report): from glob import glob import subprocess, re try: from configparser import ConfigParser, NoSectionError, NoOptionError (ConfigParser, NoSectionError, NoOptionError) # pyflakes except ImportError: # Python 2 from ConfigParser import ConfigParser, NoSectionError, NoOptionError # determine D-BUS name m = re.search(r'name\s+(\S+)\s+was not provided by any .service', exc_obj.get_dbus_message()) if not m: if sys.stderr: sys.stderr.write('Error: cannot parse D-BUS name from exception: ' + exc_obj.get_dbus_message()) return dbus_name = m.group(1) # determine .service file and Exec name for the D-BUS name services = [] # tuples of (service file, exe name, running) for f in glob('/usr/share/dbus-1/*services/*.service'): cp = ConfigParser(interpolation=None) cp.read(f, encoding='UTF-8') try: if cp.get('D-BUS Service', 'Name') == dbus_name: exe = cp.get('D-BUS Service', 'Exec') running = (subprocess.call(['pidof', '-sx', exe], stdout=subprocess.PIPE) == 0) services.append((f, exe, running)) except (NoSectionError, NoOptionError): if sys.stderr: sys.stderr.write('Invalid D-BUS .service file %s: %s' % ( f, exc_obj.get_dbus_message())) continue if not services: report['DbusErrorAnalysis'] = 'no service file providing ' + dbus_name else: report['DbusErrorAnalysis'] = 'provided by' for (service, exe, running) in services: report['DbusErrorAnalysis'] += ' %s (%s is %srunning)' % ( service, exe, ('' if running else 'not ')) def install(): '''Install the python apport hook.''' sys.excepthook = apport_excepthook
Submit
FILE
FOLDER
Name
Size
Permission
Action
Babel-2.8.0.egg-info
---
0755
CommandNotFound
---
0755
DistUpgrade
---
0755
Django-3.2.12.egg-info
---
0755
Genshi-0.7.6.egg-info
---
0755
HweSupportStatus
---
0755
Jinja2-3.0.3.egg-info
---
0755
MarkupSafe-2.0.1.egg-info
---
0755
MySQLdb
---
0755
OpenSSL
---
0755
PyGObject-3.42.1.egg-info
---
0755
PyGreSQL-5.1.2.egg-info
---
0755
PyJWT-2.3.0.egg-info
---
0755
PyNaCl-1.5.0.dist-info
---
0755
PyYAML-5.4.1.egg-info
---
0755
Pygments-2.11.2.egg-info
---
0755
S3
---
0755
SecretStorage-3.3.1.egg-info
---
0755
Sphinx-4.3.2.egg-info
---
0755
Trac-1.5.3.egg-info
---
0755
UpdateManager
---
0755
__pycache__
---
0755
_distutils_hack
---
0755
_yaml
---
0755
alabaster
---
0755
alabaster-0.7.12.egg-info
---
0755
apport
---
0755
apt
---
0755
apt_inst-stubs
---
0755
apt_pkg-stubs
---
0755
aptsources
---
0755
asgiref
---
0755
asgiref-3.5.0.egg-info
---
0755
attr
---
0755
attrs-21.2.0.egg-info
---
0755
awscli
---
0755
awscli-1.22.34.egg-info
---
0755
babel
---
0755
blinker
---
0755
boto
---
0755
boto-2.49.0.egg-info
---
0755
botocore
---
0755
botocore-1.23.34.egg-info
---
0755
certifi
---
0755
certifi-2020.6.20.egg-info
---
0755
chardet
---
0755
chardet-4.0.0.egg-info
---
0755
colorama
---
0755
colorama-0.4.4.egg-info
---
0755
cryptography
---
0755
cryptography-3.4.8.egg-info
---
0755
curl
---
0755
dateutil
---
0755
dbus
---
0755
dbus_python-1.2.18.egg-info
---
0755
debian
---
0755
debian_bundle
---
0755
devscripts
---
0755
devscripts-2.22.1ubuntu1.egg-info
---
0755
distlib
---
0755
distlib-0.3.4.egg-info
---
0755
distro
---
0755
distro-1.7.0.egg-info
---
0755
distro_info-1.1+ubuntu0.2.egg-info
---
0755
django
---
0755
docutils
---
0755
docutils-0.17.1.egg-info
---
0755
duplicity
---
0755
duplicity-0.8.21.egg-info
---
0755
fail2ban
---
0755
fail2ban-0.11.2.egg-info
---
0755
fasteners
---
0755
fasteners-0.14.1.egg-info
---
0755
filelock
---
0755
filelock-3.6.0.egg-info
---
0755
future
---
0755
future-0.18.2.egg-info
---
0755
genshi
---
0755
gi
---
0755
hgdemandimport
---
0755
hgext
---
0755
hgext3rd
---
0755
httplib2
---
0755
httplib2-0.20.2.egg-info
---
0755
idna
---
0755
idna-3.3.egg-info
---
0755
imagesize-1.3.0.egg-info
---
0755
importlib_metadata
---
0755
importlib_metadata-4.6.4.egg-info
---
0755
iotop
---
0755
janitor
---
0755
jeepney
---
0755
jeepney-0.7.1.dist-info
---
0755
jinja2
---
0755
jmespath
---
0755
jmespath-0.10.0.egg-info
---
0755
jsonpatch-1.32.egg-info
---
0755
jsonpointer-2.0.egg-info
---
0755
jsonschema
---
0755
jsonschema-3.2.0.egg-info
---
0755
jwt
---
0755
keyring
---
0755
keyring-23.5.0.egg-info
---
0755
launchpadlib
---
0755
launchpadlib-1.10.16.egg-info
---
0755
lazr
---
0755
lazr.restfulclient-0.14.4.egg-info
---
0755
lazr.uri-1.0.6.egg-info
---
0755
libfuturize
---
0755
libpasteurize
---
0755
lockfile
---
0755
lockfile-0.12.2.egg-info
---
0755
magic
---
0755
markupsafe
---
0755
mercurial
---
0755
monotonic-1.6.egg-info
---
0755
more_itertools
---
0755
more_itertools-8.10.0.egg-info
---
0755
mysqlclient-1.4.6.egg-info
---
0755
nacl
---
0755
netifaces-0.11.0.egg-info
---
0755
netplan
---
0755
numpy
---
0755
numpy-1.21.5.egg-info
---
0755
oauthlib
---
0755
oauthlib-3.2.0.egg-info
---
0755
packaging
---
0755
packaging-21.3.egg-info
---
0755
past
---
0755
pexpect
---
0755
pip
---
0755
pip-22.0.2.dist-info
---
0755
pkg_resources
---
0755
platformdirs
---
0755
platformdirs-2.5.1.dist-info
---
0755
psycopg2
---
0755
psycopg2-2.9.2.egg-info
---
0755
ptyprocess
---
0755
ptyprocess-0.7.0.dist-info
---
0755
pyOpenSSL-21.0.0.egg-info
---
0755
pyasn1
---
0755
pyasn1-0.4.8.egg-info
---
0755
pycurl-7.44.1.egg-info
---
0755
pygments
---
0755
pygtkcompat
---
0755
pymacaroons
---
0755
pymacaroons-0.13.0.egg-info
---
0755
pyparsing-2.4.7.egg-info
---
0755
pyrsistent
---
0755
pyrsistent-0.18.1.egg-info
---
0755
pyserial-3.5.egg-info
---
0755
pysvn
---
0755
pysvn-1.9.15.egg-info
---
0755
python_apt-2.4.0+ubuntu4.1.egg-info
---
0755
python_dateutil-2.8.1.egg-info
---
0755
python_debian-0.1.43+ubuntu1.1.egg-info
---
0755
python_magic-0.4.24.egg-info
---
0755
pytz
---
0755
pytz-2022.1.egg-info
---
0755
requests
---
0755
requests-2.25.1.egg-info
---
0755
roman-3.3.egg-info
---
0755
rsa
---
0755
rsa-4.8.egg-info
---
0755
s3cmd-2.2.0.egg-info
---
0755
s3transfer
---
0755
s3transfer-0.5.0.egg-info
---
0755
secretstorage
---
0755
serial
---
0755
setuptools
---
0755
setuptools-59.6.0.egg-info
---
0755
simplejson
---
0755
simplejson-3.17.6.egg-info
---
0755
six-1.16.0.egg-info
---
0755
snowballstemmer
---
0755
snowballstemmer-2.2.0.egg-info
---
0755
softwareproperties
---
0755
sos
---
0755
sos-4.9.2.egg-info
---
0755
sphinx
---
0755
sqlparse
---
0755
sqlparse-0.4.2.egg-info
---
0755
ssh_import_id
---
0755
ssh_import_id-5.11.egg-info
---
0755
systemd
---
0755
trac
---
0755
tracopt
---
0755
twisted
---
0755
uaclient
---
0755
ubuntu_pro_client-8001.egg-info
---
0755
ufw
---
0755
unattended_upgrades-0.1.egg-info
---
0755
urllib3
---
0755
urllib3-1.26.5.egg-info
---
0755
virtualenv
---
0755
virtualenv-20.13.0+ds.dist-info
---
0755
wadllib
---
0755
wadllib-1.3.6.egg-info
---
0755
wheel
---
0755
wheel-0.37.1.egg-info
---
0755
xapian
---
0755
yaml
---
0755
zipp-1.0.0.egg-info
---
0755
_cffi_backend.cpython-310-x86_64-linux-gnu.so
194472 bytes
0644
_dbus_bindings.cpython-310-x86_64-linux-gnu.so
168152 bytes
0644
_dbus_glib_bindings.cpython-310-x86_64-linux-gnu.so
23040 bytes
0644
_pg.cpython-310-x86_64-linux-gnu.so
114376 bytes
0644
_pyrsistent_version.py
23 bytes
0644
_snack.cpython-310-x86_64-linux-gnu.so
47888 bytes
0644
apport_python_hook.py
8063 bytes
0644
apt_inst.cpython-310-x86_64-linux-gnu.so
60064 bytes
0644
apt_pkg.cpython-310-x86_64-linux-gnu.so
347096 bytes
0644
blinker-1.4.egg-info
3901 bytes
0644
command_not_found-0.3.egg-info
189 bytes
0644
deb822.py
273 bytes
0644
debconf.py
6769 bytes
0644
distro_info.py
12528 bytes
0644
drv_libxml2.py
15376 bytes
0644
imagesize.py
13352 bytes
0644
iotop-0.6.egg-info
348 bytes
0644
jsonpatch.py
28813 bytes
0644
jsonpointer.py
9796 bytes
0644
libxml2.py
346308 bytes
0644
libxml2mod.cpython-310-x86_64-linux-gnu.so
437808 bytes
0644
lsb_release.py
14901 bytes
0644
mercurial-6.1.1-py3.10.egg-info
1330 bytes
0644
monotonic.py
7169 bytes
0644
netifaces.cpython-310-x86_64-linux-gnu.so
23232 bytes
0644
pexpect-4.8.0.egg-info
2285 bytes
0644
pg.py
102204 bytes
0644
pgdb.py
63567 bytes
0644
problem_report.py
26867 bytes
0644
pvectorc.cpython-310-x86_64-linux-gnu.so
37552 bytes
0644
pycurl.cpython-310-x86_64-linux-gnu.so
143976 bytes
0644
pyparsing.py
273365 bytes
0644
roman.py
3664 bytes
0644
schedutils-0.6.egg-info
291 bytes
0644
schedutils.cpython-310-x86_64-linux-gnu.so
15136 bytes
0644
six.py
34549 bytes
0644
snack.py
31134 bytes
0644
systemd_python-234.egg-info
586 bytes
0644
ufw-0.36.1.egg-info
263 bytes
0644
zipp.py
6914 bytes
0644
N4ST4R_ID | Naxtarrr