From d6a57d3d1ee5ccc170fc3849304939328c0ca9a8 Mon Sep 17 00:00:00 2001 From: Jim Norman Date: Tue, 24 Apr 2007 18:51:33 +0000 Subject: [PATCH] Bug 267542. Don't start persistent until user has a home directory. --- CASA/micasad/cache/MPFileWatcher.cs | 31 +++++++++++++++++++++++++ CASA/micasad/cache/SecretStore.cs | 35 +++++++++++++++++++---------- CASA/micasad/common/WinUser.cs | 2 +- CASA/micasad/lss/LocalStorage.cs | 2 +- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/CASA/micasad/cache/MPFileWatcher.cs b/CASA/micasad/cache/MPFileWatcher.cs index ff35b67a..27573417 100644 --- a/CASA/micasad/cache/MPFileWatcher.cs +++ b/CASA/micasad/cache/MPFileWatcher.cs @@ -15,6 +15,7 @@ namespace sscs.cache private string m_filename = null; private byte[] m_baMP = new byte[32]; private byte[] m_baMPIV = new byte[32]; + private byte[] m_baMPSalt = null; private bool m_bIgnoreFileDeletes = false; public MPFileWatcher(string MPFilePath, string MPFileName) @@ -91,7 +92,18 @@ namespace sscs.cache fs.Read(m_baMPIV, 0, m_baMPIV.Length); fs.Flush(); fs.Close(); + + if (File.Exists(m_dir + m_filename + ".salt")) + { + m_baMPSalt = new byte[64]; + fs = new FileStream(m_dir + m_filename + ".salt", FileMode.Open, FileAccess.Read); + fs.Read(m_baMPSalt, 0, m_baMPSalt.Length); + fs.Flush(); + fs.Close(); + } + } + catch (Exception e) { LogMessage(e.ToString()); @@ -127,6 +139,25 @@ namespace sscs.cache { LogMessage(e.ToString()); } + + + if (m_baMPSalt != null) + { + try + { + FileStream fs = new FileStream(m_dir + m_filename + ".salt", FileMode.Create); + fs.Write(m_baMPSalt, 0, m_baMPSalt.Length); + fs.Flush(); + fs.Close(); + + File.SetAttributes(m_dir + m_filename + ".salt", FileAttributes.Hidden); + } + catch (Exception e) + { + LogMessage(e.ToString()); + } + } + } private void LogMessage(string message) diff --git a/CASA/micasad/cache/SecretStore.cs b/CASA/micasad/cache/SecretStore.cs index 774f48dc..576dd549 100644 --- a/CASA/micasad/cache/SecretStore.cs +++ b/CASA/micasad/cache/SecretStore.cs @@ -917,18 +917,29 @@ namespace sscs.cache return null; } else - { - // the user might have set a different one - // load the policy file and check. - UIPol uiPolicy = (UIPol)ICASAPol.GetPolicy(CASAPolType.UI_POL, GetUserHomeDirectory(), GetUserName()); - if (uiPolicy != null) - { - string sDir = uiPolicy.GetConfigSetting(ConstStrings.CONFIG_PERSISTENT_DIRECTORY); - if ((sDir != null) && (sDir.Length > 0)) - { - m_persistenceDirectory = sDir; - return m_persistenceDirectory; - } + { + + string sUserHomeDir = GetUserHomeDirectory(); + if (sUserHomeDir != null) + { + + // the user might have set a different one + // load the policy file and check. + UIPol uiPolicy = (UIPol)ICASAPol.GetPolicy(CASAPolType.UI_POL, sUserHomeDir, GetUserName()); + if (uiPolicy != null) + { + string sDir = uiPolicy.GetConfigSetting(ConstStrings.CONFIG_PERSISTENT_DIRECTORY); + if ((sDir != null) && (sDir.Length > 0)) + { + m_persistenceDirectory = sDir; + return m_persistenceDirectory; + } + } + } + else + { + // user not logged in yet + return null; } } diff --git a/CASA/micasad/common/WinUser.cs b/CASA/micasad/common/WinUser.cs index 73ae6b99..f6726652 100644 --- a/CASA/micasad/common/WinUser.cs +++ b/CASA/micasad/common/WinUser.cs @@ -33,7 +33,7 @@ namespace sscs.common { internal class WinUser : User { - private string m_sUserHome = ""; + private string m_sUserHome = null; internal WinUser() { diff --git a/CASA/micasad/lss/LocalStorage.cs b/CASA/micasad/lss/LocalStorage.cs index dd5844ae..40387dc1 100644 --- a/CASA/micasad/lss/LocalStorage.cs +++ b/CASA/micasad/lss/LocalStorage.cs @@ -444,7 +444,7 @@ namespace sscs.lss if (createdTimeNode != null) { //Console.WriteLine("Secret create time:" + new DateTime(long.Parse(createdTimeNode.Value))); - secret.CreatedTime = new DateTime(long.Parse(createdTimeNode.Value), DateTimeKind.Utc).ToLocalTime(); + secret.CreatedTime = new DateTime(long.Parse(createdTimeNode.Value), DateTimeKind.Utc).ToLocalTime(); } else {