Bug 193933. Fix Desktop capture problem.

This commit is contained in:
Jim Norman 2006-07-26 16:28:50 +00:00
parent 65b1bbbfc4
commit 8f19a3798b
3 changed files with 314 additions and 298 deletions

View File

@ -88,9 +88,14 @@ namespace sscs.cache
// start a MPFileWatcher if necessary
if (mpWatcher == null)
{
// make sure HomeDirectory exists
String sHomeDir = GetUserHomeDirectory();
if (sHomeDir != null && sHomeDir.Length > 0)
{
mpWatcher = new MPFileWatcher(GetUserHomeDirectory(), ConstStrings.MICASA_PASSCODE_BY_MASTERPASSWD_FILE);
}
}
}

View File

@ -71,6 +71,7 @@ namespace sscs.init
{
try
{
System.Diagnostics.Trace.WriteLine("Running: " + sProcess + " " + sArgs);
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(sProcess);

View File

@ -227,7 +227,7 @@ namespace sscs.lss
doc.LoadXml(xmlToLoad);
#if false
XmlTextWriter writer = new XmlTextWriter("/home/poorna/.miCASA.xml",null);
XmlTextWriter writer = new XmlTextWriter("d:/persist.xml",null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);
writer.Close();
@ -357,7 +357,57 @@ namespace sscs.lss
//userStore.DumpSecretstore();
try
{
MemoryStream ms1 = GetSecretsAsXMLStream();
//byte[] key = CASACrypto.GetKeySetFromFile(CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(),userStore.GetPasscodeByDesktopFilePath()),userStore.GetKeyFilePath());
byte[] key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetKeyFilePath());
string fileName = userStore.GetPersistenceFilePath();
string tempFile = fileName;
int count=0;
// rename existing file
if(File.Exists(fileName))
{
while(true)
{
if (File.Exists(tempFile+".tmp"))
{
if(IsOwnedByRoot(tempFile+".tmp"))
{
File.Delete(tempFile+".tmp");
break;
}
else
{
count++;
tempFile = fileName + count.ToString();
}
}
else
break;
}
File.Move(fileName, tempFile+".tmp");
}
CASACrypto.EncryptDataAndWriteToFile(ms1.ToArray(),key,fileName);
//remove temp
if(File.Exists(tempFile+".tmp"))
{
if(IsOwnedByRoot(tempFile+".tmp"))
File.Delete(tempFile+".tmp");
}
}
catch(Exception e)
{
CSSSLogger.ExpLog(e.ToString());
}
}
internal MemoryStream GetSecretsAsXMLStream()
{
try
{
MemoryStream ms1 = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(ms1,null);
writer.Formatting = Formatting.Indented;
@ -366,7 +416,6 @@ namespace sscs.lss
writer.WriteStartElement(XmlConsts.miCASANode);
writer.WriteAttributeString(XmlConsts.versionAttr,"1.5");
{
IDictionaryEnumerator iter = (IDictionaryEnumerator)userStore.GetKeyChainEnumerator();
char [] tmpId;
string sTmpId;
@ -465,55 +514,16 @@ namespace sscs.lss
}
writer.WriteEndElement(); //keychain
}
}
writer.WriteEndElement(); //miCASA node
writer.WriteEndDocument();
writer.Flush();
writer.Close();
//byte[] key = CASACrypto.GetKeySetFromFile(CASACrypto.GetMasterPasscode(userStore.GetDesktopPasswd(),userStore.GetPasscodeByDesktopFilePath()),userStore.GetKeyFilePath());
byte[] key = CASACrypto.GetKeySetFromFile(m_baGeneratedKey, userStore.GetKeyFilePath());
string fileName = userStore.GetPersistenceFilePath();
string tempFile = fileName;
int count=0;
// rename existing file
if(File.Exists(fileName))
{
while(true)
{
if (File.Exists(tempFile+".tmp"))
{
if(IsOwnedByRoot(tempFile+".tmp"))
{
File.Delete(tempFile+".tmp");
break;
}
else
{
count++;
tempFile = fileName + count.ToString();
}
}
else
break;
}
File.Move(fileName, tempFile+".tmp");
}
CASACrypto.EncryptDataAndWriteToFile(ms1.ToArray(),key,fileName);
//remove temp
if(File.Exists(tempFile+".tmp"))
{
if(IsOwnedByRoot(tempFile+".tmp"))
File.Delete(tempFile+".tmp");
}
return ms1;
}
catch (Exception e)
{
CSSSLogger.ExpLog(e.ToString());
throw e;
}
}
}