This is actually done already in apport for all apport-package bug
reports:
def attach_conffiles(report, package, conffiles=None):
'''Attach information about any modified or deleted conffiles'''
try:
dpkg = subprocess.Popen(['dpkg-query','-W','--showformat=${Conffiles}',
package], stdout=subprocess.PIPE, close_fds=True)
except OSError, e:
return 'Error: ' + str(e)
out = dpkg.communicate()[0]
if dpkg.returncode != 0:
return
for line in out.splitlines():
if not line:
continue
# just take the first two fields, to not stumble over obsolete
# conffiles
path, default_md5sum = line.strip().split()[:2]
if conffiles and path not in conffiles: continue
key = 'modified.conffile.' + path_to_key(path)
if os.path.exists(path):
contents = open(path).read()
m = hashlib.md5()
m.update(contents)
calculated_md5sum = m.hexdigest()
if calculated_md5sum != default_md5sum:
report[key] = contents
statinfo = os.stat(path)
mtime = datetime.datetime.fromtimestamp(statinfo.st_mtime)
mtime_key = 'mtime.conffile.' + path_to_key(path)
report[mtime_key] = mtime.isoformat()
else:
report[key] = '[deleted]'
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/803963
Title:
apport should always check if a package's conffiles are modified
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/803963/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs