doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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