Blame SOURCES/0323-plugins-Catch-unhandled-exception-in-a-a-g-machine-i.patch

a60cd7
From 323931ae023c46370e200483a7c37959309cd9a4 Mon Sep 17 00:00:00 2001
a60cd7
From: Martin Kutlak <mkutlak@redhat.com>
a60cd7
Date: Tue, 21 May 2019 14:55:43 +0000
a60cd7
Subject: [PATCH] plugins: Catch unhandled exception in a-a-g-machine-id
a60cd7
a60cd7
dmidecode can fail due to permission denies or any different reasons that
a60cd7
causes dmidecode to return non-zero return code.
a60cd7
a60cd7
Related: rhbz#1688368
a60cd7
a60cd7
cherry picked from commit 53100055cd504fa0d5d56eb9312ece66ba8de49e
a60cd7
a60cd7
Signed-off-by: Martin Kutlak <mkutlak@redhat.com>
a60cd7
---
a60cd7
 src/plugins/abrt-action-generate-machine-id | 7 +++++--
a60cd7
 1 file changed, 5 insertions(+), 2 deletions(-)
a60cd7
a60cd7
diff --git a/src/plugins/abrt-action-generate-machine-id b/src/plugins/abrt-action-generate-machine-id
a60cd7
index f843d773..fc79b192 100644
a60cd7
--- a/src/plugins/abrt-action-generate-machine-id
a60cd7
+++ b/src/plugins/abrt-action-generate-machine-id
a60cd7
@@ -23,7 +23,7 @@
a60cd7
 import os
a60cd7
 import sys
a60cd7
 from argparse import ArgumentParser
a60cd7
-from subprocess import check_output
a60cd7
+from subprocess import check_output, CalledProcessError
a60cd7
 import logging
a60cd7
 
a60cd7
 import hashlib
a60cd7
@@ -52,7 +52,10 @@ def generate_machine_id_dmidecode():
a60cd7
 
a60cd7
     # Run dmidecode command
a60cd7
     for k in keys:
a60cd7
-        data = check_output(["dmidecode", "-s", k]).strip()
a60cd7
+        try:
a60cd7
+            data = check_output(["dmidecode", "-s", k]).strip()
a60cd7
+        except (OSError, CalledProcessError) as ex:
a60cd7
+            raise RuntimeError("Execution of dmidecode failed: {0}".format(str(ex)))
a60cd7
 
a60cd7
         # Update the hash as we find the fields we are looking for
a60cd7
         machine_id.update(data)
a60cd7
-- 
a60cd7
2.21.0
a60cd7