/usr/share/apport/package-hooks/chromium-browser.py is in chromium-browser 18.0.1025.151~r130497-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | '''chromium apport hook
/usr/share/apport/package-hooks/chromium-browser.py
Copyright (c) 2010, Fabien Tassin <fta@sofaraway.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version. See http://www.gnu.org/copyleft/gpl.html for
the full text of the license.
'''
import os, sys, getopt, codecs
import time
from stat import *
import re
import apport.hookutils
import subprocess
has_json = 1
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
has_json = 0
HOME = os.getenv("HOME")
PACKAGE = 'chromium-browser'
RELATED_PACKAGES = [
PACKAGE,
'chromium-browser-l10n',
'chromium-browser-inspector',
'chromium-browser-dbg',
'chromium-codecs-ffmpeg',
'chromium-codecs-ffmpeg-extra',
'libvpx0',
'libgtk2.0-0',
'nspluginwrapper',
# various plugins
'flashplugin-installer',
'rhythmbox-plugins',
'totem-mozilla',
'icedtea6-plugin',
'moonlight-plugin-chromium',
'sun-java6-bin',
'acroread',
'google-talkplugin',
# chrome
'google-chrome-unstable',
'google-chrome-beta',
'google-chrome-stable',
]
def installed_version(report, pkgs):
report['RelatedPackagesPolicy'] = ''
for pkg in pkgs:
script = subprocess.Popen(['apt-cache', 'policy', pkg], stdout=subprocess.PIPE)
report['RelatedPackagesPolicy'] += script.communicate()[0] + "\n"
def gconf_values(report, keys):
report['gconf-keys'] = ''
for key in keys:
try:
script = subprocess.Popen(['gconftool-2', '--get', key], stdout=subprocess.PIPE)
except OSError:
report['gconf-keys'] = "gconftool-2 not found"
return
out = script.communicate()[0]
if out == "":
out = "**unset**\n"
report['gconf-keys'] += key + " = " + out
def get_user_profile_dir(report):
dir = HOME + "/.config/chromium/Default"
# see if report['ProcCmdline'] contains a --user-data-dir=xxx and use it if it still exists
return dir
def user_prefs(report, file):
if has_json == 0:
report['ChromiumPrefs'] = "no json module found. Skipped"
return
try:
with open(file, 'r') as f:
entry = json.load(f)
except IOError:
report['ChromiumPrefs'] = "can't open profile " + file
return
report['ChromiumPrefs'] = '';
if 'browser' in entry and 'check_default_browser' in entry['browser']:
report['ChromiumPrefs'] += "browser/check_default_browser = " + \
str(entry['browser']['check_default_browser']) + "\n"
else:
report['ChromiumPrefs'] += "browser/check_default_browser = **unset** (no such key yet)\n"
if 'theme' in entry['extensions']:
if 'use_system' in entry['extensions']['theme']:
report['ChromiumPrefs'] += "extensions/theme/use_system = " + \
str(entry['extensions']['theme']['use_system']) + "\n"
else:
report['ChromiumPrefs'] += "extensions/theme/use_system = **unset** (no such key)\n"
# list entensions+versions
report['ChromiumPrefs'] += "extensions/settings =\n"
if 'settings' in entry['extensions']:
for ext in entry['extensions']['settings'].keys():
report['ChromiumPrefs'] += " - '" + ext + "'\n"
if 'manifest' in entry['extensions']['settings'][ext]:
for k in [ 'name', 'description', 'version', 'update_url' ]:
report['ChromiumPrefs'] += " manifest/%s = %s\n" % \
(k, "'" + entry['extensions']['settings'][ext]['manifest'][k] + "'" \
if k in entry['extensions']['settings'][ext]['manifest'] else "*undef*")
else:
report['ChromiumPrefs'] += " manifest/* = *undef*\n"
for k in [ 'blacklist', 'state' ]:
if k in entry['extensions']['settings'][ext]:
report['ChromiumPrefs'] += " %s = %s\n" % \
(k, repr(entry['extensions']['settings'][ext][k]))
else:
report['ChromiumPrefs'] += " (no entry found in the Preferences file)"
# list plugins
# (for some reason, this key is not populated until something is (manually?)
# changed in about:plugins)
report['DetectedPlugins'] = ""
if 'plugins' in entry and 'plugins_list' in entry['plugins']:
for plugin in entry['plugins']['plugins_list']:
report['DetectedPlugins'] += "=> " + plugin['name'] + "\n" + \
" - enabled = " + str(plugin['enabled']) + "\n"
if 'path' in plugin:
report['DetectedPlugins'] += " - path = " + plugin['path'] + "\n"
else:
report['DetectedPlugins'] += "(no entry found in the Preferences file)"
def list_installed_plugins(report):
# $SRC/webkit/glue/plugins/plugin_list_posix.cc
# 1/ MOZ_PLUGIN_PATH env variable
# 2/ ~/.mozilla/plugins
# 3/ /usr/lib/browser-plugins /usr/lib/mozilla/plugins /usr/lib/firefox/plugins
# /usr/lib/xulrunner-addons/plugins
# and on x64 systems (unless /usr/lib64 is a symlink to /usr/lib):
# /usr/lib64/browser-plugins /usr/lib64/mozilla/plugins /usr/lib64/firefox/plugins
# /usr/lib64/xulrunner-addons/plugins
# It's not clear if $SRC/third_party/WebKit/WebCore/plugins/PluginDatabase.cpp
# is also used (if it is, we need the zillions dirs from PluginDatabase::defaultPluginDirectories()
report['InstalledPlugins'] = ''
dirs = {}
def dcallback(arg, directory, files):
r = []
for file in files:
r.append(os.path.join(directory, file))
return r
for dir in ( HOME + "/.mozilla/plugins",
"/usr/lib/browser-plugins",
"/usr/lib/mozilla/plugins",
"/usr/lib/firefox/plugins",
"/usr/lib/xulrunner-addons/plugins",
"/usr/lib64/browser-plugins",
"/usr/lib64/mozilla/plugins",
"/usr/lib64/firefox/plugins",
"/usr/lib64/xulrunner-addons/plugins" ):
if os.path.exists(dir):
d = os.path.realpath(dir)
if d not in dirs:
dirs[d] = True
report['InstalledPlugins'] += dir + ":\n"
for ent in os.listdir(d):
filename = os.path.join(d, ent)
report['InstalledPlugins'] += " => " + ent + "\n"
while os.path.islink(filename):
filename2 = os.readlink(filename)
if filename2 == filename:
report['InstalledPlugins'] += " - (symlink loop, abort)\n"
break
if not os.path.exists(filename):
report['InstalledPlugins'] += " - broken symlink to " + filename2 + "\n"
break
filename = os.path.normpath(os.path.join(os.path.dirname(filename), filename2))
report['InstalledPlugins'] += " - symlink to " + filename + "\n"
if os.path.exists(filename):
st = os.stat(filename)
report['InstalledPlugins'] += " (size: " + \
str(st.st_size) + " bytes, mtime: " + time.ctime(st.st_mtime) + ")\n"
report['InstalledPlugins'] += "\n"
def get_envs(envs):
s = ""
for env in envs:
s += env + " = " + str(os.getenv(env)) + "\n"
return s
def add_info(report, ui = None, userdir = None):
apport.hookutils.attach_related_packages(report, RELATED_PACKAGES)
installed_version(report, RELATED_PACKAGES)
# Allow reports from PPAs
if not apport.packaging.is_distro_package(PACKAGE):
report['ThirdParty'] = 'True'
report['CrashDB'] = 'ubuntu'
try:
fd = open('/etc/chromium-browser/default')
report['chromium-default'] = ""
for l in fd.readlines():
if re.match('^(#|$)', l):
continue
report['chromium-default'] += l
fd.close()
except IOError:
pass
try:
report['user-desktop-file'] = \
open(HOME + '/.local/share/applications/' + PACKAGE + '.desktop').read()
except IOError:
pass
gconf_values(report, [
'/desktop/gnome/applications/browser/exec',
'/desktop/gnome/url-handlers/https/command',
'/desktop/gnome/url-handlers/https/enabled',
'/desktop/gnome/url-handlers/http/command',
'/desktop/gnome/url-handlers/http/enabled',
'/desktop/gnome/session/required_components/windowmanager',
'/apps/metacity/general/compositing_manager',
'/desktop/gnome/interface/icon_theme',
'/desktop/gnome/interface/gtk_theme',
])
user_dir = userdir if userdir is not None else get_user_profile_dir(report)
user_prefs(report, user_dir + "/Preferences")
list_installed_plugins(report)
# DE
report['Desktop-Session'] = get_envs([ 'DESKTOP_SESSION', 'XDG_CONFIG_DIRS', 'XDG_DATA_DIRS' ])
# Env
report['Env'] = get_envs([ 'MOZ_PLUGIN_PATH', 'LD_LIBRARY_PATH' ])
# Disk usage
script = subprocess.Popen([ 'df', '-Th' ], stdout=subprocess.PIPE)
report['DiskUsage'] = script.communicate()[0] + "\n\nInodes:\n"
script = subprocess.Popen([ 'df', '-ih' ], stdout=subprocess.PIPE)
report['DiskUsage'] += script.communicate()[0]
## DEBUGING ##
if __name__ == '__main__':
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
try:
opts, args = getopt.getopt(sys.argv[1:], "-u:", [ 'user-dir=' ])
except getopt.GetoptError, err:
print str(err)
sys.exit(2)
userdir = None
for o, a in opts:
if o in ("-u", "--user-dir"):
userdir = a
else:
assert False, "unhandled option"
report = {}
add_info(report, userdir = userdir)
for key in report:
print '[%s]\n%s\n' % (key, report[key])
|