Ejemplo n.º 1
0
// nee BOOL LoadSysEncSettings (void)
BOOL TryDetectSystemEncryptionStatus (void)
{
	DWORD size = 0;
	char *sysEncCfgFileBuf = NULL;
	char *xml = NULL;
	char *configPath = NULL;
	char paramName[100], paramVal[MAX_PATH];

	// Defaults
	int newSystemEncryptionStatus = SYSENC_STATUS_NONE;
	WipeAlgorithmId newnWipeMode = TC_WIPE_NONE;

	/* TODO: In case portable TrueCrypt was used to set up system encryption and has not finished
	   we won't be able to detect the state by config files since we don't know the TC's directory.
	   Actually it seems TC itself when used from another folder will not be able to do that.
	   Will have to check whether boot-related facilities can tell more */

	configPath = GetConfigPath (TC_APPD_FILENAME_SYSTEM_ENCRYPTION);
	if (!FileExists (configPath))
	{
		SystemEncryptionStatus = newSystemEncryptionStatus;
		nWipeMode = newnWipeMode;
	} 
	else {
		sysEncCfgFileBuf = LoadFile (configPath, &size);
		xml = sysEncCfgFileBuf;
	}

	if (xml == NULL)
	{
		return FALSE;
	}

	while (xml = XmlFindElement (xml, "config"))
	{
		XmlGetAttributeText (xml, "key", paramName, sizeof (paramName));
		XmlGetNodeText (xml, paramVal, sizeof (paramVal));

		if (strcmp (paramName, "SystemEncryptionStatus") == 0)
		{
			newSystemEncryptionStatus = atoi (paramVal);
		}
		else if (strcmp (paramName, "WipeMode") == 0)
		{
			newnWipeMode = (WipeAlgorithmId) atoi (paramVal);
		}

		xml++;
	}

	SystemEncryptionStatus = newSystemEncryptionStatus;
	nWipeMode = newnWipeMode;

	free (sysEncCfgFileBuf);
	return TRUE;
}
Ejemplo n.º 2
0
char *XmlFindElementByAttributeValue (char *xml, char *nodeName, char *attrName, char *attrValue)
{
	char attr[2048];

	while (xml = XmlFindElement (xml, nodeName))
	{
		XmlGetAttributeText (xml, attrName, attr, sizeof (attr));
		if (strcmp (attr, attrValue) == 0)
			return xml;

		xml++;
	}

	return NULL;
}