Move .CASAPolicy.xml file to /home/.casa/username

This commit is contained in:
Jim Norman 2006-09-22 17:35:40 +00:00
parent e770de6959
commit 818c0796dd
7 changed files with 132 additions and 17 deletions

View File

@ -1,3 +1,8 @@
--------------------------------------------------------------------
Fri Sep 22 11:32:00 MST 2006 - jnorman@novell.com
- SLED is planning to encypt the user home directory
Move the .CASAPolicy files to /home/.casa/username
--------------------------------------------------------------------
Thu Jul 06 14:32:53 MST 2006 - jnorman@novell.com
- Bug 173648. Exec CASAManager.exe in the forground.

View File

@ -241,7 +241,12 @@ namespace Novell.CASA.GUI
Logger.DbgLog("GUI:CasaMain.CasaMain() - BEGIN");
if( false == Common.CheckForSingleInstance() )
{
{
// setup the users policy directory
MiCasaRequestReply.Send(MiCasaRequestReply.VERB_CREATE_POLICY_DIR);
MasterPasswordAuthentication();
if (Common.IsTrayAvailable()) // && Common.IsArgSet(args, Common.ARG_SHOW_TRAY_ICON))
{

View File

@ -57,6 +57,7 @@ namespace sscs.cache
private LocalStorage lss = null;
bool bIsStorePersistent = false;
string m_persistenceDirectory = null;
private static string POLICY_DIRECTORY = "/home/.casa";
private MPFileWatcher mpWatcher = null;
@ -89,8 +90,9 @@ namespace sscs.cache
ssMutex = new Mutex();
// create the policy directory for this user
CreatePolicyDirectory();
// start a MPFileWatcher if necessary
if (mpWatcher == null)
{
@ -907,6 +909,47 @@ namespace sscs.cache
}
}
internal void CreatePolicyDirectory()
{
#if LINUX
// set up mask
Mono.Unix.Native.FilePermissions permissions = Mono.Unix.Native.Syscall.umask(
Mono.Unix.Native.FilePermissions.S_IWGRP |
Mono.Unix.Native.FilePermissions.S_IWOTH);
// create the directory if necessary
if (!Directory.Exists(POLICY_DIRECTORY))
{
Directory.CreateDirectory(POLICY_DIRECTORY);
}
// create the directory for this user
Mono.Unix.UnixUserInfo uui = new Mono.Unix.UnixUserInfo(user.UserIdentifier.GetUID());
string sUsername = uui.UserName;
if (sUsername != null)
{
if (!Directory.Exists(POLICY_DIRECTORY+"/"+sUsername))
{
Directory.CreateDirectory(POLICY_DIRECTORY+"/"+sUsername);
// make this user the owner
if (uui != null)
{
Mono.Unix.Native.Syscall.chown(POLICY_DIRECTORY+"/"+sUsername, (uint)uui.UserId, (uint)uui.GroupId);
}
}
}
else
{
Console.WriteLine("no username");
}
// restore umask
Mono.Unix.Native.Syscall.umask(permissions);
#endif
}
}
}

View File

@ -59,6 +59,7 @@ namespace Novell.CASA.MiCasa.Communication
public const int VERB_EXPORT_SECRETS = 21;
public const int VERB_ADD_XML_SECRETS = 22;
public const int VERB_CHANGE_PERSIST_DIR = 23;
public const int VERB_CREATE_POLICY_DIR = 24;
public const int VERB_DUMP_LINKED_KEYS = 96;
public const int VERB_CREATE_TEST_SECRETS = 97;

View File

@ -231,6 +231,10 @@ namespace sscs.verbs
{
return DoChangePersistentDir(ssStore, wo);
}
case MiCasaRequestReply.VERB_CREATE_POLICY_DIR:
{
return DoCreatePolicyDir(ssStore, wo);
}
default:
{
@ -252,6 +256,12 @@ namespace sscs.verbs
}
private WrappedObject DoCreatePolicyDir(SecretStore ssStore, WrappedObject wo)
{
ssStore.CreatePolicyDirectory();
return wo;
}
private WrappedObject DoChangePersistentDir(SecretStore ssStore, WrappedObject wo)
{
CSSSLogger.ExecutionTrace(this);

View File

@ -57,7 +57,7 @@ CSFILES = $(srcdir)/AssemblyInfo.cs \
CSFILES_CSC := $(subst /,$(SEP),$(CSFILES))
CS_FLAGS = $(CSC_LIBFLAG)
CS_RESOURCES =
CS_LIBS =
CS_LIBS = Mono.Posix.dll
CS_LIBPATH =
OBJDIR = ./$(TARGET_CFG)/$(LIB)
@ -76,7 +76,7 @@ vpath %.cpp $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
vpath %.cs $(PLATFORMDEPENDENTSOURCEDIR) $(PLATFORMINDEPENDENTSOURCEDIR)
$(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT): $(OBJDIR) $(CSFILES)
$(CSC) $(CS_FLAGS) $(CS_EXTRA_FLAGS) -out:$@ $(CSFILES_CSC)
$(CSC) $(CS_FLAGS) $(CS_EXTRA_FLAGS) $(CS_LIBS:%=/r:%) -out:$@ $(CSFILES_CSC)
cp -f $(OBJDIR)/$(MODULE_NAME).$(MODULE_EXT) $(CASALIBDIR)/$(TARGET_CFG)/$(MODULE_NAME).$(MODULE_EXT)
$(OBJDIR):

View File

@ -32,34 +32,85 @@ using System.Text;
namespace Novell.CASA.CASAPolicy
{
public class ICASAPol
{
{
static string GetPolicyFilePath()
{
return GetPolicyFilePath(null);
}
static string GetPolicyFilePath(string sUserDir)
static string GetPolicyFilePath(string sUserHomeDir)
{
if (sUserDir != null)
{
return sUserDir + XmlConsts.policyFileName;
}
try
{
/* There needs to be a better way to get the HOME dir,
* if this is used by miCASAd(as it runs as root).
* if this is used by miCASAd(as it runs as root).
* UPDATE: micasad passes in the Home Directory
*/
int platform = (int)Environment.OSVersion.Platform;
string homeDir;
if ( (platform == 128) || ( platform == 4) )
{
homeDir = System.Environment.GetEnvironmentVariable("HOME");
}
else
{
{
// if sUserHomeDir is passed
if (sUserHomeDir != null)
{
homeDir = sUserHomeDir;
}
else
{
homeDir = System.Environment.GetEnvironmentVariable("HOME");
}
// get users name
string sUsername = homeDir.Substring(homeDir.LastIndexOf("/") + 1);
if (sUsername != null)
{
// check for existing files
string sOldLocation = homeDir + XmlConsts.policyFileName;
string sNewLocation = "/home/.casa/" + sUsername + XmlConsts.policyFileName;
// move file if needed
if ((!File.Exists(sNewLocation)) && (File.Exists(sOldLocation)))
{
try
{
File.Copy(sOldLocation, sNewLocation);
#if LINUX
// make the user the owner of the file
Mono.Unix.UnixUserInfo uui = new Mono.Unix.UnixUserInfo(sUsername);
if (uui != null)
{
Mono.Unix.Native.Syscall.chown(sNewLocation, (uint)uui.UserId, (uint)uui.GroupId);
}
#endif
File.Delete(sOldLocation);
}
catch (Exception)
{
}
}
return (sNewLocation);
}
}
else // is windows
{
if (sUserHomeDir != null)
{
return sUserHomeDir + XmlConsts.policyFileName;
}
homeDir = (System.Environment.GetEnvironmentVariable("USERPROFILE"));
}