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

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