diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-04 16:19:31 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-04 16:19:31 +0100 |
commit | afb30fe1502e9c45b722da3b5c09e292d589aa7f (patch) | |
tree | 8f0429ccc50987a34e73899c0a724ff6e0205c93 | |
parent | 892b7fde75cafca50a18dcb8620ddc22b2e74688 (diff) | |
download | abrt-afb30fe1502e9c45b722da3b5c09e292d589aa7f.tar.gz abrt-afb30fe1502e9c45b722da3b5c09e292d589aa7f.tar.xz abrt-afb30fe1502e9c45b722da3b5c09e292d589aa7f.zip |
*: UID:UUID -> crash_id conversion
This fixes at least three instances where we did not check whether
user is even allowed to report or delete a crash.
Also fixes a few cases when root might inadvertently act on (e.g. delete)
mote than one crash.
Renamed FILENAME_UID to CD_UID - makes more sense this way.
Added COL_INFORMALL and CD_INFORMALL. Nuked UID == -1 hacks.
Renamed getReport() to start_job on Python side.
Dropped a few unused parameters from server -> client dbus signals.
Fixed CLI's way of reverencing crashes (see updated help text).
Run-tested (GUI and CLI).
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Acked-by: Nikola Pajkovsky <npajkovs@redhat.com>
29 files changed, 444 insertions, 387 deletions
diff --git a/inc/CrashTypes.h b/inc/CrashTypes.h index af106cff..77a2ff27 100644 --- a/inc/CrashTypes.h +++ b/inc/CrashTypes.h @@ -25,7 +25,6 @@ #define FILENAME_ARCHITECTURE "architecture" #define FILENAME_KERNEL "kernel" #define FILENAME_TIME "time" -#define FILENAME_UID "uid" #define FILENAME_PACKAGE "package" #define FILENAME_COMPONENT "component" #define FILENAME_DESCRIPTION "description" @@ -42,8 +41,15 @@ #define FILENAME_MEMORYMAP "memorymap" #define FILENAME_KERNELOOPS "kerneloops" -#define CD_DUPHASH "DUPHASH" +// Apart from CD_UID, which is also stored as a file in dump directory, +// these items only exist in db. (CD_UID is also a file because +// dump directory is created before its DB entry, and DB has to learn +// CD_UID from _somewhere_ in order to be able to store it in DB record, +// right?) +#define CD_UID "uid" /* lowercase: compat with older versions */ #define CD_UUID "UUID" +#define CD_INFORMALL "InformAll" +#define CD_DUPHASH "DUPHASH" #define CD_DUMPDIR "DumpDir" #define CD_COUNT "Count" #define CD_REPORTED "Reported" diff --git a/lib/Plugins/CCpp.cpp b/lib/Plugins/CCpp.cpp index d2bbf3c5..47378690 100644 --- a/lib/Plugins/CCpp.cpp +++ b/lib/Plugins/CCpp.cpp @@ -280,7 +280,7 @@ static void GetBacktrace(const char *pDebugDumpDir, CDebugDump dd; dd.Open(pDebugDumpDir); dd.LoadText(FILENAME_EXECUTABLE, executable); - dd.LoadText(FILENAME_UID, UID); + dd.LoadText(CD_UID, UID); } // Workaround for @@ -414,7 +414,7 @@ static string run_unstrip_n(const char *pDebugDumpDir) { CDebugDump dd; dd.Open(pDebugDumpDir); - dd.LoadText(FILENAME_UID, UID); + dd.LoadText(CD_UID, UID); } char* args[4]; @@ -648,7 +648,7 @@ string CAnalyzerCCpp::GetGlobalUUID(const char *pDebugDumpDir) dd.LoadText(FILENAME_EXECUTABLE, executable); dd.LoadText(FILENAME_PACKAGE, package); if (m_bBacktrace) - dd.LoadText(FILENAME_UID, uid_str); + dd.LoadText(CD_UID, uid_str); } string independent_backtrace; @@ -798,7 +798,7 @@ void CAnalyzerCCpp::CreateReport(const char *pDebugDumpDir, int force) } dd.LoadText(FILENAME_PACKAGE, package); - dd.LoadText(FILENAME_UID, UID); + dd.LoadText(CD_UID, UID); dd.Close(); /* do not keep dir locked longer than needed */ string build_ids; diff --git a/lib/Plugins/Firefox.cpp b/lib/Plugins/Firefox.cpp index 3cb9c938..ac7ab2cd 100644 --- a/lib/Plugins/Firefox.cpp +++ b/lib/Plugins/Firefox.cpp @@ -246,7 +246,7 @@ static void GetBacktrace(const char *pDebugDumpDir, std::string& pBacktrace) CDebugDump dd; dd.Open(pDebugDumpDir); dd.LoadText(FILENAME_EXECUTABLE, executable); - dd.LoadText(FILENAME_UID, UID); + dd.LoadText(CD_UID, UID); } // Workaround for @@ -440,7 +440,7 @@ static std::string run_unstrip_n(const char *pDebugDumpDir) { CDebugDump dd; dd.Open(pDebugDumpDir); - dd.LoadText(FILENAME_UID, UID); + dd.LoadText(CD_UID, UID); } char* args[4]; @@ -884,7 +884,7 @@ void CAnalyzerFirefox::CreateReport(const char *pDebugDumpDir, int force) } dd.LoadText(FILENAME_PACKAGE, package); - dd.LoadText(FILENAME_UID, UID); + dd.LoadText(CD_UID, UID); dd.Close(); /* do not keep dir locked longer than needed */ std::string build_ids; diff --git a/lib/Plugins/Mailx.cpp b/lib/Plugins/Mailx.cpp index 50bc3920..f9dd2cca 100644 --- a/lib/Plugins/Mailx.cpp +++ b/lib/Plugins/Mailx.cpp @@ -132,7 +132,7 @@ std::string CMailx::Report(const map_crash_data_t& pCrashData, args = append_str_to_vector(args, arg_size, m_sEmailTo.c_str()); update_client(_("Sending an email...")); - const char *uid_str = get_crash_data_item_content(pCrashData, FILENAME_UID).c_str(); + const char *uid_str = get_crash_data_item_content(pCrashData, CD_UID).c_str(); exec_and_feed_input(xatoi_u(uid_str), emailBody.c_str(), args); while (*args) diff --git a/lib/Plugins/SQLite3.cpp b/lib/Plugins/SQLite3.cpp index 5819b98c..b076dfaf 100644 --- a/lib/Plugins/SQLite3.cpp +++ b/lib/Plugins/SQLite3.cpp @@ -25,14 +25,15 @@ using namespace std; -#define ABRT_TABLE_VERSION 3 -#define ABRT_TABLE_VERSION_STR "3" +#define ABRT_TABLE_VERSION 4 +#define ABRT_TABLE_VERSION_STR "4" #define ABRT_TABLE "abrt_v"ABRT_TABLE_VERSION_STR #define ABRT_REPRESULT_TABLE "abrt_v"ABRT_TABLE_VERSION_STR"_reportresult" #define SQLITE3_MASTER_TABLE "sqlite_master" -#define COL_UUID "UUID" #define COL_UID "UID" +#define COL_UUID "UUID" +#define COL_INFORMALL "InformAll" #define COL_DEBUG_DUMP_PATH "DebugDumpPath" #define COL_COUNT "Count" #define COL_REPORTED "Reported" @@ -99,6 +100,9 @@ static string sql_escape(const char *str) } #endif +/* Note: + * expects "SELECT * FROM ...", not "SELECT <only some fields> FROM ..." + */ static void get_table(vector_database_rows_t& pTable, sqlite3 *db, const char *fmt, ...) { @@ -134,11 +138,12 @@ static void get_table(vector_database_rows_t& pTable, { case 0: row.m_sUUID = val; break; case 1: row.m_sUID = val; break; - case 2: row.m_sDebugDumpDir = val; break; - case 3: row.m_sCount = val; break; - case 4: row.m_sReported = val; break; - case 5: row.m_sTime = val; break; - case 6: row.m_sMessage = val; break; + case 2: row.m_sInformAll = val; break; + case 3: row.m_sDebugDumpDir = val; break; + case 4: row.m_sCount = val; break; + case 5: row.m_sReported = val; break; + case 6: row.m_sTime = val; break; + case 7: row.m_sMessage = val; break; } } pTable.push_back(row); @@ -170,14 +175,13 @@ static int execute_sql(sqlite3 *db, const char *fmt, ...) return affected; } -static bool exists_uuid_uid(sqlite3 *db, const char *pUUID, const char *pUID) +static bool exists_uuid_uid(sqlite3 *db, const char *UUID, const char *UID) { vector_database_rows_t table; get_table(table, db, - "SELECT "COL_REPORTED" FROM "ABRT_TABLE" WHERE " - COL_UUID" = '%s' " - "AND ("COL_UID" = '%s' OR "COL_UID" = '-1');", - pUUID, pUID + "SELECT * FROM "ABRT_TABLE + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s';", + UUID, UID ); return !table.empty(); } @@ -230,13 +234,49 @@ static void update_from_old_ver(sqlite3 *db, int old_version) COL_MESSAGE " FROM abrt_v2;" "DROP TABLE abrt_v2;" - "CREATE TABLE "ABRT_REPRESULT_TABLE" (" + "CREATE TABLE abrt_v3_reportresult (" COL_UUID" VARCHAR NOT NULL," COL_UID" VARCHAR NOT NULL," COL_REPORTER" VARCHAR NOT NULL," COL_MESSAGE" VARCHAR NOT NULL DEFAULT ''," "PRIMARY KEY ("COL_UUID","COL_UID","COL_REPORTER"));" "COMMIT;", + // v3-> v4 + "BEGIN TRANSACTION;" + "CREATE TABLE abrt_v4(" + COL_UUID" VARCHAR NOT NULL," + COL_UID" VARCHAR NOT NULL," + COL_INFORMALL" INT NOT NULL DEFAULT 0," + COL_DEBUG_DUMP_PATH" VARCHAR NOT NULL," + COL_COUNT" INT NOT NULL DEFAULT 1," + COL_REPORTED" INT NOT NULL DEFAULT 0," + COL_TIME" VARCHAR NOT NULL DEFAULT 0," + COL_MESSAGE" VARCHAR NOT NULL DEFAULT ''," + "PRIMARY KEY ("COL_UUID","COL_UID"));" + "INSERT INTO abrt_v4 " + "SELECT "COL_UUID"," + COL_UID"," + "0," /* COL_INFORMALL */ + COL_DEBUG_DUMP_PATH"," + COL_COUNT"," + COL_REPORTED"," + COL_TIME"," + COL_MESSAGE + " FROM abrt_v3;" + "DROP TABLE abrt_v3;" + "UPDATE abrt_v4" + " SET "COL_UID"='0', "COL_INFORMALL"=1" + " WHERE "COL_UID"='-1';" + "CREATE TABLE abrt_v4_reportresult (" + COL_UUID" VARCHAR NOT NULL," + COL_UID" VARCHAR NOT NULL," + COL_REPORTER" VARCHAR NOT NULL," + COL_MESSAGE" VARCHAR NOT NULL DEFAULT ''," + "PRIMARY KEY ("COL_UUID","COL_UID","COL_REPORTER"));" + "INSERT INTO abrt_v4_reportresult " + "SELECT * FROM abrt_v3_reportresult;" + "DROP TABLE abrt_v3_reportresult;" + "COMMIT;", }; while (old_version < ABRT_TABLE_VERSION) @@ -266,13 +306,14 @@ static bool check_table(sqlite3 *db) } // table format: - // table[0]:"NAME" // table[1]:"SQL" <== field names from SELECT + // table[0]:"NAME" // table[1]:"SQL" <== field names from SELECT // table[2]:"abrt_vNN" // table[3]:"sql" char *tableName = table[0 + ncol]; char *underscore = strchr(tableName, '_'); if (underscore) { - int tableVersion = xatoi_u(underscore + 2); + // It can be "abrt_vNN_something", thus using atoi(), not xatoi() + int tableVersion = atoi(underscore + 2); sqlite3_free_table(table); if (tableVersion < ABRT_TABLE_VERSION) { @@ -348,6 +389,7 @@ void CSQLite3::Connect() "CREATE TABLE "ABRT_TABLE" (" COL_UUID" VARCHAR NOT NULL," COL_UID" VARCHAR NOT NULL," + COL_INFORMALL" INT NOT NULL DEFAULT 0," COL_DEBUG_DUMP_PATH" VARCHAR NOT NULL," COL_COUNT" INT NOT NULL DEFAULT 1," COL_REPORTED" INT NOT NULL DEFAULT 0," @@ -366,82 +408,83 @@ void CSQLite3::Connect() } } -void CSQLite3::Insert_or_Update(const char *pUUID, - const char *pUID, +void CSQLite3::Insert_or_Update(const char *crash_id, + bool inform_all_users, const char *pDebugDumpPath, const char *pTime) { - if (!is_string_safe(pUUID) - || !is_string_safe(pUID) + const char *UUID = strchr(crash_id, ':'); + if (!UUID + || !is_string_safe(crash_id) || !is_string_safe(pDebugDumpPath) || !is_string_safe(pTime) ) { return; } - if (!exists_uuid_uid(m_pDB, pUUID, pUID)) + /* Split crash_id into UID:UUID */ + unsigned uid_len = UUID - crash_id; + UUID++; + char UID[uid_len + 1]; + strncpy(UID, crash_id, uid_len); + UID[uid_len] = '\0'; + + if (!exists_uuid_uid(m_pDB, UUID, UID)) { execute_sql(m_pDB, "INSERT INTO "ABRT_TABLE" (" COL_UUID"," COL_UID"," + COL_INFORMALL"," COL_DEBUG_DUMP_PATH"," COL_TIME ")" - " VALUES ('%s','%s','%s','%s');", - pUUID, pUID, pDebugDumpPath, pTime + " VALUES ('%s','%s',%u,'%s','%s');", + UUID, UID, (unsigned)inform_all_users, pDebugDumpPath, pTime ); } else { execute_sql(m_pDB, - "UPDATE "ABRT_TABLE" SET " - COL_COUNT" = "COL_COUNT" + 1, " - COL_TIME" = '%s'" - " WHERE "COL_UUID" = '%s'" - " AND "COL_UID" = '%s';", - pTime, pUUID, pUID + "UPDATE "ABRT_TABLE + " SET "COL_COUNT"="COL_COUNT"+1,"COL_TIME"='%s'" + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s';", + pTime, + UUID, UID ); } } -void CSQLite3::DeleteRow(const char *pUUID, const char *pUID) +void CSQLite3::DeleteRow(const char *crash_id) { - if (!is_string_safe(pUUID) - || !is_string_safe(pUID) + const char *UUID = strchr(crash_id, ':'); + if (!UUID + || !is_string_safe(crash_id) ) { return; } - if (pUID[0] == '0' && !pUID[1]) - { - execute_sql(m_pDB, - "DELETE FROM "ABRT_TABLE" " - "WHERE "COL_UUID" = '%s';", - pUUID - ); - execute_sql(m_pDB, - "DELETE FROM "ABRT_REPRESULT_TABLE" " - "WHERE "COL_UUID" = '%s';", - pUUID - ); - } - else if (exists_uuid_uid(m_pDB, pUUID, pUID)) + /* Split crash_id into UID:UUID */ + unsigned uid_len = UUID - crash_id; + UUID++; + char UID[uid_len + 1]; + strncpy(UID, crash_id, uid_len); + UID[uid_len] = '\0'; + + if (exists_uuid_uid(m_pDB, UUID, UID)) { - execute_sql(m_pDB, "DELETE FROM "ABRT_TABLE" " - "WHERE "COL_UUID" = '%s' " - "AND ("COL_UID" = '%s' OR "COL_UID" = '-1');", - pUUID, pUID + execute_sql(m_pDB, "DELETE FROM "ABRT_TABLE + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s';", + UUID, UID ); - execute_sql(m_pDB, "DELETE FROM "ABRT_REPRESULT_TABLE" " - "WHERE "COL_UUID" = '%s' " - "AND ("COL_UID" = '%s' OR "COL_UID" = '-1');", - pUUID, pUID + execute_sql(m_pDB, "DELETE FROM "ABRT_REPRESULT_TABLE + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s';", + UUID, UID ); } else { - error_msg("UUID,UID %s,%s is not found in DB", pUUID, pUID); + error_msg("crash_id %s is not found in DB", crash_id); } } @@ -455,8 +498,8 @@ void CSQLite3::DeleteRows_by_dir(const char *dump_dir) /* Get UID:UUID pair(s) to delete */ vector_database_rows_t table; get_table(table, m_pDB, - "SELECT * FROM "ABRT_TABLE" " - "WHERE "COL_DEBUG_DUMP_PATH" = '%s'", + "SELECT * FROM "ABRT_TABLE + " WHERE "COL_DEBUG_DUMP_PATH"='%s';", dump_dir ); if (table.empty()) @@ -469,84 +512,82 @@ void CSQLite3::DeleteRows_by_dir(const char *dump_dir) while (it != table.end()) { execute_sql(m_pDB, - "DELETE FROM "ABRT_REPRESULT_TABLE" " - "WHERE "COL_UUID" = '%s' " - "AND ("COL_UID" = '%s');", + "DELETE FROM "ABRT_REPRESULT_TABLE + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s';", it->m_sUUID.c_str(), it->m_sUID.c_str() ); } execute_sql(m_pDB, - "DELETE FROM "ABRT_TABLE" " - "WHERE "COL_DEBUG_DUMP_PATH" = '%s'", + "DELETE FROM "ABRT_TABLE + " WHERE "COL_DEBUG_DUMP_PATH"='%s'", dump_dir ); } -void CSQLite3::SetReported(const char *pUUID, const char *pUID, const char *pMessage) +void CSQLite3::SetReported(const char *crash_id, const char *pMessage) { - if (!is_string_safe(pUUID) - || !is_string_safe(pUID) + const char *UUID = strchr(crash_id, ':'); + if (!UUID + || !is_string_safe(crash_id) || !is_string_safe(pMessage) ) { return; } - if (pUID[0] == '0' && !pUID[1]) - { - execute_sql(m_pDB, - "UPDATE "ABRT_TABLE" " - "SET "COL_REPORTED" = 1 " - "WHERE "COL_UUID" = '%s';", - pUUID - ); - execute_sql(m_pDB, "UPDATE "ABRT_TABLE" " - "SET "COL_MESSAGE" = '%s' " - "WHERE "COL_UUID" = '%s';", - pMessage, pUUID - ); - } - else if (exists_uuid_uid(m_pDB, pUUID, pUID)) + /* Split crash_id into UID:UUID */ + unsigned uid_len = UUID - crash_id; + UUID++; + char UID[uid_len + 1]; + strncpy(UID, crash_id, uid_len); + UID[uid_len] = '\0'; + + if (exists_uuid_uid(m_pDB, UUID, UID)) { execute_sql(m_pDB, - "UPDATE "ABRT_TABLE" " - "SET "COL_REPORTED" = 1 " - "WHERE "COL_UUID" = '%s' " - "AND ("COL_UID" = '%s' OR "COL_UID" = '-1');", - pUUID, pUID + "UPDATE "ABRT_TABLE + " SET "COL_REPORTED"=1" + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s';", + UUID, UID ); execute_sql(m_pDB, - "UPDATE "ABRT_TABLE" " - "SET "COL_MESSAGE" = '%s' " - "WHERE "COL_UUID" = '%s' " - "AND ("COL_UID" = '%s' OR "COL_UID" = '-1');", - pMessage, pUUID, pUID + "UPDATE "ABRT_TABLE + " SET "COL_MESSAGE"='%s'" + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s';", + pMessage, UUID, UID ); } else { - error_msg("UUID,UID %s,%s is not found in DB", pUUID, pUID); + error_msg("crash_id %s is not found in DB", crash_id); } } -void CSQLite3::SetReportedPerReporter(const char *pUUID, - const char *pUID, +void CSQLite3::SetReportedPerReporter(const char *crash_id, const char *reporter, const char *pMessage) { - if (!is_string_safe(pUUID) - || !is_string_safe(pUID) + const char *UUID = strchr(crash_id, ':'); + if (!UUID + || !is_string_safe(crash_id) || !is_string_safe(reporter) || !is_string_safe(pMessage) ) { return; } + /* Split crash_id into UID:UUID */ + unsigned uid_len = UUID - crash_id; + UUID++; + char UID[uid_len + 1]; + strncpy(UID, crash_id, uid_len); + UID[uid_len] = '\0'; + int affected_rows = execute_sql(m_pDB, "UPDATE "ABRT_REPRESULT_TABLE " SET "COL_MESSAGE"='%s'" " WHERE "COL_UUID"='%s' AND "COL_UID"='%s' AND "COL_REPORTER"='%s'", pMessage, - pUUID, pUID, reporter + UUID, UID, reporter ); if (!affected_rows) { @@ -554,21 +595,16 @@ void CSQLite3::SetReportedPerReporter(const char *pUUID, "INSERT INTO "ABRT_REPRESULT_TABLE " ("COL_UUID","COL_UID","COL_REPORTER","COL_MESSAGE")" " VALUES ('%s','%s','%s','%s');", - pUUID, pUID, reporter, pMessage + UUID, UID, reporter, pMessage ); } } -vector_database_rows_t CSQLite3::GetUIDData(const char *pUID) +vector_database_rows_t CSQLite3::GetUIDData(long caller_uid) { vector_database_rows_t table; - if (!is_string_safe(pUID)) - { - return table; - } - - if (pUID[0] == '0' && !pUID[1]) + if (caller_uid == 0) { get_table(table, m_pDB, "SELECT * FROM "ABRT_TABLE";"); } @@ -576,40 +612,35 @@ vector_database_rows_t CSQLite3::GetUIDData(const char *pUID) { get_table(table, m_pDB, "SELECT * FROM "ABRT_TABLE - " WHERE "COL_UID" = '%s' OR "COL_UID" = '-1';", - pUID + " WHERE "COL_UID"='%ld' OR "COL_INFORMALL"=1;", + caller_uid ); } return table; } -database_row_t CSQLite3::GetRow(const char *pUUID, const char *pUID) +database_row_t CSQLite3::GetRow(const char *crash_id) { - if (!is_string_safe(pUUID) - || !is_string_safe(pUID) + const char *UUID = strchr(crash_id, ':'); + if (!UUID + || !is_string_safe(crash_id) ) { return database_row_t(); } - vector_database_rows_t table; + /* Split crash_id into UID:UUID */ + unsigned uid_len = UUID - crash_id; + UUID++; + char UID[uid_len + 1]; + strncpy(UID, crash_id, uid_len); + UID[uid_len] = '\0'; - if (pUID[0] == '0' && !pUID[1]) - { - get_table(table, m_pDB, - "SELECT * FROM "ABRT_TABLE" " - "WHERE "COL_UUID" = '%s';", - pUUID - ); - } - else - { - get_table(table, m_pDB, - "SELECT * FROM "ABRT_TABLE" " - "WHERE "COL_UUID" = '%s' " - "AND ("COL_UID" = '%s' OR "COL_UID" = '-1');", - pUUID, pUID - ); - } + vector_database_rows_t table; + get_table(table, m_pDB, + "SELECT * FROM "ABRT_TABLE + " WHERE "COL_UUID"='%s' AND "COL_UID"='%s';", + UUID, UID + ); if (table.size() == 0) { diff --git a/lib/Plugins/SQLite3.h b/lib/Plugins/SQLite3.h index 94cb0422..b9dc9e7f 100644 --- a/lib/Plugins/SQLite3.h +++ b/lib/Plugins/SQLite3.h @@ -37,20 +37,18 @@ class CSQLite3 : public CDatabase virtual void Connect(); virtual void DisConnect(); - virtual void Insert_or_Update(const char *pUUID, - const char *pUID, + virtual void Insert_or_Update(const char *crash_id, + bool inform_all_users, const char *pDebugDumpPath, const char *pTime); - - virtual void DeleteRow(const char *pUUID, const char *pUID); + virtual void DeleteRow(const char *crash_id); virtual void DeleteRows_by_dir(const char *dump_dir); - virtual void SetReported(const char *pUUID, const char *pUID, const char *pMessage); - virtual void SetReportedPerReporter(const char *pUUID, - const char *pUID, + virtual void SetReported(const char *crash_id, const char *pMessage); + virtual void SetReportedPerReporter(const char *crash_id, const char *reporter, const char *pMessage); - virtual vector_database_rows_t GetUIDData(const char *pUID); - virtual database_row_t GetRow(const char *pUUID, const char *pUID); + virtual vector_database_rows_t GetUIDData(long caller_uid); + virtual database_row_t GetRow(const char *crash_id); virtual void SetSettings(const map_plugin_settings_t& pSettings); }; diff --git a/lib/Utils/CommLayerInner.cpp b/lib/Utils/CommLayerInner.cpp index bde3a71c..9512019d 100644 --- a/lib/Utils/CommLayerInner.cpp +++ b/lib/Utils/CommLayerInner.cpp @@ -42,7 +42,7 @@ static void warn_client(const char *msg) pthread_mutex_unlock(&s_map_mutex); if (peer) - s_pObs->Warning(msg, peer, key); + s_pObs->Warning(msg, peer); } void init_daemon_logging(CObserver *pObs) @@ -89,6 +89,6 @@ void update_client(const char *fmt, ...) char *msg = xvasprintf(fmt, p); va_end(p); - s_pObs->Status(msg, peer, key); + s_pObs->Status(msg, peer); free(msg); } diff --git a/lib/Utils/Database.h b/lib/Utils/Database.h index 6d7613bb..a698bcbc 100644 --- a/lib/Utils/Database.h +++ b/lib/Utils/Database.h @@ -40,6 +40,7 @@ typedef struct database_row_t { std::string m_sUUID; /**< A local UUID.*/ std::string m_sUID; /**< An UID of an user.*/ + std::string m_sInformAll; std::string m_sDebugDumpDir; /**< A debugdump directory of a crash.*/ std::string m_sCount; /**< Crash rate.*/ std::string m_sReported; /**< Is a row reported?*/ @@ -73,8 +74,8 @@ class CDatabase : public CPlugin * @param pDebugDumpPath A debugdump path. * @param pTime Time when a crash occurs. */ - virtual void Insert_or_Update(const char *pUUID, - const char *pUID, + virtual void Insert_or_Update(const char *crash_id, + bool inform_all_users, const char *pDebugDumpPath, const char *pTime) = 0; /** @@ -82,8 +83,7 @@ class CDatabase : public CPlugin * @param pUUID A lodal UUID of a crash. * @param pUID An UID of an user. */ - virtual void DeleteRow(const char *pUUID, - const char *pUID) = 0; + virtual void DeleteRow(const char *crash_id) = 0; virtual void DeleteRows_by_dir(const char *dump_dir) = 0; /** * A method, which sets that particular row was reported. @@ -92,11 +92,9 @@ class CDatabase : public CPlugin * @param pMessage A text explanation of reported problem * (where it is stored etc)... */ - virtual void SetReported(const char *pUUID, - const char *pUID, + virtual void SetReported(const char *crash_id, const char *pMessage) = 0; - virtual void SetReportedPerReporter(const char *pUUID, - const char *pUID, + virtual void SetReportedPerReporter(const char *crash_id, const char *reporter, const char *pMessage) = 0; /** @@ -106,7 +104,7 @@ class CDatabase : public CPlugin * @param pUID An UID of an user. * @return A vector of matched rows. */ - virtual vector_database_rows_t GetUIDData(const char *pUID) = 0; + virtual vector_database_rows_t GetUIDData(long caller_uid) = 0; /** * A method, which returns one row accordind to UUID of a crash and * UID of an user. If there are no row, empty row is returned. @@ -114,8 +112,7 @@ class CDatabase : public CPlugin * @param pUID An UID of an user. * @return A matched row. */ - virtual database_row_t GetRow(const char *pUUID, - const char *pUID) = 0; + virtual database_row_t GetRow(const char *crash_id) = 0; }; #endif diff --git a/lib/Utils/DebugDump.cpp b/lib/Utils/DebugDump.cpp index b8f8827c..97c387c5 100644 --- a/lib/Utils/DebugDump.cpp +++ b/lib/Utils/DebugDump.cpp @@ -319,7 +319,7 @@ void CDebugDump::Create(const char *pDir, uid_t uid) (long)m_uid, (long)m_gid); } - SaveText(FILENAME_UID, to_string(uid).c_str()); + SaveText(CD_UID, to_string(uid).c_str()); SaveKernelArchitectureRelease(); time_t t = time(NULL); SaveText(FILENAME_TIME, to_string(t).c_str()); diff --git a/lib/Utils/Observer.h b/lib/Utils/Observer.h index adf6844a..ec7dfa7b 100644 --- a/lib/Utils/Observer.h +++ b/lib/Utils/Observer.h @@ -26,8 +26,8 @@ class CObserver { public: virtual ~CObserver() {} - virtual void Status(const char *pMessage, const char* peer, uint64_t pDest) = 0; - virtual void Warning(const char *pMessage, const char* peer, uint64_t pDest) = 0; + virtual void Status(const char *pMessage, const char* peer) = 0; + virtual void Warning(const char *pMessage, const char* peer) = 0; }; #endif diff --git a/lib/Utils/make_descr.cpp b/lib/Utils/make_descr.cpp index 80198965..a2f0c034 100644 --- a/lib/Utils/make_descr.cpp +++ b/lib/Utils/make_descr.cpp @@ -68,14 +68,16 @@ static void add_content(bool &was_multiline, string& description, const char *he } } +/* Items we don't want to include */ static const char *const blacklisted_items_bz[] = { FILENAME_TIME , - FILENAME_UID , FILENAME_ANALYZER , FILENAME_COREDUMP , FILENAME_DESCRIPTION, /* package description - basically useless */ - CD_DUPHASH , + CD_UID , CD_UUID , + CD_INFORMALL , + CD_DUPHASH , CD_DUMPDIR , CD_COUNT , CD_REPORTED , diff --git a/lib/Utils/test.cpp b/lib/Utils/test.cpp index 24a62760..35edb0c5 100644 --- a/lib/Utils/test.cpp +++ b/lib/Utils/test.cpp @@ -92,7 +92,7 @@ int main(int argc, char** argv) */ map_crash_data_t crashReport; middleWare.CreateCrashReport(crashInfo[CD_DUPHASH][CD_CONTENT], - crashInfo[FILENAME_UID][CD_CONTENT], + crashInfo[CD_UID][CD_CONTENT], crashReport); /* Report crash */ middleWare.Report(crashReport); diff --git a/src/CLI/CLI.cpp b/src/CLI/CLI.cpp index ef88732f..fcf1f0cd 100644 --- a/src/CLI/CLI.cpp +++ b/src/CLI/CLI.cpp @@ -73,7 +73,7 @@ static void print_crash_infos(vector_map_crash_data_t& pCrashInfos, int pMode) "\tCrash Time : %s\n" "\tCrash Count: %s\n"), ii, - get_crash_data_item_content(info, FILENAME_UID).c_str(), + get_crash_data_item_content(info, CD_UID).c_str(), get_crash_data_item_content(info, CD_UUID).c_str(), get_crash_data_item_content(info, FILENAME_PACKAGE).c_str(), get_crash_data_item_content(info, FILENAME_EXECUTABLE).c_str(), @@ -84,6 +84,39 @@ static void print_crash_infos(vector_map_crash_data_t& pCrashInfos, int pMode) } } +static char *guess_crash_id(const char *str) +{ + vector_map_crash_data_t ci = call_GetCrashInfos(); + unsigned num_crashinfos = ci.size(); + if (str[0] == '@') /* "--report @N" syntax */ + { + unsigned position = xatoi_u(str + 1); + if (position >= num_crashinfos) + error_msg_and_die("There are only %u crash infos", num_crashinfos); + map_crash_data_t& info = ci[position]; + return xasprintf("%s:%s", + get_crash_data_item_content(info, CD_UID).c_str(), + get_crash_data_item_content(info, CD_UUID).c_str() + ); + } + + unsigned len = strlen(str); + unsigned ii; + for (ii = 0; ii < num_crashinfos; ii++) + { + map_crash_data_t& info = ci[ii]; + const char *this_uuid = get_crash_data_item_content(info, CD_UUID).c_str(); + if (strncmp(str, this_uuid, len) == 0) + { + return xasprintf("%s:%s", + get_crash_data_item_content(info, CD_UID).c_str(), + this_uuid + ); + } + } + error_msg_and_die("Crash '%s' not found", str); +} + static const struct option longopts[] = { /* name, has_arg, flag, val */ @@ -120,15 +153,20 @@ static void usage(char *argv0) "Actions:\n" " --get-list print list of crashes which are not reported yet\n" " --get-list-full print list of all crashes\n" - " --report UUID create and send a report\n" - " --report-always UUID create and send a report without asking\n" - " --delete UUID remove crash\n"), + " --report CRASH_ID create and send a report\n" + " --report-always CRASH_ID create and send a report without asking\n" + " --delete CRASH_ID remove crash\n" + "CRASH_ID may be:\n" + " an UID:UUID pair,\n" + " an UUID prefix - the first crash with matching UUID will be acted upon\n" + " @N - N'th crash (as displayed by --get-list-full) will be acted upon\n" + ), name, name); } int main(int argc, char** argv) { - const char* uuid = NULL; + const char* crash_id = NULL; int op = -1; setlocale(LC_ALL, ""); @@ -146,7 +184,7 @@ int main(int argc, char** argv) case OPT_REPORT: case OPT_REPORT_ALWAYS: case OPT_DELETE: - uuid = optarg; + crash_id = optarg; /* fall through */ case OPT_GET_LIST: case OPT_GET_LIST_FULL: @@ -195,45 +233,30 @@ int main(int argc, char** argv) } case OPT_REPORT: case OPT_REPORT_ALWAYS: - exitcode = report(uuid, op == OPT_REPORT_ALWAYS); - if (exitcode == -1) /* no such UUID */ + exitcode = report(crash_id, op == OPT_REPORT_ALWAYS); + if (exitcode == -1) /* no such crash_id */ { - vector_map_crash_data_t ci = call_GetCrashInfos(); - unsigned num_crashinfos = ci.size(); - if (uuid[0] == '@') /* "--report @N" syntax */ - { - unsigned position = xatoi_u(uuid + 1); - if (position >= num_crashinfos) - error_msg_and_die("There are only %u crash infos", num_crashinfos); - map_crash_data_t& info = ci[position]; - uuid = get_crash_data_item_content(info, CD_UUID).c_str(); - } else { - unsigned uuid_len = strlen(uuid); - unsigned ii; - for (ii = 0; ii < num_crashinfos; ii++) - { - map_crash_data_t& info = ci[ii]; - const char *this_uuid = get_crash_data_item_content(info, CD_UUID).c_str(); - if (strncmp(uuid, this_uuid, uuid_len) == 0) - { - uuid = this_uuid; - goto do_report; - } - } - error_msg_and_die("Crash '%s' not found", uuid); - } - do_report: - exitcode = report(uuid, op == OPT_REPORT_ALWAYS); + crash_id = guess_crash_id(crash_id); + exitcode = report(crash_id, op == OPT_REPORT_ALWAYS); if (exitcode == -1) - error_msg_and_die("Crash '%s' not found", uuid); + error_msg_and_die("Crash '%s' not found", crash_id); } break; case OPT_DELETE: { - if (call_DeleteDebugDump(uuid) != 0) + exitcode = call_DeleteDebugDump(crash_id); + if (exitcode == ENOENT) + { + crash_id = guess_crash_id(crash_id); + exitcode = call_DeleteDebugDump(crash_id); + if (exitcode == ENOENT) + { + error_msg_and_die("Crash '%s' not found", crash_id); + } + } + if (exitcode != 0) { - log("Can't delete debug dump with UUID '%s'", uuid); - exitcode = 1; + error_msg_and_die("Can't delete debug dump '%s'", crash_id); } break; } diff --git a/src/CLI/dbus.cpp b/src/CLI/dbus.cpp index db45cd8b..b251c6f0 100644 --- a/src/CLI/dbus.cpp +++ b/src/CLI/dbus.cpp @@ -121,11 +121,11 @@ vector_map_crash_data_t call_GetCrashInfos() return argout; } -map_crash_data_t call_CreateReport(const char* uuid) +map_crash_data_t call_CreateReport(const char* crash_id) { DBusMessage* msg = new_call_msg(__func__ + 5); dbus_message_append_args(msg, - DBUS_TYPE_STRING, &uuid, + DBUS_TYPE_STRING, &crash_id, DBUS_TYPE_INVALID); DBusMessage *reply = send_get_reply_and_unref(msg); @@ -166,11 +166,11 @@ report_status_t call_Report(const map_crash_data_t& report, return result; } -int32_t call_DeleteDebugDump(const char* uuid) +int32_t call_DeleteDebugDump(const char* crash_id) { DBusMessage* msg = new_call_msg(__func__ + 5); dbus_message_append_args(msg, - DBUS_TYPE_STRING, &uuid, + DBUS_TYPE_STRING, &crash_id, DBUS_TYPE_INVALID); DBusMessage *reply = send_get_reply_and_unref(msg); diff --git a/src/CLI/dbus.h b/src/CLI/dbus.h index c5eebbd7..be6b9615 100644 --- a/src/CLI/dbus.h +++ b/src/CLI/dbus.h @@ -24,7 +24,7 @@ extern DBusConnection* s_dbus_conn; vector_map_crash_data_t call_GetCrashInfos(); -map_crash_data_t call_CreateReport(const char *uuid); +map_crash_data_t call_CreateReport(const char *crash_id); /** Sends report using enabled Reporter plugins. * @param plugins @@ -36,7 +36,7 @@ map_crash_data_t call_CreateReport(const char *uuid); */ report_status_t call_Report(const map_crash_data_t& report, const map_map_string_t &plugins); -int32_t call_DeleteDebugDump(const char* uuid); +int32_t call_DeleteDebugDump(const char* crash_id); /* Gets basic data about all installed plugins. */ diff --git a/src/CLI/report.cpp b/src/CLI/report.cpp index 41ac6c2c..68df2d7d 100644 --- a/src/CLI/report.cpp +++ b/src/CLI/report.cpp @@ -523,11 +523,11 @@ static void get_reporter_plugin_settings(map_map_string_t &settings, bool ask_us } } -/* Reports the crash with corresponding uuid over DBus. */ -int report(const char *uuid, bool always) +/* Reports the crash with corresponding crash_id over DBus. */ +int report(const char *crash_id, bool always) { // Ask for an initial report. - map_crash_data_t cr = call_CreateReport(uuid); + map_crash_data_t cr = call_CreateReport(crash_id); if (cr.size() == 0) { return -1; diff --git a/src/Daemon/CommLayerServer.h b/src/Daemon/CommLayerServer.h index bb33a1e9..6e593d29 100644 --- a/src/Daemon/CommLayerServer.h +++ b/src/Daemon/CommLayerServer.h @@ -31,11 +31,11 @@ class CCommLayerServer { /* just stubs to be called when not implemented in specific comm layer */ virtual void Crash(const char *progname, const char *uid_str) {} - virtual void JobDone(const char* pDest, const char* pUUID) = 0; + virtual void JobDone(const char* peer) = 0; virtual void QuotaExceed(const char* str) {} - virtual void Update(const char* pMessage, const char* peer, uint64_t pJobID) {}; - virtual void Warning(const char* pMessage, const char* peer, uint64_t pJobID) {}; + virtual void Update(const char* pMessage, const char* peer) {}; + virtual void Warning(const char* pMessage, const char* peer) {}; }; #endif diff --git a/src/Daemon/CommLayerServerDBus.cpp b/src/Daemon/CommLayerServerDBus.cpp index a397dd15..6dcb8e45 100644 --- a/src/Daemon/CommLayerServerDBus.cpp +++ b/src/Daemon/CommLayerServerDBus.cpp @@ -95,33 +95,27 @@ void CCommLayerServerDBus::QuotaExceed(const char* str) send_flush_and_unref(msg); } -void CCommLayerServerDBus::JobDone(const char* peer, const char* pUUID) +void CCommLayerServerDBus::JobDone(const char* peer) { DBusMessage* msg = new_signal_msg("JobDone", peer); - dbus_message_append_args(msg, - DBUS_TYPE_STRING, &peer, /* TODO: redundant parameter, remove from API */ - DBUS_TYPE_STRING, &pUUID, /* TODO: redundant parameter, remove from API */ - DBUS_TYPE_INVALID); - VERB2 log("Sending signal JobDone('%s','%s')", peer, pUUID); + VERB2 log("Sending signal JobDone() to peer %s", peer); send_flush_and_unref(msg); } -void CCommLayerServerDBus::Update(const char* pMessage, const char* peer, uint64_t job_id) +void CCommLayerServerDBus::Update(const char* pMessage, const char* peer) { DBusMessage* msg = new_signal_msg("Update", peer); dbus_message_append_args(msg, DBUS_TYPE_STRING, &pMessage, - DBUS_TYPE_UINT64, &job_id, /* TODO: redundant parameter, remove from API */ DBUS_TYPE_INVALID); send_flush_and_unref(msg); } -void CCommLayerServerDBus::Warning(const char* pMessage, const char* peer, uint64_t job_id) +void CCommLayerServerDBus::Warning(const char* pMessage, const char* peer) { DBusMessage* msg = new_signal_msg("Warning", peer); dbus_message_append_args(msg, DBUS_TYPE_STRING, &pMessage, - DBUS_TYPE_UINT64, &job_id, /* TODO: redundant parameter, remove from API */ DBUS_TYPE_INVALID); send_flush_and_unref(msg); } @@ -151,7 +145,7 @@ static long get_remote_uid(DBusMessage* call, const char** ppSender = NULL) static int handle_GetCrashInfos(DBusMessage* call, DBusMessage* reply) { long unix_uid = get_remote_uid(call); - vector_map_crash_data_t argout1 = GetCrashInfos(to_string(unix_uid).c_str()); + vector_map_crash_data_t argout1 = GetCrashInfos(unix_uid); DBusMessageIter out_iter; dbus_message_iter_init_append(reply, &out_iter); @@ -166,8 +160,8 @@ static int handle_StartJob(DBusMessage* call, DBusMessage* reply) int r; DBusMessageIter in_iter; dbus_message_iter_init(call, &in_iter); - const char* pUUID; - r = load_val(&in_iter, pUUID); + const char* crash_id; + r = load_val(&in_iter, crash_id); if (r != ABRT_DBUS_MORE_FIELDS) { error_msg("dbus call %s: parameter type mismatch", __func__ + 7); @@ -183,13 +177,9 @@ static int handle_StartJob(DBusMessage* call, DBusMessage* reply) const char* sender; long unix_uid = get_remote_uid(call, &sender); - if (CreateReportThread(pUUID, to_string(unix_uid).c_str(), force, sender) != 0) + if (CreateReportThread(crash_id, unix_uid, force, sender) != 0) return -1; /* can't create thread (err msg is already logged) */ - dbus_message_append_args(reply, - DBUS_TYPE_STRING, &pUUID, /* redundant, eliminate from API */ - DBUS_TYPE_INVALID); - send_flush_and_unref(reply); return 0; } @@ -199,8 +189,8 @@ static int handle_CreateReport(DBusMessage* call, DBusMessage* reply) int r; DBusMessageIter in_iter; dbus_message_iter_init(call, &in_iter); - const char* pUUID; - r = load_val(&in_iter, pUUID); + const char* crash_id; + r = load_val(&in_iter, crash_id); if (r != ABRT_DBUS_LAST_FIELD) { error_msg("dbus call %s: parameter type mismatch", __func__ + 7); @@ -209,7 +199,7 @@ static int handle_CreateReport(DBusMessage* call, DBusMessage* reply) long unix_uid = get_remote_uid(call); map_crash_data_t report; - CreateReport(pUUID, to_string(unix_uid).c_str(), /*force:*/ 0, report); + CreateReport(crash_id, unix_uid, /*force:*/ 0, report); DBusMessageIter out_iter; dbus_message_iter_init_append(reply, &out_iter); @@ -300,7 +290,7 @@ static int handle_Report(DBusMessage* call, DBusMessage* reply) report_status_t argout1; try { - argout1 = Report(argin1, user_conf_data, to_string(unix_uid).c_str()); + argout1 = Report(argin1, user_conf_data, unix_uid); } catch (CABRTException &e) { @@ -325,8 +315,8 @@ static int handle_DeleteDebugDump(DBusMessage* call, DBusMessage* reply) int r; DBusMessageIter in_iter; dbus_message_iter_init(call, &in_iter); - const char* argin1; - r = load_val(&in_iter, argin1); + const char* crash_id; + r = load_val(&in_iter, crash_id); if (r != ABRT_DBUS_LAST_FIELD) { error_msg("dbus call %s: parameter type mismatch", __func__ + 7); @@ -334,7 +324,7 @@ static int handle_DeleteDebugDump(DBusMessage* call, DBusMessage* reply) } long unix_uid = get_remote_uid(call); - int32_t result = DeleteDebugDump(argin1, to_string(unix_uid).c_str()); + int32_t result = DeleteDebugDump(crash_id, unix_uid); DBusMessageIter out_iter; dbus_message_iter_init_append(reply, &out_iter); diff --git a/src/Daemon/CommLayerServerDBus.h b/src/Daemon/CommLayerServerDBus.h index 4fecf1be..91ec0919 100644 --- a/src/Daemon/CommLayerServerDBus.h +++ b/src/Daemon/CommLayerServerDBus.h @@ -30,11 +30,11 @@ class CCommLayerServerDBus /* DBus signal senders */ virtual void Crash(const char *progname, const char *uid_str); - virtual void JobDone(const char* pDest, const char* pUUID); + virtual void JobDone(const char* peer); virtual void QuotaExceed(const char* str); - virtual void Update(const char* pMessage, const char* peer, uint64_t pJobID); - virtual void Warning(const char* pMessage, const char* peer, uint64_t pJobID); + virtual void Update(const char* pMessage, const char* peer); + virtual void Warning(const char* pMessage, const char* peer); }; #endif diff --git a/src/Daemon/CrashWatcher.cpp b/src/Daemon/CrashWatcher.cpp index 4d68a811..b2215716 100644 --- a/src/Daemon/CrashWatcher.cpp +++ b/src/Daemon/CrashWatcher.cpp @@ -22,18 +22,18 @@ #include "DebugDump.h" #include "CrashWatcher.h" -void CCrashWatcher::Status(const char *pMessage, const char* peer, uint64_t pJobID) +void CCrashWatcher::Status(const char *pMessage, const char* peer) { VERB1 log("Update('%s'): %s", peer, pMessage); if (g_pCommLayer != NULL) - g_pCommLayer->Update(pMessage, peer, pJobID); + g_pCommLayer->Update(pMessage, peer); } -void CCrashWatcher::Warning(const char *pMessage, const char* peer, uint64_t pJobID) +void CCrashWatcher::Warning(const char *pMessage, const char* peer) { VERB1 log("Warning('%s'): %s", peer, pMessage); if (g_pCommLayer != NULL) - g_pCommLayer->Warning(pMessage, peer, pJobID); + g_pCommLayer->Warning(pMessage, peer); } CCrashWatcher::CCrashWatcher() @@ -44,32 +44,31 @@ CCrashWatcher::~CCrashWatcher() { } -vector_map_crash_data_t GetCrashInfos(const char *pUID) +vector_map_crash_data_t GetCrashInfos(long caller_uid) { vector_map_crash_data_t retval; log("Getting crash infos..."); try { - vector_pair_string_string_t UUIDsUIDs; - UUIDsUIDs = GetUUIDsOfCrash(pUID); + vector_string_t crash_ids; + GetUUIDsOfCrash(caller_uid, crash_ids); unsigned int ii; - for (ii = 0; ii < UUIDsUIDs.size(); ii++) + for (ii = 0; ii < crash_ids.size(); ii++) { - const char *uuid = UUIDsUIDs[ii].first.c_str(); - const char *uid = UUIDsUIDs[ii].second.c_str(); + const char *crash_id = crash_ids[ii].c_str(); map_crash_data_t info; - mw_result_t res = FillCrashInfo(uuid, uid, info); + mw_result_t res = FillCrashInfo(crash_id, info); switch (res) { case MW_OK: retval.push_back(info); break; case MW_ERROR: - error_msg("Dump directory for UUID %s doesn't exist or misses crucial files, deleting", uuid); + error_msg("Dump directory for crash_id %s doesn't exist or misses crucial files, deleting", crash_id); /* Deletes both DB record and dump dir */ - DeleteDebugDump(uuid, uid); + DeleteDebugDump(crash_id, /*caller_uid:*/ 0); break; default: break; @@ -81,8 +80,6 @@ vector_map_crash_data_t GetCrashInfos(const char *pUID) error_msg("%s", e.what()); } - //retval = GetCrashInfos(pUID); - //Notify("Sent crash info"); return retval; } @@ -94,37 +91,37 @@ vector_map_crash_data_t GetCrashInfos(const char *pUID) * StartJob dbus call already did all the processing, and we just retrieve * the result from dump directory, which is fast. */ -void CreateReport(const char* pUUID, const char* pUID, int force, map_crash_data_t& crashReport) +void CreateReport(const char* crash_id, long caller_uid, int force, map_crash_data_t& crashReport) { /* FIXME: starting from here, any shared data must be protected with a mutex. * For example, CreateCrashReport does: * g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); * which is unsafe wrt concurrent updates to g_pPluginManager state. */ - mw_result_t res = CreateCrashReport(pUUID, pUID, force, crashReport); + mw_result_t res = CreateCrashReport(crash_id, caller_uid, force, crashReport); switch (res) { case MW_OK: VERB2 log_map_crash_data(crashReport, "crashReport"); break; case MW_IN_DB_ERROR: - error_msg("Can't find crash with UUID %s in database", pUUID); + error_msg("Can't find crash with id %s in database", crash_id); break; case MW_PLUGIN_ERROR: error_msg("Particular analyzer plugin isn't loaded or there is an error within plugin(s)"); break; default: - error_msg("Corrupted crash with UUID %s, deleting", pUUID); - DeleteDebugDump(pUUID, pUID); + error_msg("Corrupted crash with id %s, deleting", crash_id); + DeleteDebugDump(crash_id, /*caller_uid:*/ 0); break; } } typedef struct thread_data_t { pthread_t thread_id; - char* UUID; - char* UID; + long caller_uid; int force; + char* crash_id; char* peer; } thread_data_t; static void* create_report(void* arg) @@ -138,8 +135,8 @@ static void* create_report(void* arg) { log("Creating report..."); map_crash_data_t crashReport; - CreateReport(thread_data->UUID, thread_data->UID, thread_data->force, crashReport); - g_pCommLayer->JobDone(thread_data->peer, thread_data->UUID); + CreateReport(thread_data->crash_id, thread_data->caller_uid, thread_data->force, crashReport); + g_pCommLayer->JobDone(thread_data->peer); } catch (CABRTException& e) { @@ -149,19 +146,18 @@ static void* create_report(void* arg) set_client_name(NULL); /* free strduped strings */ - free(thread_data->UUID); - free(thread_data->UID); + free(thread_data->crash_id); free(thread_data->peer); free(thread_data); /* Bogus value. pthreads require us to return void* */ return NULL; } -int CreateReportThread(const char* pUUID, const char* pUID, int force, const char* pSender) +int CreateReportThread(const char* crash_id, long caller_uid, int force, const char* pSender) { thread_data_t *thread_data = (thread_data_t *)xzalloc(sizeof(thread_data_t)); - thread_data->UUID = xstrdup(pUUID); - thread_data->UID = xstrdup(pUID); + thread_data->crash_id = xstrdup(crash_id); + thread_data->caller_uid = caller_uid; thread_data->force = force; thread_data->peer = xstrdup(pSender); @@ -172,8 +168,7 @@ int CreateReportThread(const char* pUUID, const char* pUID, int force, const cha pthread_attr_destroy(&attr); if (r != 0) { - free(thread_data->UUID); - free(thread_data->UID); + free(thread_data->crash_id); free(thread_data->peer); free(thread_data); /* The only reason this may happen is system-wide resource starvation, @@ -188,16 +183,27 @@ int CreateReportThread(const char* pUUID, const char* pUID, int force, const cha /* Remove dump dir and its DB record */ -int DeleteDebugDump(const char *pUUID, const char *pUID) +int DeleteDebugDump(const char *crash_id, long caller_uid) { try { CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); - database_row_t row = database->GetRow(pUUID, pUID); - database->DeleteRow(pUUID, pUID); + database_row_t row = database->GetRow(crash_id); + if (row.m_sUUID == "") + { + database->DisConnect(); + return ENOENT; + } + if (caller_uid != 0 /* not called by root */ + && row.m_sInformAll != "1" + && to_string(caller_uid) != row.m_sUID + ) { + database->DisConnect(); + return EPERM; + } + database->DeleteRow(crash_id); database->DisConnect(); - const char *dump_dir = row.m_sDebugDumpDir.c_str(); if (dump_dir[0] != '\0') { @@ -209,7 +215,7 @@ int DeleteDebugDump(const char *pUUID, const char *pUID) { error_msg("%s", e.what()); } - return -1; /* failure */ + return EIO; /* generic failure code */ } void DeleteDebugDump_by_dir(const char *dump_dir) diff --git a/src/Daemon/CrashWatcher.h b/src/Daemon/CrashWatcher.h index eaf24997..015bd70f 100644 --- a/src/Daemon/CrashWatcher.h +++ b/src/Daemon/CrashWatcher.h @@ -43,14 +43,14 @@ class CCrashWatcher public: /* Observer methods */ - virtual void Status(const char *pMessage, const char* peer, uint64_t pJobID); - virtual void Warning(const char *pMessage, const char* peer, uint64_t pJobID); + virtual void Status(const char *pMessage, const char* peer); + virtual void Warning(const char *pMessage, const char* peer); }; -vector_map_crash_data_t GetCrashInfos(const char *pUID); -int CreateReportThread(const char* pUUID, const char* pUID, int force, const char* pSender); -void CreateReport(const char* pUUID, const char* pUID, int force, map_crash_data_t&); -int DeleteDebugDump(const char *pUUID, const char *pUID); +vector_map_crash_data_t GetCrashInfos(long caller_uid); +int CreateReportThread(const char* crash_id, long caller_uid, int force, const char* pSender); +void CreateReport(const char* crash_id, long caller_uid, int force, map_crash_data_t&); +int DeleteDebugDump(const char *crash_id, long caller_uid); void DeleteDebugDump_by_dir(const char *dump_dir); #endif diff --git a/src/Daemon/Daemon.cpp b/src/Daemon/Daemon.cpp index 704d2c35..46bd9502 100644 --- a/src/Daemon/Daemon.cpp +++ b/src/Daemon/Daemon.cpp @@ -42,6 +42,8 @@ #include "DebugDump.h" #include "Daemon.h" +using namespace std; + /* Daemon initializes, then sits in glib main loop, waiting for events. * Events can be: @@ -53,16 +55,16 @@ * - GetCrashInfos(): returns a vector_map_crash_data_t (vector_map_vector_string_t) * of crashes for given uid * v[N]["executable"/"uid"/"kernel"/"backtrace"][N] = "contents" - * - StartJob(UUID,force): starts creating a report for /var/cache/abrt/DIR with this UUID. + * - StartJob(crash_id,force): starts creating a report for /var/cache/abrt/DIR with this UID:UUID. * Returns job id (uint64). * After thread returns, when report creation thread has finished, - * JobDone(client_dbus_ID,UUID) dbus signal is emitted. - * - CreateReport(UUID): returns map_crash_data_t (map_vector_string_t) + * JobDone() dbus signal is emitted. + * - CreateReport(crash_id): returns map_crash_data_t (map_vector_string_t) * - Report(map_crash_data_t (map_vector_string_t[, map_map_string_t])): * "Please report this crash": calls Report() of all registered reporter plugins. * Returns report_status_t (map_vector_string_t) - the status of each call. * 2nd parameter is the contents of user's abrt.conf. - * - DeleteDebugDump(UUID): delete it from DB and delete corresponding /var/cache/abrt/DIR + * - DeleteDebugDump(crash_id): delete it from DB and delete corresponding /var/cache/abrt/DIR * - GetPluginsInfo(): returns map_map_string_t * map["plugin"] = { "Name": "plugin", "Enabled": "yes" ... } * - GetPluginSettings(PluginName): returns map_plugin_settings_t (map_string_t) @@ -74,16 +76,12 @@ * * DBus signals we emit: * - Crash(progname,uid) - a new crash occurred (new /var/cache/abrt/DIR is found) - * - JobDone(client_dbus_ID,UUID) - see StartJob above. + * - JobDone(client_dbus_ID) - see StartJob above. * Sent as unicast to the client which did StartJob. - * - Warning(msg,job_id) - * - Update(msg,job_id) + * - Warning(msg) + * - Update(msg) * Both are sent as unicast to last client set by set_client_name(name). * If set_client_name(NULL) was done, they are not sent. - * - * TODO: - * - JobDone signal does not need to pass any parameters - * - our clients never send multiple StartJob's. */ @@ -514,7 +512,7 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin #define fullname fullname_should_not_be_used_here const char *analyzer = get_crash_data_item_content(crashinfo, FILENAME_ANALYZER).c_str(); - const char *uid_str = get_crash_data_item_content(crashinfo, FILENAME_UID).c_str(); + const char *uid_str = get_crash_data_item_content(crashinfo, CD_UID).c_str(); /* Autoreport it if configured to do so */ if (res != MW_REPORTED @@ -522,9 +520,12 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin ) { VERB1 log("Reporting the crash automatically"); map_crash_data_t crash_report; + string crash_id = ssprintf("%s:%s", uid_str, get_crash_data_item_content(crashinfo, CD_UUID).c_str()); mw_result_t crash_result = CreateCrashReport( - get_crash_data_item_content(crashinfo, CD_UUID).c_str(), - uid_str, /*force:*/ 0, crash_report + crash_id.c_str(), + /*caller_uid:*/ 0, + /*force:*/ 0, + crash_report ); if (crash_result == MW_OK) { diff --git a/src/Daemon/MiddleWare.cpp b/src/Daemon/MiddleWare.cpp index 16b86da0..1ed13e86 100644 --- a/src/Daemon/MiddleWare.cpp +++ b/src/Daemon/MiddleWare.cpp @@ -235,24 +235,34 @@ static void run_analyser_CreateReport(const char *pAnalyzer, /* else: GetAnalyzer() already complained, no need to handle it here */ } -mw_result_t CreateCrashReport(const char *pUUID, - const char *pUID, +/* + * Called in three cases: + * (1) by StartJob dbus call -> CreateReportThread(), in the thread + * (2) by CreateReport dbus call + * (3) by daemon if AutoReportUID is set for this user's crashes + */ +mw_result_t CreateCrashReport(const char *crash_id, + long caller_uid, int force, map_crash_data_t& pCrashData) { - VERB2 log("CreateCrashReport('%s','%s',result)", pUUID, pUID); + VERB2 log("CreateCrashReport('%s',%ld,result)", crash_id, caller_uid); database_row_t row; - if (pUUID[0] != '\0') + CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); + database->Connect(); + row = database->GetRow(crash_id); + database->DisConnect(); + if (row.m_sUUID == "") { - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); - database->Connect(); - row = database->GetRow(pUUID, pUID); - database->DisConnect(); + error_msg("crash '%s' is not in database", crash_id); + return MW_IN_DB_ERROR; } - if (pUUID[0] == '\0' || row.m_sUUID != pUUID) - { - error_msg("UUID '%s' is not in database", pUUID); + if (caller_uid != 0 /* not called by root */ + && row.m_sInformAll != "1" + && to_string(caller_uid) != row.m_sUID + ) { + error_msg("crash '%s' can't be accessed by user with uid %ld", crash_id, caller_uid); return MW_IN_DB_ERROR; } @@ -282,9 +292,8 @@ mw_result_t CreateCrashReport(const char *pUUID, RunAnalyzerActions(analyzer.c_str(), row.m_sDebugDumpDir.c_str(), force); DebugDumpToCrashReport(row.m_sDebugDumpDir.c_str(), pCrashData); - + add_to_crash_data_ext(pCrashData, CD_UUID , CD_SYS, CD_ISNOTEDITABLE, row.m_sUUID.c_str()); add_to_crash_data_ext(pCrashData, CD_DUPHASH, CD_TXT, CD_ISNOTEDITABLE, dup_hash.c_str()); - add_to_crash_data_ext(pCrashData, CD_UUID , CD_SYS, CD_ISNOTEDITABLE, pUUID); } catch (CABRTException& e) { @@ -366,20 +375,34 @@ void RunActionsAndReporters(const char *pDebugDumpDir) // dbus handler passes it from user without checking report_status_t Report(const map_crash_data_t& client_report, map_map_string_t& pSettings, - const char *pUID) + long caller_uid) { // Get ID fields - const char *UID = get_crash_data_item_content_or_NULL(client_report, FILENAME_UID); + const char *UID = get_crash_data_item_content_or_NULL(client_report, CD_UID); const char *UUID = get_crash_data_item_content_or_NULL(client_report, CD_UUID); - if (!UID || !UUID) { + if (!UID || !UUID) + { throw CABRTException(EXCEP_ERROR, "Report(): UID or UUID is missing in client's report data"); } + string crash_id = ssprintf("%s:%s", UID, UUID); // Retrieve corresponding stored record map_crash_data_t stored_report; - mw_result_t r = FillCrashInfo(UUID, UID, stored_report); + mw_result_t r = FillCrashInfo(crash_id.c_str(), stored_report); if (r != MW_OK) + { return report_status_t(); + } + + // Is it allowed for this user to report? + if (caller_uid != 0 // not called by root + && get_crash_data_item_content(stored_report, CD_INFORMALL) != "1" + && strcmp(to_string(caller_uid).c_str(), UID) != 0 + ) { + throw CABRTException(EXCEP_ERROR, "Report(): user with uid %ld can't report crash %s", + caller_uid, crash_id.c_str()); + } + const std::string& pDumpDir = get_crash_data_item_content(stored_report, CD_DUMPDIR); // Save comment, "how to reproduce", backtrace @@ -536,11 +559,11 @@ report_status_t Report(const map_crash_data_t& client_report, const vector_string_t &v = ret_it->second; if (v[REPORT_STATUS_IDX_FLAG] == "1") { - database->SetReportedPerReporter(UUID, UID, plugin_name.c_str(), v[REPORT_STATUS_IDX_MSG].c_str()); + database->SetReportedPerReporter(crash_id.c_str(), plugin_name.c_str(), v[REPORT_STATUS_IDX_MSG].c_str()); } ret_it++; } - database->SetReported(UUID, UID, message.c_str()); + database->SetReported(crash_id.c_str(), message.c_str()); database->DisConnect(); } @@ -556,14 +579,14 @@ report_status_t Report(const map_crash_data_t& client_report, * @return It returns true if debugdump dir is already saved, otherwise * it returns false. */ -static bool IsDebugDumpSaved(const char *pUID, +static bool IsDebugDumpSaved(long uid, const char *pDebugDumpDir) { /* TODO: use database query instead of dumping all rows and searching in them */ CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); - vector_database_rows_t rows = database->GetUIDData(pUID); + vector_database_rows_t rows = database->GetUIDData(uid); database->DisConnect(); int ii; @@ -838,8 +861,8 @@ static void RunAnalyzerActions(const char *pAnalyzer, const char *pDebugDumpDir, * @param pCrashData A filled crash info. * @return It return results of operation. See mw_result_t. */ -static mw_result_t SaveDebugDumpToDatabase(const char *pUUID, - const char *pUID, +static mw_result_t SaveDebugDumpToDatabase(const char *crash_id, + bool inform_all_users, const char *pTime, const char *pDebugDumpDir, map_crash_data_t& pCrashData) @@ -847,11 +870,11 @@ static mw_result_t SaveDebugDumpToDatabase(const char *pUUID, CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); /* note: if [UUID,UID] record exists, pDebugDumpDir is not updated in the record */ - database->Insert_or_Update(pUUID, pUID, pDebugDumpDir, pTime); - database_row_t row = database->GetRow(pUUID, pUID); + database->Insert_or_Update(crash_id, inform_all_users, pDebugDumpDir, pTime); + database_row_t row = database->GetRow(crash_id); database->DisConnect(); - mw_result_t res = FillCrashInfo(pUUID, pUID, pCrashData); + mw_result_t res = FillCrashInfo(crash_id, pCrashData); if (res == MW_OK) { const char *first = get_crash_data_item_content(pCrashData, CD_DUMPDIR).c_str(); @@ -869,15 +892,6 @@ static mw_result_t SaveDebugDumpToDatabase(const char *pUUID, return res; } -std::string getDebugDumpDir(const char *pUUID, const char *pUID) -{ - CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); - database->Connect(); - database_row_t row = database->GetRow(pUUID, pUID); - database->DisConnect(); - return row.m_sDebugDumpDir; -} - mw_result_t SaveDebugDump(const char *pDebugDumpDir, map_crash_data_t& pCrashData) { @@ -891,7 +905,7 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, CDebugDump dd; dd.Open(pDebugDumpDir); dd.LoadText(FILENAME_TIME, time); - dd.LoadText(FILENAME_UID, UID); + dd.LoadText(CD_UID, UID); dd.LoadText(FILENAME_ANALYZER, analyzer); dd.LoadText(FILENAME_EXECUTABLE, executable); dd.LoadText(FILENAME_CMDLINE, cmdline); @@ -902,7 +916,7 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, return MW_ERROR; } - if (IsDebugDumpSaved(UID.c_str(), pDebugDumpDir)) + if (IsDebugDumpSaved(xatou(UID.c_str()), pDebugDumpDir)) { return MW_IN_DB; } @@ -913,10 +927,8 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, return res; } - std::string lUUID = GetLocalUUID(analyzer.c_str(), pDebugDumpDir); - const char *uid_str = analyzer_has_InformAllUsers(analyzer.c_str()) - ? "-1" - : UID.c_str(); + std::string UUID = GetLocalUUID(analyzer.c_str(), pDebugDumpDir); + std::string crash_id = ssprintf("%s:%s", UID.c_str(), UUID.c_str()); /* Loads pCrashData (from the *first debugdump dir* if this one is a dup) * Returns: * MW_REPORTED: "the crash is flagged as reported in DB" (which also means it's a dup) @@ -924,16 +936,19 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, * MW_OK: "crash count is 1" (iow: this is a new crash, not a dup) * else: an error code */ - return SaveDebugDumpToDatabase(lUUID.c_str(), uid_str, time.c_str(), pDebugDumpDir, pCrashData); + return SaveDebugDumpToDatabase(crash_id.c_str(), + analyzer_has_InformAllUsers(analyzer.c_str()), + time.c_str(), + pDebugDumpDir, + pCrashData); } -mw_result_t FillCrashInfo(const char *pUUID, - const char *pUID, +mw_result_t FillCrashInfo(const char *crash_id, map_crash_data_t& pCrashData) { CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); database->Connect(); - database_row_t row = database->GetRow(pUUID, pUID); + database_row_t row = database->GetRow(crash_id); database->DisConnect(); std::string package; @@ -952,34 +967,32 @@ mw_result_t FillCrashInfo(const char *pUUID, return MW_ERROR; } + add_to_crash_data(pCrashData, CD_UID , row.m_sUID.c_str() ); add_to_crash_data(pCrashData, CD_UUID , row.m_sUUID.c_str() ); + add_to_crash_data(pCrashData, CD_INFORMALL , row.m_sInformAll.c_str() ); add_to_crash_data(pCrashData, CD_COUNT , row.m_sCount.c_str() ); add_to_crash_data(pCrashData, CD_REPORTED , row.m_sReported.c_str() ); add_to_crash_data(pCrashData, CD_MESSAGE , row.m_sMessage.c_str() ); add_to_crash_data(pCrashData, CD_DUMPDIR , row.m_sDebugDumpDir.c_str()); -//TODO: why do we keep uid and time in DB and in dumpdir?! - add_to_crash_data(pCrashData, FILENAME_UID , row.m_sUID.c_str() ); add_to_crash_data(pCrashData, FILENAME_TIME , row.m_sTime.c_str() ); return MW_OK; } -vector_pair_string_string_t GetUUIDsOfCrash(const char *pUID) +void GetUUIDsOfCrash(long caller_uid, vector_string_t &result) { CDatabase* database = g_pPluginManager->GetDatabase(g_settings_sDatabase.c_str()); vector_database_rows_t rows; database->Connect(); - rows = database->GetUIDData(pUID); + rows = database->GetUIDData(caller_uid); database->DisConnect(); - vector_pair_string_string_t UUIDsUIDs; unsigned ii; for (ii = 0; ii < rows.size(); ii++) { - UUIDsUIDs.push_back(make_pair(rows[ii].m_sUUID, rows[ii].m_sUID)); + string crash_id = ssprintf("%s:%s", rows[ii].m_sUID.c_str(), rows[ii].m_sUUID.c_str()); + result.push_back(crash_id); } - - return UUIDsUIDs; } void AddAnalyzerActionOrReporter(const char *pAnalyzer, diff --git a/src/Daemon/MiddleWare.h b/src/Daemon/MiddleWare.h index 94f9fb99..275d5312 100644 --- a/src/Daemon/MiddleWare.h +++ b/src/Daemon/MiddleWare.h @@ -29,8 +29,8 @@ * An enum contains all return codes. */ typedef enum { - MW_ERROR, /**< Common error.*/ MW_OK, /**< No error.*/ + MW_ERROR, /**< Common error.*/ MW_BLACKLISTED, /**< Package is blacklisted.*/ MW_CORRUPTED, /**< Debugdump directory is corrupted.*/ MW_PACKAGE_ERROR, /**< Cannot determine package name.*/ @@ -62,8 +62,8 @@ void LoadOpenGPGPublicKey(const char* key); * @param pCrashData A filled crash report. * @return It return results of operation. See mw_result_t. */ -mw_result_t CreateCrashReport(const char *pUUID, - const char *pUID, +mw_result_t CreateCrashReport(const char *crash_id, + long caller_uid, int force, map_crash_data_t& pCrashData); /** @@ -93,16 +93,7 @@ void RunActionsAndReporters(const char *pDebugDumpDir); */ report_status_t Report(const map_crash_data_t& pCrashData, map_map_string_t& pSettings, - const char *pUID); -/** - * Get debugdump direcotory. If debugdump is not found - * in database it will return empty string. - * @param pUUID A local UUID of a crash. - * @param pUID An UID of an user. - * @return A debugdump directory. - */ -std::string getDebugDumpDir( const char *pUUID, - const char *pUID); + long caller_uid); /** * Adds package name and description to debugdump dir. * Saves debugdump into database. @@ -123,8 +114,7 @@ mw_result_t SaveDebugDump(const char *pDebugDumpDir, * @param pCrashData A crash info. * @return It return results of operation. See mw_result_t. */ -mw_result_t FillCrashInfo(const char *pUUID, - const char *pUID, +mw_result_t FillCrashInfo(const char *crash_id, map_crash_data_t& pCrashData); /** * Gets all local UUIDs and UIDs of crashes. These crashes @@ -132,7 +122,7 @@ mw_result_t FillCrashInfo(const char *pUUID, * @param pUID an UID of an user. * @return A vector of pairs (local UUID, UID). */ -vector_pair_string_string_t GetUUIDsOfCrash(const char *pUID); +void GetUUIDsOfCrash(long caller_uid, vector_string_t &result); /** * Adds one association among alanyzer plugin and its * action and reporter plugins. diff --git a/src/Gui/CCDBusBackend.py b/src/Gui/CCDBusBackend.py index 7aa179bc..6c2bb2e4 100644 --- a/src/Gui/CCDBusBackend.py +++ b/src/Gui/CCDBusBackend.py @@ -149,11 +149,11 @@ class DBusManager(gobject.GObject): #print "crash" self.emit("crash") - def update_cb(self, message, job_id=0): + def update_cb(self, message): log1("Update:%s", message) self.emit("update", message) - def warning_cb(self, message, job_id=0): + def warning_cb(self, message): log1("Warning:%s", message) self.emit("warning", message) @@ -164,22 +164,21 @@ class DBusManager(gobject.GObject): else: self.emit("daemon-state-changed", "down") - def jobdone_cb(self, dest, uuid): - # TODO: check that it is indeed OUR job: - # remember uuid in getReport and compare here - log1("Our job for UUID %s is done", uuid) - dump = self.daemon().CreateReport(uuid) + def jobdone_cb(self): + log1("Our job for crash_id %s is done", self.job_crash_id) + dump = self.daemon().CreateReport(self.job_crash_id) if dump: self.emit("analyze-complete", dump) else: - self.emit("abrt-error",_("Daemon didn't return valid report info\nDebuginfo is missing?")) + self.emit("abrt-error", _("Daemon didn't return valid report info\nDebuginfo is missing?")) def report_done(self, result): self.emit("report-done", result) - def getReport(self, UUID, force=0): + def start_job(self, crash_id, force=0): # 2nd param is "force recreating of backtrace etc" - self.daemon().StartJob(UUID, force, timeout=60) + self.daemon().StartJob(crash_id, force, timeout=60) + self.job_crash_id = crash_id def Report(self, report, reporters, reporters_settings = None): # map < Plguin_name vec <status, message> > @@ -188,8 +187,8 @@ class DBusManager(gobject.GObject): else: self.daemon().Report(report, reporters, reply_handler=self.report_done, error_handler=self.error_handler_cb, timeout=60) - def DeleteDebugDump(self,UUID): - return self.daemon().DeleteDebugDump(UUID) + def DeleteDebugDump(self, crash_id): + return self.daemon().DeleteDebugDump(crash_id) def getDumps(self): row_dict = None diff --git a/src/Gui/CCDump.py b/src/Gui/CCDump.py index 3d6e8704..ad7e4d51 100644 --- a/src/Gui/CCDump.py +++ b/src/Gui/CCDump.py @@ -15,7 +15,6 @@ CD_TXT = "t" FILENAME_ARCHITECTURE = "architecture" FILENAME_KERNEL = "kernel" FILENAME_TIME = "time" -FILENAME_UID = "uid" FILENAME_PACKAGE = "package" FILENAME_COMPONENT = "component" FILENAME_DESCRIPTION = "description" @@ -32,8 +31,10 @@ FILENAME_BACKTRACE = "backtrace" FILENAME_MEMORYMAP = "memorymap" FILENAME_KERNELOOPS = "kerneloops" -CD_DUPHASH = "DUPHASH" +CD_UID = "uid" CD_UUID = "UUID" +CD_INFORMALL = "InformAll" +CD_DUPHASH = "DUPHASH" CD_DUMPDIR = "DumpDir" CD_COUNT = "Count" CD_REPORTED = "Reported" diff --git a/src/Gui/CCMainWindow.py b/src/Gui/CCMainWindow.py index 74291fb2..4d7dff46 100644 --- a/src/Gui/CCMainWindow.py +++ b/src/Gui/CCMainWindow.py @@ -190,7 +190,7 @@ class MainWindow(): except: icon = None user = "N/A" - if entry.getUID() != "-1": + if entry.getUID() != "-1": # compat: only abrt <= 1.0.9 used UID = -1 try: user = pwd.getpwuid(int(entry.getUID()))[0] except Exception, ex: @@ -244,7 +244,7 @@ class MainWindow(): # this should work until we keep the row object in the last position dump = dumpsListStore.get_value(dumpsListStore.get_iter(path[0]), dumpsListStore.get_n_columns()-1) try: - self.ccdaemon.DeleteDebugDump(dump.getUUID()) + self.ccdaemon.DeleteDebugDump("%s:%s" % (dump.getUID(), dump.getUUID())) self.hydrate() treeview.emit("cursor-changed") except Exception, ex: diff --git a/src/Gui/CCReporterDialog.py b/src/Gui/CCReporterDialog.py index 7cbe2197..94b9495c 100644 --- a/src/Gui/CCReporterDialog.py +++ b/src/Gui/CCReporterDialog.py @@ -514,7 +514,7 @@ class ReporterSelector(): # show the report window with selected report try: - self.daemon.getReport(report[CD_UUID][CD_CONTENT], force=1) + self.daemon.start_job("%s:%s" % (report[CD_UID][CD_CONTENT], report[CD_UUID][CD_CONTENT]), force=1) except Exception, ex: # FIXME #3 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply # do this async and wait for yum to end with debuginfoinstal @@ -535,7 +535,7 @@ class ReporterSelector(): # when getReport is done it emits "analyze-complete" and on_analyze_complete_cb is called # FIXME: does it make sense to change it to use callback rather then signal emitting? try: - self.daemon.getReport(self.dump.getUUID()) + self.daemon.start_job("%s:%s" % (self.dump.getUID(), self.dump.getUUID())) except Exception, ex: # FIXME #3 dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply # do this async and wait for yum to end with debuginfoinstal diff --git a/src/Hooks/abrt-hook-python.cpp b/src/Hooks/abrt-hook-python.cpp index 34459540..972f1176 100644 --- a/src/Hooks/abrt-hook-python.cpp +++ b/src/Hooks/abrt-hook-python.cpp @@ -140,7 +140,7 @@ int main(int argc, char** argv) free(cmdline); char uid[sizeof(long) * 3 + 2]; sprintf(uid, "%lu", (long)getuid()); - dd.SaveText(FILENAME_UID, uid); + dd.SaveText(CD_UID, uid); dd.Close(); |