File: source_mariadb.py

package info (click to toggle)
mariadb 1%3A11.8.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 774,668 kB
  • sloc: ansic: 2,415,394; cpp: 1,796,628; asm: 381,336; perl: 62,933; sh: 50,568; pascal: 40,908; java: 39,363; python: 25,814; yacc: 20,444; sql: 17,907; xml: 12,354; ruby: 8,544; cs: 6,542; makefile: 6,143; ada: 1,879; lex: 1,194; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (54 lines) | stat: -rw-r--r-- 2,025 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''apport package hook for mariadb

(c) 2009 Canonical Ltd.
Author: Mathias Gug <mathias.gug@canonical.com>
'''

from __future__ import print_function, unicode_literals
import os, os.path

from apport.hookutils import path_to_key, read_file, attach_conffiles, attach_mac_events, attach_file

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):
    attach_conffiles(report, 'mariadb-server', conffiles=None)
    key = 'Logs' + path_to_key('/var/log/daemon.log')
    report[key] = ""
    for line in read_file('/var/log/daemon.log').split('\n'):
        try:
            if 'mariadbd' in line.split()[4]:
                report[key] += line + '\n'
        except IndexError:
            continue
    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'
    attach_mac_events(report, '/usr/sbin/mariadbd')
    attach_file(report,'/etc/apparmor.d/usr.sbin.mariadbd')
    _add_my_conf_files(report, '/etc/mysql/mariadb.cnf')
    for f in os.listdir('/etc/mysql/conf.d'):
        _add_my_conf_files(report, os.path.join('/etc/mysql/conf.d', f))
    for f in os.listdir('/etc/mysql/mariadb.conf.d'):
        _add_my_conf_files(report, os.path.join('/etc/mysql/mariadb.conf.d', f))
    try:
        report['MySQLVarLibDirListing'] = str(os.listdir('/var/lib/mysql'))
    except OSError:
        report['MySQLVarLibDirListing'] = str(False)

if __name__ == '__main__':
    report = {}
    add_info(report)
    for key in report:
        print('%s: %s' % (key, report[key].split('\n', 1)[0]))