diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-10 13:55:24 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-10 13:55:24 +0100 |
commit | b07c8d78cbad077ea0596b90b370e2db0fe8b577 (patch) | |
tree | 4835acd8741a392833fc2969ec512b21c3f39584 /src/CLI | |
parent | fc2c5e2f02e6da00e27d68a83277a61efdcc9f83 (diff) | |
download | abrt-b07c8d78cbad077ea0596b90b370e2db0fe8b577.tar.gz abrt-b07c8d78cbad077ea0596b90b370e2db0fe8b577.tar.xz abrt-b07c8d78cbad077ea0596b90b370e2db0fe8b577.zip |
make "abrt-cli --delete randomuuid" report that deletion failed. closes bug 59
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/CLI')
-rw-r--r-- | src/CLI/ABRTSocket.h | 2 | ||||
-rw-r--r-- | src/CLI/CLI.cpp | 9 | ||||
-rw-r--r-- | src/CLI/dbus.cpp | 58 | ||||
-rw-r--r-- | src/CLI/dbus.h | 2 |
4 files changed, 46 insertions, 25 deletions
diff --git a/src/CLI/ABRTSocket.h b/src/CLI/ABRTSocket.h index 536e4b50..c3a63e51 100644 --- a/src/CLI/ABRTSocket.h +++ b/src/CLI/ABRTSocket.h @@ -23,7 +23,7 @@ class CABRTSocket vector_crash_infos_t GetCrashInfos(); map_crash_report_t CreateReport(const char *pUUID); void Report(const map_crash_report_t& pReport); - void DeleteDebugDump(const char *pUUID); + int32_t DeleteDebugDump(const char *pUUID); }; #endif /* ABRTSOCKET_H_ */ diff --git a/src/CLI/CLI.cpp b/src/CLI/CLI.cpp index ac686ba3..1f7e5430 100644 --- a/src/CLI/CLI.cpp +++ b/src/CLI/CLI.cpp @@ -183,6 +183,7 @@ int main(int argc, char** argv) ABRTDaemon.Connect(VAR_RUN"/abrt.socket"); #endif + int exitcode = 0; switch (op) { case OPT_GET_LIST: @@ -200,7 +201,11 @@ int main(int argc, char** argv) break; case OPT_DELETE: { - call_DeleteDebugDump(uuid); + if (call_DeleteDebugDump(uuid) != 0) + { + log("Can't delete debug dump with UUID '%s'", uuid); + exitcode = 1; + } break; } } @@ -209,5 +214,5 @@ int main(int argc, char** argv) ABRTDaemon.Disconnect(); #endif - return 0; + return exitcode; } diff --git a/src/CLI/dbus.cpp b/src/CLI/dbus.cpp index 2da9d745..f25165bb 100644 --- a/src/CLI/dbus.cpp +++ b/src/CLI/dbus.cpp @@ -106,41 +106,45 @@ static DBusMessage* send_get_reply_and_unref(DBusMessage* msg) vector_crash_infos_t call_GetCrashInfos() { - DBusMessage* msg = new_call_msg("GetCrashInfos"); + DBusMessage* msg = new_call_msg(__func__ + 5); DBusMessage *reply = send_get_reply_and_unref(msg); - vector_crash_infos_t argout; DBusMessageIter in_iter; dbus_message_iter_init(reply, &in_iter); + + vector_crash_infos_t argout; int r = load_val(&in_iter, argout); if (r != ABRT_DBUS_LAST_FIELD) /* more values present, or bad type */ - error_msg_and_die("dbus call %s: return type mismatch", "GetCrashInfos"); + error_msg_and_die("dbus call %s: return type mismatch", __func__ + 5); + dbus_message_unref(reply); return argout; } map_crash_report_t call_CreateReport(const char* uuid) { - DBusMessage* msg = new_call_msg("CreateReport"); + DBusMessage* msg = new_call_msg(__func__ + 5); dbus_message_append_args(msg, DBUS_TYPE_STRING, &uuid, DBUS_TYPE_INVALID); DBusMessage *reply = send_get_reply_and_unref(msg); - map_crash_report_t argout; DBusMessageIter in_iter; dbus_message_iter_init(reply, &in_iter); + + map_crash_report_t argout; int r = load_val(&in_iter, argout); if (r != ABRT_DBUS_LAST_FIELD) /* more values present, or bad type */ - error_msg_and_die("dbus call %s: return type mismatch", "CreateReport"); + error_msg_and_die("dbus call %s: return type mismatch", __func__ + 5); + dbus_message_unref(reply); return argout; } void call_Report(const map_crash_report_t& report) { - DBusMessage* msg = new_call_msg("Report"); + DBusMessage* msg = new_call_msg(__func__ + 5); DBusMessageIter out_iter; dbus_message_iter_init_append(msg, &out_iter); store_val(&out_iter, report); @@ -152,31 +156,42 @@ void call_Report(const map_crash_report_t& report) dbus_message_unref(reply); } -void call_DeleteDebugDump(const char* uuid) +int32_t call_DeleteDebugDump(const char* uuid) { - DBusMessage* msg = new_call_msg("DeleteDebugDump"); + DBusMessage* msg = new_call_msg(__func__ + 5); dbus_message_append_args(msg, DBUS_TYPE_STRING, &uuid, DBUS_TYPE_INVALID); DBusMessage *reply = send_get_reply_and_unref(msg); + DBusMessageIter in_iter; + dbus_message_iter_init(reply, &in_iter); + + int32_t result; + int r = load_val(&in_iter, result); + if (r != ABRT_DBUS_LAST_FIELD) /* more values present, or bad type */ + error_msg_and_die("dbus call %s: return type mismatch", __func__ + 5); + dbus_message_unref(reply); + return result; } vector_map_string_t call_GetPluginsInfo() { - DBusMessage *msg = new_call_msg("GetPluginsInfo"); - DBusMessage *reply = send_get_reply_and_unref(msg); - - vector_map_string_t argout; - DBusMessageIter in_iter; - dbus_message_iter_init(reply, &in_iter); - int r = load_val(&in_iter, argout); - if (r != ABRT_DBUS_LAST_FIELD) /* more values present, or bad type */ - error_msg_and_die("dbus call GetPluginsInfo: return type mismatch"); - dbus_message_unref(reply); - return argout; + DBusMessage *msg = new_call_msg(__func__ + 5); + DBusMessage *reply = send_get_reply_and_unref(msg); + + DBusMessageIter in_iter; + dbus_message_iter_init(reply, &in_iter); + + vector_map_string_t argout; + int r = load_val(&in_iter, argout); + if (r != ABRT_DBUS_LAST_FIELD) /* more values present, or bad type */ + error_msg_and_die("dbus call %s: return type mismatch", __func__ + 5); + + dbus_message_unref(reply); + return argout; } void handle_dbus_err(bool error_flag, DBusError *err) @@ -191,6 +206,7 @@ void handle_dbus_err(bool error_flag, DBusError *err) return; error_msg_and_die( "error requesting DBus name %s, possible reasons: " - "abrt run by non-root; dbus config is incorrect", + "abrt run by non-root; dbus config is incorrect; " + "or dbus daemon needs to be restarted to reload dbus config", ABRTD_DBUS_NAME); } diff --git a/src/CLI/dbus.h b/src/CLI/dbus.h index 48d391e6..f39f5381 100644 --- a/src/CLI/dbus.h +++ b/src/CLI/dbus.h @@ -26,7 +26,7 @@ extern DBusConnection* s_dbus_conn; extern vector_crash_infos_t call_GetCrashInfos(); extern map_crash_report_t call_CreateReport(const char *uuid); extern void call_Report(const map_crash_report_t& report); -extern void call_DeleteDebugDump(const char* uuid); +extern int32_t call_DeleteDebugDump(const char* uuid); /* Gets basic data about all installed plugins. */ |