diff --git a/rel-eng/packages/subscription-manager b/rel-eng/packages/subscription-manager
index e70e94b..fd8bffa 100644
--- a/rel-eng/packages/subscription-manager
+++ b/rel-eng/packages/subscription-manager
@@ -1 +1 @@
-1.10.14-11 ./
+1.10.14-12 ./
diff --git a/src/daemons/rhsm_d.py b/src/daemons/rhsm_d.py
index de8541e..7db3251 100755
--- a/src/daemons/rhsm_d.py
+++ b/src/daemons/rhsm_d.py
@@ -15,6 +15,24 @@
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
+import sys
+
+enable_debug = False
+
+
+def excepthook_base(exc_type, exc_value, exc_traceback):
+ # something failed before we even got logging setup
+ if issubclass(exc_type, KeyboardInterrupt):
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
+ return
+
+ if enable_debug:
+ sys.__excepthook__(exc_type, exc_value, exc_traceback)
+
+ # something fundamental failed... how quiet should we be?
+ sys.exit(0)
+
+sys.excepthook = excepthook_base
import syslog
import gobject
@@ -22,8 +40,9 @@ import dbus
import dbus.service
import dbus.glib
import logging
+import gettext
+import traceback
-import sys
sys.path.append("/usr/share/rhsm")
log = logging.getLogger("rhsm-app.rhsmd")
@@ -31,6 +50,19 @@ log = logging.getLogger("rhsm-app.rhsmd")
from subscription_manager import logutil
logutil.init_logger()
+
+# If we get here, we should be okay to use define excepthook that
+# uses our logging. Set this up before we do injection init, since
+# that has a lot of potential failures.
+def excepthook_logging(exc_type, exc_value, exc_traceback):
+ framelist = traceback.format_exception(exc_type, exc_value, exc_traceback)
+ log.error("Unhandled rhsmd exception caught by the logging excepthook: %s",
+ "".join(framelist))
+
+ return excepthook_base(exc_type, exc_value, exc_traceback)
+
+sys.excepthook = excepthook_logging
+
from subscription_manager.injectioninit import init_dep_injection
init_dep_injection()
@@ -47,7 +79,7 @@ from subscription_manager.cert_sorter import RHSM_VALID, \
import rhsm.config
CFG = rhsm.config.initConfig()
-enable_debug = False
+_ = gettext.gettext
def debug(msg):
@@ -250,6 +282,12 @@ def main():
# good, so it gets an exit status of 0.
return status
+ # we are not running from cron here, so unset the excepthook
+ # though, we may be running from cli, or as a dbus activation. For
+ # cli, we should traceback. For dbus, we should try to log it and
+ # raise dbus exception?
+ sys.excepthook = sys.__excepthook__
+
system_bus = dbus.SystemBus()
loop = gobject.MainLoop()
checker = StatusChecker(system_bus, options.keep_alive, force_signal, loop)
diff --git a/subscription-manager.spec b/subscription-manager.spec
index 6a3cad1..8c98379 100644
--- a/subscription-manager.spec
+++ b/subscription-manager.spec
@@ -14,7 +14,7 @@
Name: subscription-manager
Version: 1.10.14
-Release: 11%{?dist}
+Release: 12%{?dist}
Summary: Tools and libraries for subscription and repository management
Group: System Environment/Base
License: GPLv2
@@ -419,6 +419,9 @@ fi
%endif
%changelog
+* Fri Dec 05 2014 Adrian Likins <alikins@redhat.com> 1.10.14-12
+- 1167463: Add a catchall excepthook for rhsmd (alikins@redhat.com)
+
* Mon Nov 24 2014 Devan Goodwin <dgoodwin@rm-rf.ca> 1.10.14-11
- 1113741: Fix rhsmd traceback on 502 errors. (alikins@redhat.com)