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

@ -437,6 +437,12 @@ public class Common
return false;
}
internal static string GetUserName()
{
return Environment.GetEnvironmentVariable("USERNAME");
}
internal static string GetUserHomeDir()
{
if (Common.IS_LINUX)
@ -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

@ -810,7 +810,43 @@ namespace sscs.cache
}
}
#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)
@ -944,7 +980,7 @@ namespace sscs.cache
}
else
{
Console.WriteLine("no username");
CSSSLogger.DbgLog("No Username set");
}
// restore umask