arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

Blame SOURCES/0238-vmcore-fix-finding-partitions-by-UUID-and-LABEL.patch

baab13
From 5cdaa8e6a276ad8cb79c3457badbb4f9dda5aa3e Mon Sep 17 00:00:00 2001
baab13
From: Jakub Filak <jfilak@redhat.com>
baab13
Date: Mon, 13 Jun 2016 09:43:21 +0200
baab13
Subject: [PATCH] vmcore: fix finding partitions by UUID and LABEL
baab13
baab13
In kdump.conf fs partition can be specified by UUID or LABEL but mtab
baab13
uses only file system node path. Hence, we need to translate the ID to
baab13
its node path.
baab13
baab13
Related: rhbz#1147053
baab13
baab13
Signed-off-by: Jakub Filak <jfilak@redhat.com>
baab13
---
baab13
 configure.ac                        |  2 ++
baab13
 src/hooks/Makefile.am               |  1 +
baab13
 src/hooks/abrt_harvest_vmcore.py.in | 27 +++++++++++++++++++++++++++
baab13
 3 files changed, 30 insertions(+)
baab13
baab13
diff --git a/configure.ac b/configure.ac
baab13
index 330dd9c..20a7f27 100644
baab13
--- a/configure.ac
baab13
+++ b/configure.ac
baab13
@@ -173,6 +173,8 @@ AC_ARG_ENABLE(doxygen-docs,
baab13
     [enable_doxygen_docs=no]
baab13
 )
baab13
 
baab13
+AC_PATH_PROG([BLKID], [BLKID], [/usr/sbin/blkid], [$PATH:/usr/sbin:/sbin])
baab13
+
baab13
 # Doxygen Documentation
baab13
 
baab13
 AC_PATH_PROG(DOXYGEN, doxygen, no)
baab13
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
baab13
index 9a527f4..216cfc1 100644
baab13
--- a/src/hooks/Makefile.am
baab13
+++ b/src/hooks/Makefile.am
baab13
@@ -92,6 +92,7 @@ abrt-install-ccpp-hook: abrt-install-ccpp-hook.in
baab13
 abrt-harvest-vmcore: abrt_harvest_vmcore.py.in
baab13
 	sed -e s,\@CONF_DIR\@,\$(CONF_DIR)\,g \
baab13
 	    -e s,\@DEFAULT_DUMP_LOCATION\@,$(DEFAULT_DUMP_LOCATION),g \
baab13
+	    -e s,\@BLKID\@,$(BLKID),g \
baab13
 		$< >$@
baab13
 
baab13
 abrt-harvest-pstoreoops: abrt-harvest-pstoreoops.in
baab13
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
baab13
index c6a7e6b..e71e5c9 100644
baab13
--- a/src/hooks/abrt_harvest_vmcore.py.in
baab13
+++ b/src/hooks/abrt_harvest_vmcore.py.in
baab13
@@ -13,6 +13,7 @@ import shutil
baab13
 import time
baab13
 import hashlib
baab13
 import augeas
baab13
+from subprocess import Popen, PIPE
baab13
 
baab13
 import problem
baab13
 
baab13
@@ -37,6 +38,32 @@ def get_mount_point(part_id):
baab13
     part_id - device node, label or uuid
baab13
     """
baab13
 
baab13
+    idtypes = {"UUID=":"-U", "PARTUUID=":"-U", "LABEL=":"-L", "PARTLABEL=":"-L"}
baab13
+
baab13
+    for typ, switch in idtypes.items():
baab13
+        if not part_id.startswith(typ):
baab13
+            continue
baab13
+
baab13
+        idf = part_id[len(typ):]
baab13
+        try:
baab13
+            proc = Popen(["@BLKID@", switch, idf], stdout=PIPE, stderr=PIPE)
baab13
+            out, err = proc.communicate()
baab13
+            if err:
baab13
+                sys.stderr.write("Failed 'blkid {0} {1}': {2}\n"
baab13
+                                 .format(switch, idf, err))
baab13
+                sys.exit(1)
baab13
+            if not out:
baab13
+                sys.stderr.write("No results from 'blkid {0} {1}'\n"
baab13
+                                 .format(switch, idf))
baab13
+                sys.exit(1)
baab13
+
baab13
+            part_id = out.strip()
baab13
+            break
baab13
+        except OSError as ex:
baab13
+            sys.stderr.write("Cannot run 'blkid {0} {1}': {2}\n"
baab13
+                              .format(switch, idf, str(ex)))
baab13
+            sys.exit(1)
baab13
+
baab13
     # look up the identifier in /etc/mtab
baab13
     result = get_augeas("Fstab", "/etc/mtab").get("/files/etc/mtab/*"
baab13
                                  "[spec=\"" + part_id + "\"]/file")
baab13
-- 
baab13
1.8.3.1
baab13