From 56ea4f65a792a6d4ebaeab34d6a0c1d9c8d13082 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 25 Mar 2011 16:02:21 +0100 Subject: remove FILENAME_INFORMALL and tighten up some loose ends Signed-off-by: Denys Vlasenko --- src/applet/applet.c | 21 +++------- src/daemon/CommLayerServerDBus.cpp | 7 +--- src/daemon/CommLayerServerDBus.h | 1 - src/daemon/Daemon.cpp | 10 ----- src/daemon/MiddleWare.cpp | 74 +++++++++++++++--------------------- src/daemon/abrt_event.conf | 14 ++++--- src/include/abrt_crash_data.h | 1 - src/lib/make_descr.c | 1 - src/plugins/abrt-action-rhtsupport.c | 1 - src/plugins/abrt-action-upload.c | 1 - 10 files changed, 47 insertions(+), 84 deletions(-) (limited to 'src') diff --git a/src/applet/applet.c b/src/applet/applet.c index 56266f12..a49725b7 100644 --- a/src/applet/applet.c +++ b/src/applet/applet.c @@ -40,16 +40,7 @@ static void Crash(DBusMessage* signal) const char* package_name = NULL; r = load_charp(&in_iter, &package_name); - /* 2nd param: crash_id */ - if (r != ABRT_DBUS_MORE_FIELDS) - { - error_msg("dbus signal %s: parameter type mismatch", __func__); - return; - } - const char* crash_dir = NULL; - r = load_charp(&in_iter, &crash_dir); - - /* 3rd param: dir */ + /* 2nd param: dir */ //dir parameter is not used for now, use is planned in the future if (r != ABRT_DBUS_MORE_FIELDS) { @@ -59,7 +50,7 @@ static void Crash(DBusMessage* signal) const char* dir = NULL; r = load_charp(&in_iter, &dir); - /* Optional 4th param: uid */ + /* Optional 3rd param: uid */ const char* uid_str = NULL; if (r == ABRT_DBUS_MORE_FIELDS) { @@ -94,10 +85,10 @@ static void Crash(DBusMessage* signal) */ static time_t last_time = 0; static char* last_package_name = NULL; - static char* last_crash_dir = NULL; + static char* last_dir = NULL; time_t cur_time = time(NULL); if (last_package_name && strcmp(last_package_name, package_name) == 0 - && last_crash_dir && strcmp(last_crash_dir, crash_dir) == 0 + && last_dir && strcmp(last_dir, dir) == 0 && (unsigned)(cur_time - last_time) < 2 * 60 * 60 ) { log_msg("repeated crash in %s, not showing the notification", package_name); @@ -106,8 +97,8 @@ static void Crash(DBusMessage* signal) last_time = cur_time; free(last_package_name); last_package_name = xstrdup(package_name); - free(last_crash_dir); - last_crash_dir = xstrdup(dir); + free(last_dir); + last_dir = xstrdup(dir); show_crash_notification(applet, dir, message, package_name); } diff --git a/src/daemon/CommLayerServerDBus.cpp b/src/daemon/CommLayerServerDBus.cpp index 386b5872..0f661f23 100644 --- a/src/daemon/CommLayerServerDBus.cpp +++ b/src/daemon/CommLayerServerDBus.cpp @@ -59,7 +59,6 @@ static void send_flush_and_unref(DBusMessage* msg) /* Notify the clients (UI) about a new crash */ void send_dbus_sig_Crash(const char *package_name, - const char *crash_id, const char *dir, const char *uid_str ) { @@ -68,20 +67,18 @@ void send_dbus_sig_Crash(const char *package_name, { dbus_message_append_args(msg, DBUS_TYPE_STRING, &package_name, - DBUS_TYPE_STRING, &crash_id, DBUS_TYPE_STRING, &dir, DBUS_TYPE_STRING, &uid_str, DBUS_TYPE_INVALID); - VERB2 log("Sending signal Crash('%s','%s','%s','%s')", package_name, crash_id, dir, uid_str); + VERB2 log("Sending signal Crash('%s','%s','%s')", package_name, dir, uid_str); } else { dbus_message_append_args(msg, DBUS_TYPE_STRING, &package_name, - DBUS_TYPE_STRING, &crash_id, DBUS_TYPE_STRING, &dir, DBUS_TYPE_INVALID); - VERB2 log("Sending signal Crash('%s','%s','%s')", package_name, crash_id, dir); + VERB2 log("Sending signal Crash('%s','%s')", package_name, dir); } send_flush_and_unref(msg); } diff --git a/src/daemon/CommLayerServerDBus.h b/src/daemon/CommLayerServerDBus.h index 979fef69..eab7d710 100644 --- a/src/daemon/CommLayerServerDBus.h +++ b/src/daemon/CommLayerServerDBus.h @@ -27,7 +27,6 @@ int init_dbus(void); void deinit_dbus(void); void send_dbus_sig_Crash(const char *package_name, - const char *crash_id, const char *dir, const char *uid_str ); diff --git a/src/daemon/Daemon.cpp b/src/daemon/Daemon.cpp index 5dd273e7..7bb772c8 100644 --- a/src/daemon/Daemon.cpp +++ b/src/daemon/Daemon.cpp @@ -400,23 +400,13 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin } const char *uid_str = get_crash_item_content_or_NULL(crash_data, FILENAME_UID); - const char *inform_all = get_crash_item_content_or_NULL(crash_data, FILENAME_INFORMALL); - - if (inform_all && string_to_bool(inform_all)) - uid_str = NULL; - char *crash_id = xasprintf("%s:%s", - get_crash_item_content_or_NULL(crash_data, FILENAME_UID), - get_crash_item_content_or_NULL(crash_data, FILENAME_UUID) - ); /* When dup occurs we need to return first occurence, * not the one which is deleted */ send_dbus_sig_Crash(get_crash_item_content_or_NULL(crash_data, FILENAME_PACKAGE), - crash_id, //TODO: stop passing this param, it is unused (first)? first: fullname, uid_str ); - free(crash_id); break; } case MW_CORRUPTED: diff --git a/src/daemon/MiddleWare.cpp b/src/daemon/MiddleWare.cpp index 9bbd2af3..ffc2d633 100644 --- a/src/daemon/MiddleWare.cpp +++ b/src/daemon/MiddleWare.cpp @@ -134,19 +134,15 @@ static mw_result_t CreateCrashReport(const char *dump_dir_name, char caller_uid_str[sizeof(long) * 3 + 2]; sprintf(caller_uid_str, "%ld", caller_uid); - char *uid = dd_load_text(dd, FILENAME_UID); - if (strcmp(uid, caller_uid_str) != 0) + char *uid = dd_load_text_ext(dd, FILENAME_UID, DD_FAIL_QUIETLY_ENOENT | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE); + bool uid_matches = (uid == NULL || strcmp(uid, caller_uid_str) == 0); + free(uid); + if (!uid_matches) { - char *inform_all = dd_load_text_ext(dd, FILENAME_INFORMALL, DD_FAIL_QUIETLY_ENOENT); - bool for_all = string_to_bool(inform_all); - free(inform_all); - if (!for_all) - { - dd_close(dd); - error_msg("crash '%s' can't be accessed by user with uid %ld", dump_dir_name, caller_uid); - r = MW_PERM_ERROR; - goto ret; - } + dd_close(dd); + error_msg("Dump directory '%s' can't be accessed by user with uid %ld", dump_dir_name, caller_uid); + r = MW_PERM_ERROR; + goto ret; } } dd_close(dd); @@ -222,19 +218,16 @@ report_status_t Report(crash_data_t *client_report, { char caller_uid_str[sizeof(long)*3 + 2]; sprintf(caller_uid_str, "%ld", caller_uid); - if (strcmp(caller_uid_str, get_crash_item_content_or_die(stored_report, FILENAME_UID)) != 0) + const char *uid = get_crash_item_content_or_NULL(stored_report, FILENAME_UID); + if (uid && strcmp(caller_uid_str, uid) != 0) { - const char *inform_all = get_crash_item_content_or_NULL(stored_report, FILENAME_INFORMALL); - if (!inform_all || !string_to_bool(inform_all)) - { - free_crash_data(stored_report); - char *errmsg = xasprintf("user with uid %ld can't report crash %s", caller_uid, dump_dir_name); - update_client("Reporting error: %s", errmsg); - ret[""].push_back("0"); // REPORT_STATUS_IDX_FLAG - ret[""].push_back(errmsg); // REPORT_STATUS_IDX_MSG - free(errmsg); - return ret; - } + free_crash_data(stored_report); + char *errmsg = xasprintf("user with uid %ld can't report crash %s", caller_uid, dump_dir_name); + update_client("Reporting error: %s", errmsg); + ret[""].push_back("0"); // REPORT_STATUS_IDX_FLAG + ret[""].push_back(errmsg); // REPORT_STATUS_IDX_MSG + free(errmsg); + return ret; } } @@ -621,18 +614,13 @@ vector_of_crash_data_t *GetCrashInfos(long caller_uid) sprintf(caller_uid_str, "%ld", caller_uid); uid = dd_load_text(dd, FILENAME_UID); - if (strcmp(uid, caller_uid_str) != 0) + bool uid_matches = (uid == NULL || strcmp(uid, caller_uid_str) == 0); + free(uid); + dd_close(dd); + if (!uid_matches) { - char *inform_all = dd_load_text_ext(dd, FILENAME_INFORMALL, DD_FAIL_QUIETLY_ENOENT); - bool for_all = string_to_bool(inform_all); - free(inform_all); - if (!for_all) - { - dd_close(dd); - goto next; - } + goto next; } - dd_close(dd); } { @@ -768,21 +756,19 @@ int DeleteDebugDump(const char *dump_dir_name, long caller_uid) char caller_uid_str[sizeof(long) * 3 + 2]; sprintf(caller_uid_str, "%ld", caller_uid); - char *uid = dd_load_text_ext(dd, FILENAME_UID, DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE); + char *uid = dd_load_text_ext(dd, FILENAME_UID, DD_FAIL_QUIETLY_ENOENT | DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE); /* we assume that the dump_dir can be handled by everyone if uid == NULL * e.g: kerneloops - */ + */ if (uid != NULL) { - if (strcmp(uid, caller_uid_str) != 0) + bool uid_matches = (strcmp(uid, caller_uid_str) == 0); + free(uid); + if (!uid_matches) { - char *inform_all = dd_load_text_ext(dd, FILENAME_INFORMALL, DD_FAIL_QUIETLY_ENOENT); - if (!string_to_bool(inform_all)) - { - dd_close(dd); - error_msg("Dump directory '%s' can't be accessed by user with uid %ld", dump_dir_name, caller_uid); - return 1; - } + dd_close(dd); + error_msg("Dump directory '%s' can't be accessed by user with uid %ld", dump_dir_name, caller_uid); + return 1; } } } diff --git a/src/daemon/abrt_event.conf b/src/daemon/abrt_event.conf index d127d38d..129e532a 100644 --- a/src/daemon/abrt_event.conf +++ b/src/daemon/abrt_event.conf @@ -45,14 +45,16 @@ EVENT=post-create abrt-action-save-package-data include events.d/*.conf -# uid file doesn't exist for some problems like kerneloops -EVENT=post-create if [ -e uid ]; then getent passwd "`cat uid`" | cut -d: -f1 >username; fi +# Example: if you want all users (not just root) to be able to see some problems: +#EVENT=post-create rm uid; chmod a+rX . + +# uid file is missing for problems visible to all users +# (oops scanner is often set up to not create it). +# In this case, do not record username too: +EVENT=post-create if [ -f uid ]; then getent passwd "`cat uid`" | cut -d: -f1 >username; fi EVENT=post-create analyzer=Python abrt-action-analyze-python EVENT=post-create analyzer=Kerneloops abrt-action-analyze-oops -# If you want all users (not just root) to be able to see oopses: -#EVENT=post-create analyzer=Kerneloops echo 1 >inform_all_users - # If you want behavior similar to one provided by kerneloops daemon # distributed by kerneloops.org - that is, if you want # oopses to be reported automatically and immediately without @@ -60,6 +62,8 @@ EVENT=post-create analyzer=Kerneloops abrt-action-analyze-oops #EVENT=post-create analyzer=Kerneloops abrt-action-kerneloops # Example: if you want to save sosreport immediately at the moment of a crash: +# (alternatively, you can add similar command to EVENT=analyze_foo's, +# if you would rather perform this collection later): #EVENT=post-create nice sosreport --tmp-dir "$DUMP_DIR" --batch \ --only=anaconda --only=bootloader --only=devicemapper \ diff --git a/src/include/abrt_crash_data.h b/src/include/abrt_crash_data.h index 93fcb1fb..52ae50ca 100644 --- a/src/include/abrt_crash_data.h +++ b/src/include/abrt_crash_data.h @@ -59,7 +59,6 @@ // TODO: TicketUploader also has open-coded "TICKET", "CUSTOMER" files #define FILENAME_UUID "uuid" -#define FILENAME_INFORMALL "inform_all_users" #define FILENAME_COUNT "count" /* Multi-line list of places problem was reported. * Recommended line format: diff --git a/src/lib/make_descr.c b/src/lib/make_descr.c index bd215181..c5b4bd6c 100644 --- a/src/lib/make_descr.c +++ b/src/lib/make_descr.c @@ -63,7 +63,6 @@ static const char *const blacklisted_items[] = { FILENAME_HOSTNAME , FILENAME_DUPHASH , FILENAME_UUID , - FILENAME_INFORMALL, CD_DUMPDIR , FILENAME_COUNT , NULL diff --git a/src/plugins/abrt-action-rhtsupport.c b/src/plugins/abrt-action-rhtsupport.c index 03274268..6bbf76a0 100644 --- a/src/plugins/abrt-action-rhtsupport.c +++ b/src/plugins/abrt-action-rhtsupport.c @@ -127,7 +127,6 @@ static void report_to_rhtsupport( { if (strcmp(name, FILENAME_COUNT) == 0) continue; if (strcmp(name, CD_DUMPDIR) == 0) continue; - if (strcmp(name, FILENAME_INFORMALL) == 0) continue; const char *content = value->content; if (value->flags & CD_FLAG_TXT) diff --git a/src/plugins/abrt-action-upload.c b/src/plugins/abrt-action-upload.c index beb09beb..79347a18 100644 --- a/src/plugins/abrt-action-upload.c +++ b/src/plugins/abrt-action-upload.c @@ -159,7 +159,6 @@ static int create_and_upload_archive( { if (strcmp(short_name, FILENAME_COUNT) == 0) goto next; if (strcmp(short_name, CD_DUMPDIR) == 0) goto next; - if (strcmp(short_name, FILENAME_INFORMALL) == 0) goto next; // dd_get_next_file guarantees this: //struct stat stbuf; //if (stat(full_name, &stbuf) != 0) -- cgit