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

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