Blob Blame History Raw
From 5cdaa8e6a276ad8cb79c3457badbb4f9dda5aa3e Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Mon, 13 Jun 2016 09:43:21 +0200
Subject: [PATCH] vmcore: fix finding partitions by UUID and LABEL

In kdump.conf fs partition can be specified by UUID or LABEL but mtab
uses only file system node path. Hence, we need to translate the ID to
its node path.

Related: rhbz#1147053

Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
 configure.ac                        |  2 ++
 src/hooks/Makefile.am               |  1 +
 src/hooks/abrt_harvest_vmcore.py.in | 27 +++++++++++++++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/configure.ac b/configure.ac
index 330dd9c..20a7f27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,8 @@ AC_ARG_ENABLE(doxygen-docs,
     [enable_doxygen_docs=no]
 )
 
+AC_PATH_PROG([BLKID], [BLKID], [/usr/sbin/blkid], [$PATH:/usr/sbin:/sbin])
+
 # Doxygen Documentation
 
 AC_PATH_PROG(DOXYGEN, doxygen, no)
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
index 9a527f4..216cfc1 100644
--- a/src/hooks/Makefile.am
+++ b/src/hooks/Makefile.am
@@ -92,6 +92,7 @@ abrt-install-ccpp-hook: abrt-install-ccpp-hook.in
 abrt-harvest-vmcore: abrt_harvest_vmcore.py.in
 	sed -e s,\@CONF_DIR\@,\$(CONF_DIR)\,g \
 	    -e s,\@DEFAULT_DUMP_LOCATION\@,$(DEFAULT_DUMP_LOCATION),g \
+	    -e s,\@BLKID\@,$(BLKID),g \
 		$< >$@
 
 abrt-harvest-pstoreoops: abrt-harvest-pstoreoops.in
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
index c6a7e6b..e71e5c9 100644
--- a/src/hooks/abrt_harvest_vmcore.py.in
+++ b/src/hooks/abrt_harvest_vmcore.py.in
@@ -13,6 +13,7 @@ import shutil
 import time
 import hashlib
 import augeas
+from subprocess import Popen, PIPE
 
 import problem
 
@@ -37,6 +38,32 @@ def get_mount_point(part_id):
     part_id - device node, label or uuid
     """
 
+    idtypes = {"UUID=":"-U", "PARTUUID=":"-U", "LABEL=":"-L", "PARTLABEL=":"-L"}
+
+    for typ, switch in idtypes.items():
+        if not part_id.startswith(typ):
+            continue
+
+        idf = part_id[len(typ):]
+        try:
+            proc = Popen(["@BLKID@", switch, idf], stdout=PIPE, stderr=PIPE)
+            out, err = proc.communicate()
+            if err:
+                sys.stderr.write("Failed 'blkid {0} {1}': {2}\n"
+                                 .format(switch, idf, err))
+                sys.exit(1)
+            if not out:
+                sys.stderr.write("No results from 'blkid {0} {1}'\n"
+                                 .format(switch, idf))
+                sys.exit(1)
+
+            part_id = out.strip()
+            break
+        except OSError as ex:
+            sys.stderr.write("Cannot run 'blkid {0} {1}': {2}\n"
+                              .format(switch, idf, str(ex)))
+            sys.exit(1)
+
     # look up the identifier in /etc/mtab
     result = get_augeas("Fstab", "/etc/mtab").get("/files/etc/mtab/*"
                                  "[spec=\"" + part_id + "\"]/file")
-- 
1.8.3.1