doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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