Blame SOURCES/subscription-manager-1.10.14-11-to-subscription-manager-1.10.14-12.patch

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