def attach_cloud_init_logs(report, ui=None): '''Attach cloud-init logs and tarfile from 'cloud-init collect-logs'.''' attach_root_command_outputs(report, { 'cloud-init-log-warnings': 'egrep -i "warn|error" /var/log/cloud-init.log', 'cloud-init-output.log.txt': 'cat /var/log/cloud-init-output.log'}) root_command_output( ['cloud-init', 'collect-logs', '-t', '/tmp/cloud-init-logs.tgz']) attach_file(report, '/tmp/cloud-init-logs.tgz', 'logs.tgz')
def attach_cloud_init_logs(report, ui=None): """Attach cloud-init logs and tarfile from 'cloud-init collect-logs'.""" attach_root_command_outputs( report, { "cloud-init-log-warnings": ('egrep -i "warn|error" /var/log/cloud-init.log'), "cloud-init-output.log.txt": "cat /var/log/cloud-init-output.log", }, ) root_command_output( ["cloud-init", "collect-logs", "-t", "/tmp/cloud-init-logs.tgz"]) attach_file(report, "/tmp/cloud-init-logs.tgz", "logs.tgz")
def add_info(report, ui): attach_file(report, '/proc/version_signature', 'ProcVersionSignature') attach_file(report, '/proc/cmdline', 'ProcKernelCmdline') sec_re = re.compile('audit\(|apparmor|selinux|security', re.IGNORECASE) report['KernLog'] = recent_kernlog(sec_re) # DBus messages are reported to syslog dbus_sec_re = re.compile('dbus.* apparmor', re.IGNORECASE) report['Syslog'] = recent_syslog(dbus_sec_re) packages = [ 'apparmor', 'apparmor-utils', 'libapparmor1', 'libapparmor-dev', 'libapparmor-perl', 'apparmor-utils', 'apparmor-docs', 'apparmor-profiles', 'apparmor-easyprof', 'python3-apparmor', 'python-apparmor', 'libpam-apparmor', 'libapache2-mod-apparmor', 'python3-libapparmor', 'python-libapparmor', 'auditd', 'libaudit0' ] versions = '' for package in packages: try: version = packaging.get_version(package) except ValueError: version = 'N/A' if version is None: version = 'N/A' versions += '%s %s\n' % (package, version) report['ApparmorPackages'] = versions # These need to be run as root report['ApparmorStatusOutput'] = root_command_output( ['/usr/sbin/apparmor_status']) report['PstreeP'] = command_output(['/usr/bin/pstree', '-p']) attach_file_if_exists(report, '/var/log/audit/audit.log', 'audit.log')
def add_info(report, ui): response = ui.yesno("The contents of your /etc/ssh/sshd_config file " "may help developers diagnose your bug more " "quickly. However, it may contain sensitive " "information. Do you want to include it in your " "bug report?") if response == None: # user cancelled raise StopIteration elif response: report['SSHDConfig'] = root_command_output(['/usr/sbin/sshd', '-T'])
def _apport_append_logfiles(report, logdir="/var/log/dist-upgrade/"): dirname = 'VarLogDistupgrade' for fname in APPORT_WHITELIST: f = os.path.join(logdir, fname) if not os.path.isfile(f) or os.path.getsize(f) == 0: continue ident = dirname + APPORT_WHITELIST[fname] if os.access(f, os.R_OK): report[ident] = (open(f), ) elif os.path.exists(f): try: from apport.hookutils import root_command_output report[ident] = root_command_output(["cat", '%s' % f], decode_utf8=False) except ImportError: logging.error("failed to import apport python module, " "can't include: %s" % ident)
def _apport_append_logfiles(report, logdir="/var/log/dist-upgrade/"): dirname = 'VarLogDistupgrade' for fname in APPORT_WHITELIST: f = os.path.join(logdir, fname) if not os.path.isfile(f) or os.path.getsize(f) == 0: continue ident = dirname + APPORT_WHITELIST[fname] if os.access(f, os.R_OK): report[ident] = (open(f), ) elif os.path.exists(f): try: from apport.hookutils import root_command_output report[ident] = root_command_output( ["cat", '%s' % f], decode_utf8=False) except ImportError: logging.error("failed to import apport python module, " "can't include: %s" % ident)
def add_info(report, ui): try: attach_gsettings_package(report, 'ubuntu-release-upgrader') except: pass report['CrashDB'] = 'ubuntu' report.setdefault('Tags', 'dist-upgrade') report['Tags'] += ' dist-upgrade' clone_file = '/var/log/dist-upgrade/apt-clone_system_state.tar.gz' if os.path.exists(clone_file): report['VarLogDistupgradeAptclonesystemstate.tar.gz'] = \ root_command_output(["cat", clone_file], decode_utf8=False) attach_file_if_exists(report, '/var/log/dist-upgrade/apt.log', 'VarLogDistupgradeAptlog') attach_file_if_exists(report, '/var/log/dist-upgrade/apt-term.log', 'VarLogDistupgradeApttermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/history.log', 'VarLogDistupgradeAptHistorylog') attach_file_if_exists(report, '/var/log/dist-upgrade/lspci.txt', 'VarLogDistupgradeLspcitxt') attach_file_if_exists(report, '/var/log/dist-upgrade/main.log', 'VarLogDistupgradeMainlog') attach_file_if_exists(report, '/var/log/dist-upgrade/term.log', 'VarLogDistupgradeTermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/xorg_fixup.log', 'VarLogDistupgradeXorgFixuplog') attach_file_if_exists(report, '/var/log/dist-upgrade/screenlog.0', 'VarLogDistupgradeScreenlog') attach_root_command_outputs( report, {'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'}) problem_type = report.get("ProblemType", None) if problem_type == 'Crash': tmpdir = re.compile('ubuntu-release-upgrader-\w+') tb = report.get("Traceback", None) if tb: dupe_sig = '' for line in tb.splitlines(): scrub_line = tmpdir.sub('ubuntu-release-upgrader-tmpdir', line) dupe_sig += scrub_line + '\n' report["DuplicateSignature"] = dupe_sig
def add_info(report, ui): try: attach_gsettings_package(report, 'ubuntu-release-upgrader') except: pass report['CrashDB'] = 'ubuntu' report.setdefault('Tags', 'dist-upgrade') report['Tags'] += ' dist-upgrade' clone_file = '/var/log/dist-upgrade/apt-clone_system_state.tar.gz' if os.path.exists(clone_file): report['VarLogDistupgradeAptclonesystemstate.tar.gz'] = \ root_command_output(["cat", clone_file], decode_utf8=False) attach_file_if_exists(report, '/var/log/dist-upgrade/apt.log', 'VarLogDistupgradeAptlog') attach_file_if_exists(report, '/var/log/dist-upgrade/apt-term.log', 'VarLogDistupgradeApttermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/history.log', 'VarLogDistupgradeAptHistorylog') attach_file_if_exists(report, '/var/log/dist-upgrade/lspci.txt', 'VarLogDistupgradeLspcitxt') attach_file_if_exists(report, '/var/log/dist-upgrade/main.log', 'VarLogDistupgradeMainlog') attach_file_if_exists(report, '/var/log/dist-upgrade/term.log', 'VarLogDistupgradeTermlog') attach_file_if_exists(report, '/var/log/dist-upgrade/screenlog.0', 'VarLogDistupgradeScreenlog') attach_root_command_outputs( report, {'CurrentDmesg.txt': 'dmesg | comm -13 --nocheck-order /var/log/dmesg -'}) problem_type = report.get("ProblemType", None) if problem_type == 'Crash': tmpdir = re.compile('ubuntu-release-upgrader-\w+') tb = report.get("Traceback", None) if tb: dupe_sig = '' for line in tb.splitlines(): scrub_line = tmpdir.sub('ubuntu-release-upgrader-tmpdir', line) dupe_sig += scrub_line + '\n' report["DuplicateSignature"] = dupe_sig