Blob Blame History Raw
From 57c975dfda165098502cdb9e2525bc7877301a12 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 98e2564..8e13524 100644
--- a/configure.ac
+++ b/configure.ac
@@ -263,6 +263,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 bf68994..c0255d9 100644
--- a/src/hooks/Makefile.am
+++ b/src/hooks/Makefile.am
@@ -119,6 +119,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 61a6e57..ab976dc 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
 import report
@@ -38,6 +39,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.decode().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")
-- 
2.7.4