Both run_uri and run_string commands should return string in this format:
OK\n<data>
or
FAILED\n<code>\n<data>
Where <data> is arbitrary optional data per backend and <code> is
error code from the backend.
---
src/lib/sysconfig_linux.c | 20 +++++++++++---------
src/sysconfig/schema.xml | 2 +-
2 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/lib/sysconfig_linux.c b/src/lib/sysconfig_linux.c
index 9a9ab0e..9f80c4f 100644
--- a/src/lib/sysconfig_linux.c
+++ b/src/lib/sysconfig_linux.c
@@ -304,7 +304,7 @@ run_augeas(const char *uri, const char *data, const char *key,
GError *err = NULL;
augeas *aug;
int result;
- char *value = NULL;
+ char *value = NULL, *result_str;
enum mh_result res = MH_RES_SUCCESS;
if (uri) {
@@ -382,21 +382,23 @@ run_augeas(const char *uri, const char *data, const char *key,
g_free(text);
fclose(fp);
- if (result < 0) {
- unlink(filename);
- mh_err("Augeas command failed");
- return MH_RES_BACKEND_ERROR;
- }
-
if (!g_file_get_contents(filename, &value, NULL, &err)) {
mh_err("Unable to read augeas results: %s", err->message);
unlink(filename);
return MH_RES_BACKEND_ERROR;
}
- mh_sysconfig_set_configured(key, value);
- result_cb(cb_data, result);
+ if (result < 0) {
+ asprintf(&result_str, "FAILED\n%d\n%s", result, value);
+ mh_sysconfig_set_configured(key, result_str);
+ result_cb(cb_data, MH_RES_SUCCESS);
+ } else {
+ asprintf(&result_str, "OK\n%s", value);
+ mh_sysconfig_set_configured(key, result_str);
+ result_cb(cb_data, MH_RES_SUCCESS);
+ }
+ free(result_str);
unlink(filename);
return 0;
diff --git a/src/sysconfig/schema.xml b/src/sysconfig/schema.xml
index 0635a09..c4b67a4 100644
--- a/src/sysconfig/schema.xml
+++ b/src/sysconfig/schema.xml
@@ -36,7 +36,7 @@
</itemizedlist>" />
<arg name="scheme" dir="I"
type="sstr" desc="File format of configuration file. Currently supported
are <literal>puppet</literal> and
<literal>augeas</literal>." />
<arg name="key" dir="I"
type="sstr" desc="Key will be associated with the result of the command.
The key can be used in <xref linkend='Sysconfig_is_configured'
/>." />
- <arg name="status" dir="O"
type="sstr" desc="Result of the command." />
+ <arg name="status" dir="O"
type="sstr" desc="Status of the call contains newline separated records.
First line is 'OK' or 'FAILED'. 'FAILED' status has return code on
second line. The rest of the status message is optional data that differs per
scheme." />
</method>
<method name="run_string" desc="Configure system using
given configuration text. Most arguments are the same as <xref
linkend='Sysconfig_run_uri' />">
--
1.7.7