|
|
1.1 root 1: /*
2: Copyright (c) 2004-2006 TrueCrypt Foundation. All rights reserved.
3:
4: Covered by TrueCrypt License 2.1 the full text of which is contained in the file
5: License.txt included in TrueCrypt binary and source code distribution archives.
6: */
7:
8: #define TC_REQUIRED_MOUSE_EVENTS 5000
9: #define TC_REQUIRED_KEYSTROKES RNG_POOL_SIZE
10:
11: #define TC_MAX_VOLUMES 256
12: #define TC_MAX_MINOR 256
13:
14: #define TC_MAP_DEV "/dev/mapper/truecrypt"
15: #define TC_LOOP_DEV "/dev/loop"
16: #define TC_MICE_DEVICE "/dev/input/mice"
17: #define TC_SHARE_KERNEL "/usr/share/truecrypt/kernel"
18:
19: #ifdef TC_MAX_PATH
20: #undef TC_MAX_PATH
21: #endif
22: #define TC_MAX_PATH 260
23: #define TC_MAX_PATH_STR "259"
24:
25: #define error(fmt, args...) fprintf (stderr, "truecrypt: " fmt, ## args)
26:
27: typedef struct
28: {
29: int DeviceNumber;
30: int DeviceMajor;
31: int DeviceMinor;
32: unsigned long long VolumeSize;
33: char VolumePath[TC_MAX_PATH];
34: int EA;
35: int Mode;
36: BOOL Hidden;
37: unsigned long long ReadOnlyStart;
38: unsigned long long ReadOnlyEnd;
39: unsigned long long ModTime;
40: unsigned long long AcTime;
41: int Flags;
42: } MountListEntry;
43:
44: static BOOL CheckAdminPrivileges ();
45: static void DropEffectiveUserId ();
46: static BOOL LockMemory ();
47: static BOOL WaitChild (BOOL quiet, char *execName);
48: static BOOL Execute (BOOL quiet, char *execName, ...);
49: static BOOL IsFile (char *path);
50: static BOOL IsBlockDevice (char *path);
51: static BOOL RestoreFileTime (char *path, time_t modTime, time_t acTime);
52: static BOOL LoadKernelModule ();
53: static BOOL UnloadKernelModule (BOOL quiet);
54: static BOOL CheckKernelModuleVersion (BOOL wait, BOOL quiet);
55: static void OpenMiceDevice ();
56: static BOOL GetMountList (BOOL force);
57: static BOOL IsVolumeMounted (char *volumePath);
58: static int GetFreeMapDevice ();
59: static BOOL DeleteLoopDevice (int loopDeviceNo);
60: static int AskSelection (int defaultChoice, int min, int max);
61: static BOOL AskYesNo (char *prompt, BOOL defaultNo);
62: static char *AskString (char *prompt, char *buf, int maxSize);
63: static void AskPassword (char *prompt, char *volumePath, Password *password);
64: static char *AskVolumePath (char *volumePath, char *prompt);
65: static BOOL AskKeyFiles (char *prompt, KeyFile **firstKeyFile);
66: static BOOL OpenVolume (char *volumePath, char *prompt, char *promptArg, BOOL secondaryPassword, PCRYPTO_INFO *cryptoInfo, unsigned long long *startSector, unsigned long long *totalSectors, time_t *modTime, time_t *acTime);
67: static char *EscapeSpaces (char *string);
68: static BOOL MountVolume (char *volumePath, char *mountPoint);
69: static void HexDump (unsigned __int8 *data, unsigned int length);
70: static uint64_t GetTimeUsec ();
71: static double GetTime ();
72: static BOOL RandFillPool ();
73: static BOOL ParseSize (char *string, unsigned long long *size);
74: static BOOL CreateVolume (char *hostPath);
75: static BOOL ChangePassword (char *volumePath);
76: static BOOL BackupVolumeHeaders (char *backupFile, char *volumePath);
77: static BOOL RestoreVolumeHeader (char *backupFile, char *volumePath);
78: static BOOL CreateKeyfile (char *path);
79: static time_t WindowsFileTime2UnixTime (uint64_t wTime);
80: static BOOL DumpVolumeProperties (char *volumePath);
81: static void DumpVersion (FILE *f);
82: static void DumpUsage (FILE *f);
83: static void DumpHelp ();
84: static BOOL DumpMountList (int devNo);
85: static BOOL DismountFileSystem (char *device);
86: static BOOL DismountVolume (int devNo);
87: static BOOL ToDeviceNumber (char *text, int *deviceNumber);
88:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.