From 990ddca5415d196bf7543a57a86aa47da13706c6 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Wed, 13 Sep 2017 16:32:58 +0200 Subject: cdv: Warn about unsafe crashdump Warn the user if the node executing the crashdump viewer potentially could overwrite the crashdump under inspection. --- lib/observer/src/cdv_wx.erl | 35 +++++++++++++++++++++++++++++++++++ lib/observer/src/crashdump_viewer.erl | 3 ++- 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'lib/observer') diff --git a/lib/observer/src/cdv_wx.erl b/lib/observer/src/cdv_wx.erl index ffd7694ab3..c3f36cd689 100644 --- a/lib/observer/src/cdv_wx.erl +++ b/lib/observer/src/cdv_wx.erl @@ -412,6 +412,14 @@ load_dump(Frame,undefined) -> error end; load_dump(Frame,FileName) -> + case maybe_warn_filename(FileName) of + continue -> + do_load_dump(Frame,FileName); + stop -> + error + end. + +do_load_dump(Frame,FileName) -> ok = observer_lib:display_progress_dialog(wx:null(), "Crashdump Viewer", "Loading crashdump"), @@ -432,6 +440,33 @@ load_dump(Frame,FileName) -> error end. +maybe_warn_filename(FileName) -> + case os:getenv("ERL_CRASH_DUMP_SECONDS")=="0" orelse + os:getenv("ERL_CRASH_DUMP_BYTES")=="0" of + true -> + continue; + false -> + DumpName = case os:getenv("ERL_CRASH_DUMP") of + false -> filename:absname("erl_crash.dump"); + Name -> filename:absname(Name) + end, + case filename:absname(FileName) of + DumpName -> + Warning = + "WARNING: the current crashdump might be overwritten " + "if the crashdump_viewer node crashes.\n\n" + "Renaming the file before inspecting it will " + "remove the problem.\n\n" + "Do you want to continue?", + case observer_lib:display_yes_no_dialog(Warning) of + ?wxID_YES -> continue; + ?wxID_NO -> stop + end; + _ -> + continue + end + end. + %%%----------------------------------------------------------------- %%% Find help document (HTML files) get_help_doc(HelpId) -> diff --git a/lib/observer/src/crashdump_viewer.erl b/lib/observer/src/crashdump_viewer.erl index b01c3a1bac..95e12887cd 100644 --- a/lib/observer/src/crashdump_viewer.erl +++ b/lib/observer/src/crashdump_viewer.erl @@ -205,7 +205,8 @@ do_script_start(StartFun) -> io:format("\ncdv crash: ~tp\n",[Reason]) end; _ -> - io:format("\ncdv crash: ~p\n",[unknown_reason]) + %io:format("\ncdv crash: ~p\n",[unknown_reason]) + ok end; Error -> io:format("\ncdv start failed: ~tp\n",[Error]) -- cgit v1.2.3