mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-09-29 11:15:39 +00:00
Unix: avoid false unmount success reports on retries
Skip success reporting after a failed first-pass unmount is queued for retry. Cover successful, failed, and unconfirmed retries.
This commit is contained in:
@@ -137,6 +137,7 @@ static struct { std::wstring operator[] (const char *key) const { return StringC
|
|||||||
enum Outcome { Unmounted, Busy, Unconfirmed, Failed };
|
enum Outcome { Unmounted, Busy, Unconfirmed, Failed };
|
||||||
static std::map <std::wstring, std::deque <Outcome> > Plan;
|
static std::map <std::wstring, std::deque <Outcome> > Plan;
|
||||||
static bool ForceAnswer;
|
static bool ForceAnswer;
|
||||||
|
static std::wstring Info;
|
||||||
class UserInterface {
|
class UserInterface {
|
||||||
public:
|
public:
|
||||||
struct BusyScope { BusyScope (const UserInterface *) {} };
|
struct BusyScope { BusyScope (const UserInterface *) {} };
|
||||||
@@ -152,7 +153,7 @@ public:
|
|||||||
}
|
}
|
||||||
bool AskYesNo (const std::wstring &, bool, bool) const { return ForceAnswer; }
|
bool AskYesNo (const std::wstring &, bool, bool) const { return ForceAnswer; }
|
||||||
void ShowWarning (const std::wstring &) const {}
|
void ShowWarning (const std::wstring &) const {}
|
||||||
void ShowInfo (const std::wstring &) const {}
|
void ShowInfo (const std::wstring &text) const { Info = text; }
|
||||||
static wxString ExceptionToMessage (const exception &e) { return StringConverter::ToExceptionString (e); }
|
static wxString ExceptionToMessage (const exception &e) { return StringConverter::ToExceptionString (e); }
|
||||||
struct { bool Verbose; } Preferences = { false };
|
struct { bool Verbose; } Preferences = { false };
|
||||||
};
|
};
|
||||||
@@ -173,6 +174,7 @@ static VolumeInfoList Volumes () {
|
|||||||
// Returns the details reported for unconfirmed cleanups, or the name of the other outcome.
|
// Returns the details reported for unconfirmed cleanups, or the name of the other outcome.
|
||||||
static std::wstring Run (std::deque <Outcome> a, std::deque <Outcome> b, bool interactive, bool force = false) {
|
static std::wstring Run (std::deque <Outcome> a, std::deque <Outcome> b, bool interactive, bool force = false) {
|
||||||
UserInterface ui; Plan.clear(); Plan[L"A"] = a; Plan[L"B"] = b; ForceAnswer = force;
|
UserInterface ui; Plan.clear(); Plan[L"A"] = a; Plan[L"B"] = b; ForceAnswer = force;
|
||||||
|
ui.Preferences.Verbose = true; Info.clear();
|
||||||
try { ui.DismountVolumes (Volumes(), false, interactive); return L"<no error>"; }
|
try { ui.DismountVolumes (Volumes(), false, interactive); return L"<no error>"; }
|
||||||
catch (DismountServiceCleanupFailed &e) { return e.GetSubject(); }
|
catch (DismountServiceCleanupFailed &e) { return e.GetSubject(); }
|
||||||
catch (UserAbort &) { return L"<cancelled>"; }
|
catch (UserAbort &) { return L"<cancelled>"; }
|
||||||
@@ -194,7 +196,15 @@ int Run () {
|
|||||||
Require (Run ({Unmounted}, {Busy, Busy}, false) == L"<busy>", "busy volume error changed without unconfirmed cleanup");
|
Require (Run ({Unmounted}, {Busy, Busy}, false) == L"<busy>", "busy volume error changed without unconfirmed cleanup");
|
||||||
Require (Run ({Unmounted}, {Busy}, true, false) == L"<cancelled>", "cancellation changed without unconfirmed cleanup");
|
Require (Run ({Unmounted}, {Busy}, true, false) == L"<cancelled>", "cancellation changed without unconfirmed cleanup");
|
||||||
Require (Run ({Unmounted}, {Busy, Unmounted}, true, true) == L"<no error>", "forced second pass failed");
|
Require (Run ({Unmounted}, {Busy, Unmounted}, true, true) == L"<no error>", "forced second pass failed");
|
||||||
|
for (bool interactive : {false, true}) {
|
||||||
|
Require (Run ({Failed, Unmounted}, {Unmounted}, interactive) == L"<no error>", "generic failure was not retried");
|
||||||
|
Require (Info == L"LINUX_VOL_UNMOUNTED B\nLINUX_VOL_UNMOUNTED A", "retried volume reported unmounted more than once");
|
||||||
|
}
|
||||||
|
Require (Run ({Failed, Failed}, {Unmounted}, false) == L"<failed>" && Info.empty(), "failed retry reported success");
|
||||||
|
r = Run ({Failed, Unconfirmed}, {Unmounted}, false);
|
||||||
|
Require (Has (r, L"service of A") && Info == L"LINUX_VOL_UNMOUNTED B", "unconfirmed retry reported success");
|
||||||
std::cout << "PASS: multi-volume unmount reports every unconfirmed cleanup with other failures and cancellation\n";
|
std::cout << "PASS: multi-volume unmount reports every unconfirmed cleanup with other failures and cancellation\n";
|
||||||
|
std::cout << "PASS: verbose unmount reporting follows successful attempts, including second-pass retries\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,7 +302,10 @@ namespace VeraCrypt
|
|||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
if (twoPassMode && firstPass)
|
if (twoPassMode && firstPass)
|
||||||
|
{
|
||||||
volumesLeft.push_back (volume);
|
volumesLeft.push_back (volume);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user