2022-04-11 10:32:26 +02:00
|
|
|
'''apport package hook for mariadb
|
2012-01-23 12:20:16 +01:00
|
|
|
|
|
|
|
(c) 2009 Canonical Ltd.
|
|
|
|
Author: Mathias Gug <mathias.gug@canonical.com>
|
|
|
|
'''
|
|
|
|
|
2020-04-05 12:05:56 +02:00
|
|
|
from __future__ import print_function, unicode_literals
|
2012-01-23 12:20:16 +01:00
|
|
|
import os, os.path
|
|
|
|
|
|
|
|
from apport.hookutils import *
|
|
|
|
|
|
|
|
def _add_my_conf_files(report, filename):
|
|
|
|
key = 'MySQLConf' + path_to_key(filename)
|
|
|
|
report[key] = ""
|
|
|
|
for line in read_file(filename).split('\n'):
|
|
|
|
try:
|
|
|
|
if 'password' in line.split('=')[0]:
|
|
|
|
line = "%s = @@APPORTREPLACED@@" % (line.split('=')[0])
|
|
|
|
report[key] += line + '\n'
|
|
|
|
except IndexError:
|
|
|
|
continue
|
|
|
|
|
|
|
|
def add_info(report):
|
2022-04-11 10:32:26 +02:00
|
|
|
attach_conffiles(report, 'mariadb-server', conffiles=None)
|
2012-01-23 12:20:16 +01:00
|
|
|
key = 'Logs' + path_to_key('/var/log/daemon.log')
|
|
|
|
report[key] = ""
|
|
|
|
for line in read_file('/var/log/daemon.log').split('\n'):
|
|
|
|
try:
|
2020-06-11 00:39:11 +02:00
|
|
|
if 'mariadbd' in line.split()[4]:
|
2012-01-23 12:20:16 +01:00
|
|
|
report[key] += line + '\n'
|
|
|
|
except IndexError:
|
|
|
|
continue
|
2020-04-05 12:05:56 +02:00
|
|
|
if os.path.exists('/var/log/mysql/error.log'):
|
|
|
|
key = 'Logs' + path_to_key('/var/log/mysql/error.log')
|
|
|
|
report[key] = ""
|
|
|
|
for line in read_file('/var/log/mysql/error.log').split('\n'):
|
|
|
|
report[key] += line + '\n'
|
2020-06-11 00:39:11 +02:00
|
|
|
attach_mac_events(report, '/usr/sbin/mariadbd')
|
|
|
|
attach_file(report,'/etc/apparmor.d/usr.sbin.mariadbd')
|
2020-04-05 12:05:56 +02:00
|
|
|
_add_my_conf_files(report, '/etc/mysql/mariadb.cnf')
|
2012-01-23 12:20:16 +01:00
|
|
|
for f in os.listdir('/etc/mysql/conf.d'):
|
|
|
|
_add_my_conf_files(report, os.path.join('/etc/mysql/conf.d', f))
|
2020-04-05 12:05:56 +02:00
|
|
|
for f in os.listdir('/etc/mysql/mariadb.conf.d'):
|
|
|
|
_add_my_conf_files(report, os.path.join('/etc/mysql/mariadb.conf.d', f))
|
2012-01-23 12:20:16 +01:00
|
|
|
try:
|
2020-04-05 12:05:56 +02:00
|
|
|
report['MySQLVarLibDirListing'] = str(os.listdir('/var/lib/mysql'))
|
2012-01-23 12:20:16 +01:00
|
|
|
except OSError:
|
2020-04-05 12:05:56 +02:00
|
|
|
report['MySQLVarLibDirListing'] = str(False)
|
2012-01-23 12:20:16 +01:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
report = {}
|
|
|
|
add_info(report)
|
|
|
|
for key in report:
|
2020-04-05 12:05:56 +02:00
|
|
|
print('%s: %s' % (key, report[key].split('\n', 1)[0]))
|