From 6ced991d98da9645b97ed6cf2556ae2a76085116 Mon Sep 17 00:00:00 2001 From: Jertzukka Date: Thu, 1 Jun 2023 10:01:53 +0300 Subject: Fix issues launching fsck via terminal on Linux (#1086) Currently on a system without xterm or konsole (like fresh Ubuntu install) the fsck check will not launch. Added gnome-terminal as an alternative and fixed an issue where konsole will always error out as --title and --caption are no longer valid arguments. Previously the error message was simply "xterm not found", so new LangString LINUX_EX2MSG_TERMINALNOTFOUND was added to let the user knows which programs they need to get the feature working. --- src/Common/Language.xml | 1 + src/Core/Unix/CoreUnix.cpp | 22 +++++++++++++++++----- src/Main/Forms/WaitDialog.cpp | 1 + src/Main/UserInterface.cpp | 2 ++ src/Platform/Exception.h | 1 + 5 files changed, 22 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Common/Language.xml b/src/Common/Language.xml index 366bb0b0..a2615124 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -1569,6 +1569,7 @@ VeraCrypt was previously installed using an MSI package and so it can't be updated using the standard installer.\n\nPlease use the MSI package to update your VeraCrypt installation. Use all available free space VeraCrypt cannot be upgraded because the system partition/drive was encrypted using an algorithm that is not supported anymore.\nPlease decrypt your system before upgrading VeraCrypt and then encrypt it again. + Supported terminal application could not be found, you need either xterm, konsole or gnome-terminal (with dbus-x11). diff --git a/src/Core/Unix/CoreUnix.cpp b/src/Core/Unix/CoreUnix.cpp index 2dac4cb5..56382c18 100644 --- a/src/Core/Unix/CoreUnix.cpp +++ b/src/Core/Unix/CoreUnix.cpp @@ -78,10 +78,8 @@ namespace VeraCrypt if (stat("/usr/bin/konsole", &sb) == 0) { args.clear (); - args.push_back ("--title"); - args.push_back ("fsck"); - args.push_back ("--caption"); - args.push_back ("fsck"); + args.push_back ("-p"); + args.push_back ("tabtitle=fsck"); args.push_back ("-e"); args.push_back ("sh"); args.push_back ("-c"); @@ -91,8 +89,22 @@ namespace VeraCrypt Process::Execute ("konsole", args, 1000); } catch (TimeOut&) { } } + else if (stat("/usr/bin/gnome-terminal", &sb) == 0 && stat("/usr/bin/dbus-launch", &sb) == 0) + { + args.clear (); + args.push_back ("--title"); + args.push_back ("fsck"); + args.push_back ("--"); + args.push_back ("sh"); + args.push_back ("-c"); + args.push_back (xargs); + try + { + Process::Execute ("gnome-terminal", args, 1000); + } catch (TimeOut&) { } + } else - throw; + throw TerminalNotFound(); } #endif } diff --git a/src/Main/Forms/WaitDialog.cpp b/src/Main/Forms/WaitDialog.cpp index 2976a6e8..795d7763 100644 --- a/src/Main/Forms/WaitDialog.cpp +++ b/src/Main/Forms/WaitDialog.cpp @@ -74,6 +74,7 @@ namespace VeraCrypt VC_CONVERT_EXCEPTION (ParameterTooLarge); VC_CONVERT_EXCEPTION (PartitionDeviceRequired); VC_CONVERT_EXCEPTION (StringConversionFailed); + VC_CONVERT_EXCEPTION (TerminalNotFound); VC_CONVERT_EXCEPTION (TestFailed); VC_CONVERT_EXCEPTION (TimeOut); VC_CONVERT_EXCEPTION (UnknownException); diff --git a/src/Main/UserInterface.cpp b/src/Main/UserInterface.cpp index 9c7d4e29..1a237bbe 100644 --- a/src/Main/UserInterface.cpp +++ b/src/Main/UserInterface.cpp @@ -481,6 +481,7 @@ namespace VeraCrypt EX2MSG (UnportablePassword, LangString["UNSUPPORTED_CHARS_IN_PWD"]); #if defined (TC_LINUX) + EX2MSG (TerminalNotFound, LangString["LINUX_EX2MSG_TERMINALNOTFOUND"]); EX2MSG (UnsupportedSectorSize, LangString["SECTOR_SIZE_UNSUPPORTED"]); EX2MSG (UnsupportedSectorSizeHiddenVolumeProtection, LangString["LINUX_EX2MSG_UNSUPPORTEDSECTORSIZEHIDDENVOLUMEPROTECTION"]); EX2MSG (UnsupportedSectorSizeNoKernelCrypto, LangString["LINUX_EX2MSG_UNSUPPORTEDSECTORSIZENOKERNELCRYPTO"]); @@ -1620,6 +1621,7 @@ namespace VeraCrypt VC_CONVERT_EXCEPTION (ParameterTooLarge); VC_CONVERT_EXCEPTION (PartitionDeviceRequired); VC_CONVERT_EXCEPTION (StringConversionFailed); + VC_CONVERT_EXCEPTION (TerminalNotFound); VC_CONVERT_EXCEPTION (TestFailed); VC_CONVERT_EXCEPTION (TimeOut); VC_CONVERT_EXCEPTION (UnknownException); diff --git a/src/Platform/Exception.h b/src/Platform/Exception.h index b0f04bba..c9635414 100644 --- a/src/Platform/Exception.h +++ b/src/Platform/Exception.h @@ -92,6 +92,7 @@ namespace VeraCrypt TC_EXCEPTION (ParameterTooLarge); \ TC_EXCEPTION (PartitionDeviceRequired); \ TC_EXCEPTION (StringConversionFailed); \ + TC_EXCEPTION (TerminalNotFound); \ TC_EXCEPTION (TestFailed); \ TC_EXCEPTION (TimeOut); \ TC_EXCEPTION (UnknownException); \ -- cgit v1.2.3