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

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