Migrate .miCASA files to /home/.casa/[username] directory

This commit is contained in:
Jim Norman 2006-09-25 19:46:38 +00:00
parent 36292f46b7
commit 06000507be
3 changed files with 57 additions and 8 deletions

View File

@ -1,3 +1,7 @@
--------------------------------------------------------------------
Mon Sep 25 13:13:00 MST 2006 - jnorman@novell.com
- Move the .miCASA files to /home/.casa/username dir
--------------------------------------------------------------------
Fri Sep 22 11:32:00 MST 2006 - jnorman@novell.com
- SLED is planning to encypt the user home directory

View File

@ -436,6 +436,12 @@ public class Common
else
return false;
}
internal static string GetUserName()
{
return Environment.GetEnvironmentVariable("USERNAME");
}
internal static string GetUserHomeDir()
{
@ -447,7 +453,10 @@ public class Common
internal static string GetUserPersistentDir(Config config)
{
return (config.GetConfigSetting(CONFIG_PERSISTENT_DIRECTORY, GetUserHomeDir()));
if (Common.IS_LINUX)
return (config.GetConfigSetting(CONFIG_PERSISTENT_DIRECTORY, "/home/.casa/" + GetUserName()));
else
return (config.GetConfigSetting(CONFIG_PERSISTENT_DIRECTORY, GetUserHomeDir()));
}
internal static void SetUserPersistentDir(Config config, string sNewDirectory)

View File

@ -786,16 +786,16 @@ namespace sscs.cache
}
internal string GetPersistenceDirectory()
{
{
if (m_persistenceDirectory != null)
{
{
if (Directory.Exists(m_persistenceDirectory))
return m_persistenceDirectory;
else
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());
@ -804,13 +804,49 @@ namespace sscs.cache
string sDir = uiPolicy.GetConfigSetting(ConstStrings.CONFIG_PERSISTENT_DIRECTORY);
if ((sDir != null) && (sDir.Length > 0))
{
m_persistenceDirectory = sDir;
m_persistenceDirectory = sDir;
return m_persistenceDirectory;
}
}
}
return GetUserHomeDirectory();
#if LINUX
m_persistenceDirectory = MigrateMiCasaFiles();
return m_persistenceDirectory;
#else
return GetUserHomeDirectory();
#endif
}
internal string MigrateMiCasaFiles()
{
// for v1.7, we are storing MiCasa files in /home/.casa/[username]
// let's migrate the files if needed
string sNewPath = POLICY_DIRECTORY + "/" + user.GetUserName();
try {
if (Directory.GetFiles(sNewPath, ".miCASA*").Length > 0)
return sNewPath;
// check users home directory and move them if necessary
String[] miCASAFiles = Directory.GetFiles(GetUserHomeDirectory(), ".miCASA*");
if ((miCASAFiles != null) && (miCASAFiles.Length > 0))
{
for (int i=0; i<miCASAFiles.Length; i++)
{
string sFileName = miCASAFiles[i].Substring(miCASAFiles[i].LastIndexOf("/"));
File.Move(miCASAFiles[i], sNewPath + sFileName);
}
}
}
catch (Exception e)
{
CSSSLogger.DbgLog(e.ToString());
}
return (sNewPath);
}
internal bool SetPeristenceDirectory(string sNewDirectory)
@ -943,8 +979,8 @@ namespace sscs.cache
}
}
else
{
Console.WriteLine("no username");
{
CSSSLogger.DbgLog("No Username set");
}
// restore umask