1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 02:58:02 -06:00

MacOSX: Add for using FUSE-T instead of MacFUSE

The build script build_veracrypt_macosx.h now accepts the argument -f to enable fuse-t support.
It is also possible to set the environment variable VC_OSX_FUSET to 1 for FUSE-T support.
A change was done in CoreUnix::GetMountedVolumes to add a waiting loop  for control file to be accessible because when using FUSE-T there always a delay before control file can be serialized.
This commit is contained in:
Mounir IDRASSI
2024-06-22 01:13:20 +02:00
parent 8b01b533cf
commit edde1d45f6
8 changed files with 1112 additions and 12 deletions

View File

@@ -14,14 +14,24 @@ SOURCEPATH=$(cd "$(dirname "$SCRIPTPATH/../.")"; pwd)
# directory where the VeraCrypt project has been checked out # directory where the VeraCrypt project has been checked out
PARENTDIR=$(cd "$(dirname "$SCRIPTPATH/../../../.")"; pwd) PARENTDIR=$(cd "$(dirname "$SCRIPTPATH/../../../.")"; pwd)
while getopts bp flag while getopts bpf flag
do do
case "${flag}" in case "${flag}" in
b) brew=true;; b) brew=true;;
p) package=true;; p) package=true;;
f) fuset=true;;
esac esac
done done
export VC_OSX_FUSET=0
if [ -n "$fuset" ]; then
echo "Building VeraCrypt with FUSE-T support"
VC_OSX_FUSET=1
else
echo "Building VeraCrypt with MacFUSE support"
fi
if [ -n "$brew" ]; then if [ -n "$brew" ]; then
export VC_OSX_SDK=$(xcrun --show-sdk-version) #use the latest version installed, this might fail export VC_OSX_SDK=$(xcrun --show-sdk-version) #use the latest version installed, this might fail
export VC_OSX_TARGET=${VC_OSX_SDK} export VC_OSX_TARGET=${VC_OSX_SDK}

View File

@@ -303,17 +303,39 @@ namespace VeraCrypt
continue; continue;
shared_ptr <VolumeInfo> mountedVol; shared_ptr <VolumeInfo> mountedVol;
try // Introduce a retry mechanism with a timeout for control file access
int controlFileRetries = 5;
while (controlFileRetries-- > 0)
{ {
shared_ptr <File> controlFile (new File); try
controlFile->Open (string (mf.MountPoint) + FuseService::GetControlPath()); {
shared_ptr <File> controlFile (new File);
controlFile->Open (string (mf.MountPoint) + FuseService::GetControlPath());
shared_ptr <Stream> controlFileStream (new FileStream (controlFile)); shared_ptr <Stream> controlFileStream (new FileStream (controlFile));
mountedVol = Serializable::DeserializeNew <VolumeInfo> (controlFileStream); mountedVol = Serializable::DeserializeNew <VolumeInfo> (controlFileStream);
break; // Control file opened successfully
}
catch (const std::exception& e)
{
// if exception starts with "VeraCrypt::Serializer::ValidateName", then
// serialization is not ready yet and we need to wait before retrying
// this happens when FUSE-T is used under macOS and if it is the first time
// the volume is mounted
if (string (e.what()).find ("VeraCrypt::Serializer::ValidateName") != string::npos)
{
Thread::Sleep(250); // Wait before retrying
}
else
{
break; // Control file not found
}
}
} }
catch (...)
if (!mountedVol)
{ {
continue; continue; // Skip to the next mounted filesystem
} }
if (!volumePath.IsEmpty() && wstring (mountedVol->Path).compare (volumePath) != 0) if (!volumePath.IsEmpty() && wstring (mountedVol->Path).compare (volumePath) != 0)
@@ -700,6 +722,7 @@ namespace VeraCrypt
} }
catch (...) catch (...)
{ {
wcout << L"Exception. Error mounting volume: " << wstring(*options.Path) << endl;
try try
{ {
VolumeInfoList mountedVolumes = GetMountedVolumes (*options.Path); VolumeInfoList mountedVolumes = GetMountedVolumes (*options.Path);

View File

@@ -119,6 +119,7 @@ namespace VeraCrypt
void CoreMacOSX::MountAuxVolumeImage (const DirectoryPath &auxMountPoint, const MountOptions &options) const void CoreMacOSX::MountAuxVolumeImage (const DirectoryPath &auxMountPoint, const MountOptions &options) const
{ {
#ifndef VC_MACOSX_FUSET
// Check FUSE version // Check FUSE version
char fuseVersionString[MAXHOSTNAMELEN + 1] = { 0 }; char fuseVersionString[MAXHOSTNAMELEN + 1] = { 0 };
size_t fuseVersionStringLength = MAXHOSTNAMELEN; size_t fuseVersionStringLength = MAXHOSTNAMELEN;
@@ -153,7 +154,7 @@ namespace VeraCrypt
if (fuseVersionMajor < 2 || (fuseVersionMajor == 2 && fuseVersionMinor < 5)) if (fuseVersionMajor < 2 || (fuseVersionMajor == 2 && fuseVersionMinor < 5))
throw HigherFuseVersionRequired (SRC_POS); throw HigherFuseVersionRequired (SRC_POS);
#endif
// Mount volume image // Mount volume image
string volImage = string (auxMountPoint) + FuseService::GetVolumeImagePath(); string volImage = string (auxMountPoint) + FuseService::GetVolumeImagePath();

View File

@@ -15,6 +15,6 @@ NAME := Driver
OBJS := OBJS :=
OBJS += FuseService.o OBJS += FuseService.o
CXXFLAGS += $(shell $(PKG_CONFIG) fuse --cflags) CXXFLAGS += $(shell $(PKG_CONFIG) $(VC_FUSE_PACKAGE) --cflags)
include $(BUILD_INC)/Makefile.inc include $(BUILD_INC)/Makefile.inc

View File

@@ -102,7 +102,7 @@ endif
#------ FUSE configuration ------ #------ FUSE configuration ------
FUSE_LIBS = $(shell $(PKG_CONFIG) fuse --libs) FUSE_LIBS = $(shell $(PKG_CONFIG) $(VC_FUSE_PACKAGE) --libs)
#------ Executable ------ #------ Executable ------
@@ -222,8 +222,12 @@ ifdef VC_LEGACY_BUILD
/usr/local/bin/packagesbuild $(BASE_DIR)/Setup/MacOSX/veracrypt_Legacy.pkgproj /usr/local/bin/packagesbuild $(BASE_DIR)/Setup/MacOSX/veracrypt_Legacy.pkgproj
productsign --sign "Developer ID Installer: IDRIX (Z933746L2S)" --timestamp "$(BASE_DIR)/Setup/MacOSX/VeraCrypt Legacy $(TC_VERSION).pkg" $(BASE_DIR)/Setup/MacOSX/VeraCrypt_$(TC_VERSION).pkg productsign --sign "Developer ID Installer: IDRIX (Z933746L2S)" --timestamp "$(BASE_DIR)/Setup/MacOSX/VeraCrypt Legacy $(TC_VERSION).pkg" $(BASE_DIR)/Setup/MacOSX/VeraCrypt_$(TC_VERSION).pkg
rm -f $(APPNAME)_Legacy_$(TC_VERSION).dmg rm -f $(APPNAME)_Legacy_$(TC_VERSION).dmg
else
ifeq "$(VC_OSX_FUSET)" "1"
/usr/local/bin/packagesbuild $(BASE_DIR)/Setup/MacOSX/veracrypt_fuse-t.pkgproj
else else
/usr/local/bin/packagesbuild $(BASE_DIR)/Setup/MacOSX/veracrypt.pkgproj /usr/local/bin/packagesbuild $(BASE_DIR)/Setup/MacOSX/veracrypt.pkgproj
endif
ifneq ("$(LOCAL_DEVELOPMENT_BUILD)","true") ifneq ("$(LOCAL_DEVELOPMENT_BUILD)","true")
productsign --sign "Developer ID Installer: IDRIX (Z933746L2S)" --timestamp "$(BASE_DIR)/Setup/MacOSX/VeraCrypt $(TC_VERSION).pkg" $(BASE_DIR)/Setup/MacOSX/VeraCrypt_$(TC_VERSION).pkg productsign --sign "Developer ID Installer: IDRIX (Z933746L2S)" --timestamp "$(BASE_DIR)/Setup/MacOSX/VeraCrypt $(TC_VERSION).pkg" $(BASE_DIR)/Setup/MacOSX/VeraCrypt_$(TC_VERSION).pkg
else else

View File

@@ -24,7 +24,8 @@
# SSE41: Enable SSE4.1 support in compiler # SSE41: Enable SSE4.1 support in compiler
# NOSSE2: Disable SEE2 support in compiler # NOSSE2: Disable SEE2 support in compiler
# WITHGTK3: Build wxWidgets against GTK3 # WITHGTK3: Build wxWidgets against GTK3
# WOLFCRYPT: Build with wolfCrypt as crypto provider (see Crypto/wolfCrypt.md) # WOLFCRYPT: Build with wolfCrypt as crypto provider (see Crypto/wolfCrypt.md)
# WITHFUSET: Build with FUSE-T support on macOS instead of MacFUSE
#------ Targets ------ #------ Targets ------
# all # all
@@ -52,6 +53,8 @@ export LFLAGS :=
export PKG_CONFIG ?= pkg-config export PKG_CONFIG ?= pkg-config
export PKG_CONFIG_PATH ?= /usr/local/lib/pkgconfig export PKG_CONFIG_PATH ?= /usr/local/lib/pkgconfig
export VC_FUSE_PACKAGE := fuse
export VC_OSX_FUSET ?= 0
export WX_CONFIG ?= wx-config export WX_CONFIG ?= wx-config
export WX_CONFIG_ARGS := --unicode export WX_CONFIG_ARGS := --unicode
@@ -62,6 +65,12 @@ WX_ROOT ?= $(BASE_DIR)/wxWidgets
export TC_BUILD_CONFIG := Release export TC_BUILD_CONFIG := Release
ifeq "$(origin WITHFUSET)" "command line"
ifneq "$(WITHFUSET)" "0"
VC_OSX_FUSET := 1
endif
endif
ifeq "$(origin DEBUG)" "command line" ifeq "$(origin DEBUG)" "command line"
ifneq "$(DEBUG)" "0" ifneq "$(DEBUG)" "0"
TC_BUILD_CONFIG := Debug TC_BUILD_CONFIG := Debug
@@ -333,6 +342,10 @@ ifeq "$(shell uname -s)" "Darwin"
WX_CONFIGURE_FLAGS += --with-macosx-version-min=$(VC_OSX_TARGET) --with-macosx-sdk=$(VC_OSX_SDK_PATH) WX_CONFIGURE_FLAGS += --with-macosx-version-min=$(VC_OSX_TARGET) --with-macosx-sdk=$(VC_OSX_SDK_PATH)
ifneq "$(VC_OSX_FUSET)" "0"
C_CXX_FLAGS += -DVC_MACOSX_FUSET
VC_FUSE_PACKAGE := fuse-t
endif
# Set x86 assembly flags (-msse2, -mssse3, -msse4.1) # Set x86 assembly flags (-msse2, -mssse3, -msse4.1)
# Apply flags if SIMD_SUPPORTED is 1 or if not in local development build (we are creating universal binary in this case) # Apply flags if SIMD_SUPPORTED is 1 or if not in local development build (we are creating universal binary in this case)

View File

@@ -0,0 +1,5 @@
#!/bin/bash
chmod -R go-w /Applications/VeraCrypt.app
exit 0

File diff suppressed because it is too large Load Diff