3
# postfix apport package hook
5
# Copyright (C) 2011 Canonical Ltd. All Rights Reserved.
6
# Author: Clint Byrum <clint.byrum@canonical.com>
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
27
gettext.install('postfix-apport-hook')
29
msg = _('In order for the developers to determine the cause of this, some'
30
' potentially sensitive information from your system configuration may'
31
' be helpful. Specifically, your hostname and DNS configuration. Please'
32
' note that this will be included in a *PUBLIC* bug report.' )
34
msg2 = _('Do you want to add this extra information to the bug report?')
36
host_re = re.compile('^[a-zA-Z0-9][a-zA-Z0-9\-\.]*$')
38
def add_info(report, ui):
41
if os.path.exists('/etc/mailname'):
42
extra_info['EtcMailname'] = open('/etc/mailname').read().strip()
44
extra_info['EtcMailname'] = _('*** /etc/mailname does not exist ***')
45
extra_info['Hostname'] = apport.hookutils.command_output(['hostname','--fqdn'])
46
extra_info['PostconfMyhostname'] = apport.hookutils.command_output(['/usr/sbin/postconf','-h','myhostname'])
47
extra_info['PostconfMydomain'] = apport.hookutils.command_output(['/usr/sbin/postconf','-h','mydomain'])
49
""" Note that even if the user opts not to send the info, we get this key """
50
for k,v in extra_info.iteritems():
51
if not host_re.match(v):
52
report['DuplicateSignature'] = 'InvalidHostOrDomain'
55
# Do not include this in the dupes since it is usually "/etc/mailname"
56
extra_info['PostconfMyorigin'] = apport.hookutils.command_output(['/usr/sbin/postconf','-h','myorigin'])
58
if os.path.exists('/etc/resolv.conf'):
59
extra_info['ResolvConf'] = open('/etc/resolv.conf').read()
61
extra_info['ResolvConf'] = _('*** /etc/resolv.conf does not exist ***')
63
eeinfo = [("%s: %s" % (k,v)) for k,v in extra_info.iteritems()]
64
answer = ui.yesno("%s\n\n%s\n\n%s" % (msg, msg2 ,"\n".join(eeinfo)))
66
report.update(extra_info)