mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-05 16:46:35 -05:00
Run display discovery asynchronously and bound batched disk-image inventory queries. Filter auxiliary mounts by basename, filesystem and owner, and keep unresolved candidates separate from verified volumes. Allow targeted dismounts despite incomplete discovery while requiring complete results for slot allocation and empty-inventory decisions. Use nonthrowing GUI snapshots with monotonic freshness, completion events and safe window lifetimes. Suspend inactivity decisions while the snapshot is stale, without restarting idle timers: activity counters are cumulative per volume instance. Refresh logout targets and retry only failed ones. Show a progress dialog for interactive unmounts, but keep automatic ones synchronous, so a quit or logout request that arrives meanwhile is handled afterwards rather than refused. Guard core operations against reentry and route wait-dialog requests only from worker threads, so a main-thread message cannot wait for itself. Bind teardown to captured mount and service identities, including process start time. Report a service exit that cannot be confirmed after auxiliary mount removal as a distinct error that keeps the original details. Such volumes are not retried, and a multi-volume unmount reports all of them together with any other failure or a declined prompt. Warn about it after automatic unmounts and at quit, and keep the background application until the warning is acknowledged. Keep rollback responsive, and let services remove their auxiliary directories without probing mounted paths. Preserve released /control compatibility and perform best-effort cleanup for older services. Reap bounded subprocesses as soon as their output ends. A child that survives SIGKILL is reaped by a later call, which starts no new child until then. Keep subjects and subprocess command, status and error output when formatting exceptions for wrapping and logs. Clarify discovery and rollback diagnostics. Fix the localization-dependent busy-volume regression assertion and extend discovery, snapshot, process identity, cleanup, GUI lifecycle, inactivity and teardown coverage.
104 lines
6.0 KiB
C++
104 lines
6.0 KiB
C++
/*
|
|
Derived from source code of TrueCrypt 7.1a, which is
|
|
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
|
|
by the TrueCrypt License 3.0.
|
|
|
|
Modifications and additions to the original source code (contained in this file)
|
|
and all other portions of this file are Copyright (c) 2013-2026 AM Crypto
|
|
and are governed by the Apache License 2.0 the full text of which is
|
|
contained in the file License.txt included in VeraCrypt binary and source
|
|
code distribution packages.
|
|
*/
|
|
|
|
#ifndef TC_HEADER_Core_CoreUnix
|
|
#define TC_HEADER_Core_CoreUnix
|
|
|
|
#include "System.h"
|
|
#include "Platform/Unix/Process.h"
|
|
#include "Core/CoreBase.h"
|
|
#include "Core/Unix/MountedFilesystem.h"
|
|
|
|
namespace VeraCrypt
|
|
{
|
|
class CoreUnix : public CoreBase
|
|
{
|
|
public:
|
|
CoreUnix ();
|
|
virtual ~CoreUnix ();
|
|
|
|
virtual void CheckFilesystem (shared_ptr <VolumeInfo> mountedVolume, bool repair = false) const;
|
|
virtual void DismountFilesystem (const DirectoryPath &mountPoint, bool force) const;
|
|
virtual shared_ptr <VolumeInfo> DismountVolume (shared_ptr <VolumeInfo> mountedVolume, bool ignoreOpenFiles = false, bool syncVolumeInfo = false);
|
|
#ifdef TC_LINUX
|
|
virtual shared_ptr <VolumeInfo> EmergencyDismountVolume (shared_ptr <VolumeInfo> mountedVolume);
|
|
#endif
|
|
virtual bool FilesystemSupportsLargeFiles (const FilePath &filePath) const;
|
|
virtual DirectoryPath GetDeviceMountPoint (const DevicePath &devicePath) const;
|
|
virtual uint32 GetDeviceSectorSize (const DevicePath &devicePath) const;
|
|
virtual uint64 GetDeviceSize (const DevicePath &devicePath) const;
|
|
virtual int GetOSMajorVersion () const { throw NotApplicable (SRC_POS); }
|
|
virtual int GetOSMinorVersion () const { throw NotApplicable (SRC_POS); }
|
|
virtual VolumeInfoList GetMountedVolumes (const VolumePath &volumePath = VolumePath()) const;
|
|
virtual VolumeDiscoveryResult GetMountedVolumesWithStatus (const VolumePath &volumePath = VolumePath()) const;
|
|
virtual bool IsDevicePresent (const DevicePath &device) const { throw NotApplicable (SRC_POS); }
|
|
virtual bool IsInPortableMode () const { return false; }
|
|
virtual bool IsMountPointAvailable (const DirectoryPath &mountPoint) const;
|
|
virtual bool IsOSVersion (int major, int minor) const { throw NotApplicable (SRC_POS); }
|
|
virtual bool IsOSVersionLower (int major, int minor) const { throw NotApplicable (SRC_POS); }
|
|
virtual bool IsPasswordCacheEmpty () const { throw NotApplicable (SRC_POS); }
|
|
virtual bool HasAdminPrivileges () const { return getuid() == 0 || geteuid() == 0; }
|
|
virtual VolumeSlotNumber MountPointToSlotNumber (const DirectoryPath &mountPoint) const;
|
|
virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options);
|
|
virtual void SetFileOwner (const FilesystemPath &path, const UserId &owner) const;
|
|
virtual DirectoryPath SlotNumberToMountPoint (VolumeSlotNumber slotNumber) const;
|
|
virtual void WipePasswordCache () const { throw NotApplicable (SRC_POS); }
|
|
virtual bool IsProtectedSystemDirectory (const DirectoryPath &directory) const;
|
|
virtual bool IsDirectoryOnUserPath(const DirectoryPath &directory) const;
|
|
|
|
protected:
|
|
static shared_ptr <VolumeInfo> ReadAuxiliaryVolumeInfo (const DirectoryPath &auxMountPoint);
|
|
virtual DevicePath AttachFileToLoopDevice (const FilePath &filePath, bool readOnly) const { throw NotApplicable (SRC_POS); }
|
|
virtual void DetachLoopDevice (const DevicePath &devicePath) const { throw NotApplicable (SRC_POS); }
|
|
virtual void DismountNativeVolume (shared_ptr <VolumeInfo> mountedVolume) const { throw NotApplicable (SRC_POS); }
|
|
#ifdef TC_LINUX
|
|
virtual void DismountFilesystemLazy (const DirectoryPath &mountPoint) const;
|
|
virtual void DismountNativeVolumeDeferred (shared_ptr <VolumeInfo> mountedVolume) const { DismountNativeVolume (mountedVolume); }
|
|
virtual bool IsLoopDeviceAttached (const DevicePath &devicePath) const { return devicePath.IsBlockDevice(); }
|
|
#endif
|
|
virtual bool FilesystemSupportsUnixPermissions (const DevicePath &devicePath) const;
|
|
virtual string GetDefaultMountPointPrefix () const;
|
|
virtual string GetFuseMountDirPrefix () const { return ".veracrypt_aux_mnt"; }
|
|
virtual MountedFilesystemList GetMountedFilesystems (const DevicePath &devicePath = DevicePath(), const DirectoryPath &mountPoint = DirectoryPath()) const = 0;
|
|
virtual uid_t GetRealUserId () const;
|
|
virtual gid_t GetRealGroupId () const;
|
|
virtual string GetTempDirectory () const;
|
|
// internalMountOnly maps to mount(8) -i and suppresses /sbin/mount.<type> helpers.
|
|
virtual void MountFilesystem (const DevicePath &devicePath, const DirectoryPath &mountPoint, const string &filesystemType, bool readOnly, const string &systemMountOptions, bool internalMountOnly = false) const;
|
|
virtual DevicePath MountAuxVolumeImage (const DirectoryPath &auxMountPoint, const MountOptions &options) const;
|
|
virtual void MountVolumeNative (shared_ptr <Volume> volume, MountOptions &options, const DirectoryPath &auxMountPoint) const { throw NotApplicable (SRC_POS); }
|
|
virtual void UpdateMountedVolumeInfo (shared_ptr <VolumeInfo> mountedVolume) const { (void) mountedVolume; }
|
|
#ifdef TC_MACOSX
|
|
virtual void UpdateMountedVolumesInfo (VolumeInfoList &volumes) const;
|
|
#endif
|
|
#ifdef TC_LINUX
|
|
string DetectFilesystemType (const DevicePath &devicePath) const;
|
|
bool IsFilesystemTypeRegistered (const string &filesystemType) const;
|
|
bool IsKernelFilesystemTypeAvailable (const string &filesystemType) const;
|
|
bool IsNtfsReadWriteKernelFilesystemTypeAvailable () const;
|
|
string DetectLinuxMountFallbackFilesystemType (const DevicePath &devicePath) const;
|
|
void MountFilesystemWithFallback (const DevicePath &devicePath, const DirectoryPath &mountPoint,
|
|
const string &filesystemType, bool allowFilesystemTypeFallback, bool readOnly,
|
|
const string &systemMountOptions, bool internalMountOnly) const;
|
|
void ResolveNtfsKernelMountOptions (const DevicePath &devicePath, bool mountNtfsWithKernelDriver,
|
|
wstring &filesystemType, bool &internalMountOnly) const;
|
|
string SelectNtfsKernelFilesystemType () const;
|
|
#endif
|
|
|
|
private:
|
|
CoreUnix (const CoreUnix &);
|
|
CoreUnix &operator= (const CoreUnix &);
|
|
};
|
|
}
|
|
|
|
#endif // TC_HEADER_Core_CoreUnix
|