diff options
Diffstat (limited to 'src/Main')
-rw-r--r-- | src/Main/CommandLineInterface.cpp | 4 | ||||
-rw-r--r-- | src/Main/CommandLineInterface.h | 2 | ||||
-rw-r--r-- | src/Main/GraphicUserInterface.cpp | 13 | ||||
-rw-r--r-- | src/Main/TextUserInterface.cpp | 12 | ||||
-rw-r--r-- | src/Main/UserInterface.cpp | 104 |
5 files changed, 79 insertions, 56 deletions
diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp index 735cbeef..08042c9e 100644 --- a/src/Main/CommandLineInterface.cpp +++ b/src/Main/CommandLineInterface.cpp @@ -32,9 +32,7 @@ namespace VeraCrypt ArgAllowScreencapture (false), ArgDisableFileSizeCheck (false), ArgUseLegacyPassword (false), -#if defined(TC_LINUX ) || defined (TC_FREEBSD) ArgUseDummySudoPassword (false), -#endif StartBackgroundTask (false) { wxCmdLineParser parser; @@ -376,9 +374,7 @@ namespace VeraCrypt ArgDisableFileSizeCheck = parser.Found (L"no-size-check"); ArgUseLegacyPassword = parser.Found (L"legacy-password-maxlength"); -#if defined(TC_LINUX ) || defined (TC_FREEBSD) ArgUseDummySudoPassword = parser.Found (L"use-dummy-sudo-password"); -#endif #if !defined(TC_WINDOWS) && !defined(TC_MACOSX) if (parser.Found (L"fs-options", &str)) diff --git a/src/Main/CommandLineInterface.h b/src/Main/CommandLineInterface.h index f773ca6f..7e7b1054 100644 --- a/src/Main/CommandLineInterface.h +++ b/src/Main/CommandLineInterface.h @@ -87,9 +87,7 @@ namespace VeraCrypt bool ArgAllowScreencapture; bool ArgDisableFileSizeCheck; bool ArgUseLegacyPassword; -#if defined(TC_LINUX ) || defined (TC_FREEBSD) bool ArgUseDummySudoPassword; -#endif bool StartBackgroundTask; UserPreferences Preferences; diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp index 1cb62671..b8098e95 100644 --- a/src/Main/GraphicUserInterface.cpp +++ b/src/Main/GraphicUserInterface.cpp @@ -826,6 +826,19 @@ namespace VeraCrypt return volume; } + + // check if the volume path exists using stat function. Only ENOENT error is handled to exclude permission denied error + struct stat statBuf; + if (stat (string (*options.Path).c_str(), &statBuf) != 0) + { + if (errno == ENOENT) + { + SystemException ex (SRC_POS); + ShowError (ex); + return volume; + } + } + try { if ((!options.Password || options.Password->IsEmpty()) diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp index bc3f6f5a..5dd778a0 100644 --- a/src/Main/TextUserInterface.cpp +++ b/src/Main/TextUserInterface.cpp @@ -1335,6 +1335,18 @@ namespace VeraCrypt return volume; } + // check if the volume path exists using stat function. Only ENOENT error is handled to exclude permission denied error + struct stat statBuf; + if (stat (string (*options.Path).c_str(), &statBuf) != 0) + { + if (errno == ENOENT) + { + SystemException ex (SRC_POS); + ShowError (ex); + return volume; + } + } + // Mount point if (!options.MountPoint && !options.NoFilesystem) options.MountPoint.reset (new DirectoryPath (AskString (_("Enter mount directory [default]: ")))); diff --git a/src/Main/UserInterface.cpp b/src/Main/UserInterface.cpp index ad2f22b8..4bb8bcda 100644 --- a/src/Main/UserInterface.cpp +++ b/src/Main/UserInterface.cpp @@ -496,8 +496,8 @@ namespace VeraCrypt EX2MSG (PasswordOrKeyboardLayoutIncorrect, LangString["PASSWORD_OR_KEYFILE_WRONG"] + LangString["LINUX_EX2MSG_PASSWORDORKEYBOARDLAYOUTINCORRECT"]); EX2MSG (PasswordOrMountOptionsIncorrect, LangString["PASSWORD_OR_KEYFILE_OR_MODE_WRONG"] + LangString["LINUX_EX2MSG_PASSWORDORMOUNTOPTIONSINCORRECT"]); EX2MSG (PasswordTooLong, StringFormatter (LangString["LINUX_EX2MSG_PASSWORDTOOLONG"], (int) VolumePassword::MaxSize)); - EX2MSG (PasswordUTF8TooLong, LangString["PASSWORD_UTF8_TOO_LONG"]); - EX2MSG (PasswordLegacyUTF8TooLong, LangString["LEGACY_PASSWORD_UTF8_TOO_LONG"]); + EX2MSG (PasswordUTF8TooLong, StringFormatter (LangString["PASSWORD_UTF8_TOO_LONG"], (int) VolumePassword::MaxSize)); + EX2MSG (PasswordLegacyUTF8TooLong, StringFormatter (LangString["LEGACY_PASSWORD_UTF8_TOO_LONG"], (int) VolumePassword::MaxLegacySize)); EX2MSG (PasswordUTF8Invalid, LangString["PASSWORD_UTF8_INVALID"]); EX2MSG (PartitionDeviceRequired, LangString["LINUX_EX2MSG_PARTITIONDEVICEREQUIRED"]); EX2MSG (ProtectionPasswordIncorrect, LangString["LINUX_EX2MSG_PROTECTIONPASSWORDINCORRECT"]); @@ -570,9 +570,7 @@ namespace VeraCrypt Core->SetAdminPasswordCallback (shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler)); } -#if defined(TC_LINUX ) || defined (TC_FREEBSD) Core->ForceUseDummySudoPassword (CmdLine->ArgUseDummySudoPassword); -#endif Core->WarningEvent.Connect (EventConnector <UserInterface> (this, &UserInterface::OnWarning)); Core->VolumeMountedEvent.Connect (EventConnector <UserInterface> (this, &UserInterface::OnVolumeMounted)); @@ -873,6 +871,14 @@ namespace VeraCrypt ShowWarning (e.mException); } +#if !defined(TC_WINDOWS) && !defined(TC_MACOSX) +// Function to check if a given executable exists and is executable +static bool IsExecutable(const string& exe) { + return wxFileName::IsFileExecutable("/usr/bin/" + exe) || + wxFileName::IsFileExecutable("/usr/local/bin/" + exe); +} +#endif + void UserInterface::OpenExplorerWindow (const DirectoryPath &path) { if (path.IsEmpty()) @@ -897,60 +903,58 @@ namespace VeraCrypt catch (exception &e) { ShowError (e); } #else - // MIME handler for directory seems to be unavailable through wxWidgets - wxString desktop = GetTraits()->GetDesktopEnvironment(); - bool xdgOpenPresent = wxFileName::IsFileExecutable (wxT("/usr/bin/xdg-open")) || wxFileName::IsFileExecutable (wxT("/usr/local/bin/xdg-open")); - bool nautilusPresent = wxFileName::IsFileExecutable (wxT("/usr/bin/nautilus")) || wxFileName::IsFileExecutable (wxT("/usr/local/bin/nautilus")); - - if (desktop == L"GNOME" || (desktop.empty() && !xdgOpenPresent && nautilusPresent)) - { - // args.push_back ("--no-default-window"); // This option causes nautilus not to launch under FreeBSD 11 - args.push_back ("--no-desktop"); - args.push_back (string (path)); - try - { - Process::Execute ("nautilus", args, 2000); + string directoryPath = string(path); + // Primary attempt: Use xdg-open + if (IsExecutable("xdg-open")) { + try { + args.push_back(directoryPath); + Process::Execute("xdg-open", args, 2000); + return; } catch (TimeOut&) { } - catch (exception &e) { ShowError (e); } + catch (exception&) {} } - else if (desktop == L"KDE") - { - try - { - args.push_back (string (path)); - Process::Execute ("dolphin", args, 2000); - } - catch (TimeOut&) { } - catch (exception&) - { + + // Fallback attempts: Try known file managers + const char* fallbackFileManagers[] = { "gio", "kioclient5", "kfmclient", "exo-open", "nautilus", "dolphin", "caja", "thunar", "pcmanfm" }; + const size_t numFileManagers = sizeof(fallbackFileManagers) / sizeof(fallbackFileManagers[0]); + + for (size_t i = 0; i < numFileManagers; ++i) { + const char* fm = fallbackFileManagers[i]; + if (IsExecutable(fm)) { args.clear(); - args.push_back ("openURL"); - args.push_back (string (path)); - try - { - Process::Execute ("kfmclient", args, 2000); + if (strcmp(fm, "gio") == 0) { + args.push_back("open"); + args.push_back(directoryPath); + } + else if (strcmp(fm, "kioclient5") == 0) { + args.push_back("exec"); + args.push_back(directoryPath); + } + else if (strcmp(fm, "kfmclient") == 0) { + args.push_back("openURL"); + args.push_back(directoryPath); + } + else if (strcmp(fm, "exo-open") == 0) { + args.push_back("--launch"); + args.push_back("FileManager"); + args.push_back(directoryPath); + } + else { + args.push_back(directoryPath); + } + + try { + Process::Execute(fm, args, 2000); + return; // Success } catch (TimeOut&) { } - catch (exception &e) { ShowError (e); } + catch (exception &) {} } } - else if (xdgOpenPresent) - { - // Fallback on the standard xdg-open command - // which is not always available by default - args.push_back (string (path)); - try - { - Process::Execute ("xdg-open", args, 2000); - } - catch (TimeOut&) { } - catch (exception &e) { ShowError (e); } - } - else - { - ShowWarning (wxT("Unable to find a file manager to open the mounted volume")); - } + + ShowWarning(wxT("Unable to find a file manager to open the mounted volume.\n" + "Please install xdg-utils or set a default file manager.")); #endif } |