From 9eb1b906eb978a46826a5eaeacb0fd29a81250ca Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 2 Sep 2013 19:19:26 +0100
Subject: [PATCH] daemon: augeas: Enhance error reporting for aug_init
failures.
Thanks: Dominic Cleal.
(cherry picked from commit 3d132f29204e8c5c77f08841b5288dfe3013f4f0)
---
daemon/augeas.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/daemon/augeas.c b/daemon/augeas.c
index 83e2739..9d6a553 100644
--- a/daemon/augeas.c
+++ b/daemon/augeas.c
@@ -98,12 +98,26 @@ do_aug_init (const char *root, int flags)
return -1;
}
+#ifdef AUG_NO_ERR_CLOSE
+ /* Pass AUG_NO_ERR_CLOSE so we can display detailed errors. */
+ aug = aug_init (buf, NULL, flags | AUG_NO_ERR_CLOSE);
+#else
aug = aug_init (buf, NULL, flags);
+#endif
if (!aug) {
- reply_with_error ("Augeas initialization failed");
+ reply_with_error ("augeas initialization failed");
+ return -1;
+ }
+
+#ifdef AUG_NO_ERR_CLOSE
+ if (aug_error (aug) != AUG_NOERROR) {
+ AUGEAS_ERROR ("aug_init: %s (flags %d)", root, flags);
+ aug_close (aug);
+ aug = NULL;
return -1;
}
+#endif
return 0;
}
--
1.8.3.1