Blame SOURCES/0010-vmcore-properly-configure-Augeas.patch

baab13
From 4c754657a3581b996ae540fbcbc261efd1f65ca2 Mon Sep 17 00:00:00 2001
baab13
From: Jakub Filak <jfilak@redhat.com>
baab13
Date: Thu, 16 Jan 2014 12:20:40 +0100
baab13
Subject: [ABRT PATCH 10/12] vmcore: properly configure Augeas
baab13
baab13
Configure Augeas to parse only required configuration files:
baab13
- /etc/mtab
baab13
- /ect/kdump.conf
baab13
baab13
Related to rhbz#1054158
baab13
baab13
Signed-off-by: Jakub Filak <jfilak@redhat.com>
baab13
---
baab13
 src/hooks/abrt_harvest_vmcore.py.in | 16 ++++++++++++++--
baab13
 1 file changed, 14 insertions(+), 2 deletions(-)
baab13
baab13
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
baab13
index 64d6777..ecfb32d 100644
baab13
--- a/src/hooks/abrt_harvest_vmcore.py.in
baab13
+++ b/src/hooks/abrt_harvest_vmcore.py.in
baab13
@@ -17,6 +17,18 @@ import augeas
baab13
 import problem
baab13
 
baab13
 
baab13
+def get_augeas(module, file_path):
baab13
+    """
baab13
+    A function for efficient configuration of Augeas.
baab13
+    Augeas modules are placed in /usr/share/augeas/lenses/dist
baab13
+    """
baab13
+
baab13
+    aug_obj = augeas.Augeas(flags=augeas.Augeas.NO_MODL_AUTOLOAD)
baab13
+    aug_obj.set("/augeas/load/{0}/lens".format(module), "{0}.lns".format(module))
baab13
+    aug_obj.set("/augeas/load/{0}/incl".format(module), file_path)
baab13
+    aug_obj.load()
baab13
+    return aug_obj
baab13
+
baab13
 def get_mount_point(part_id):
baab13
     """
baab13
     A function used to look up a mount point in mtab using
baab13
@@ -26,7 +38,7 @@ def get_mount_point(part_id):
baab13
     """
baab13
 
baab13
     # look up the identifier in /etc/mtab
baab13
-    result = augeas.Augeas().get("/files/etc/mtab/*"
baab13
+    result = get_augeas("Fstab", "/etc/mtab").get("/files/etc/mtab/*"
baab13
                                  "[spec=\"" + part_id + "\"]/file")
baab13
     if result:
baab13
         return result
baab13
@@ -53,7 +65,7 @@ def parse_kdump():
baab13
                          "default path '%s'\n" % dump_path)
baab13
         return dump_path
baab13
 
baab13
-    aug_obj = augeas.Augeas()
baab13
+    aug_obj = get_augeas("Kdump", "/etc/kdump.conf")
baab13
     # check for path variable in kdump.conf
baab13
     kdump_path = aug_obj.get("/files/etc/kdump.conf/path")
baab13
     if kdump_path:
baab13
-- 
baab13
1.8.3.1
baab13