doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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