Move .CASAPolicy.xml file to /home/.casa/username
This commit is contained in:
parent
e770de6959
commit
818c0796dd
@ -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.
|
||||
|
@ -242,6 +242,11 @@ namespace Novell.CASA.GUI
|
||||
|
||||
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))
|
||||
{
|
||||
|
45
CASA/micasad/cache/SecretStore.cs
vendored
45
CASA/micasad/cache/SecretStore.cs
vendored
@ -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,7 +90,8 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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):
|
||||
|
@ -33,22 +33,20 @@ 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).
|
||||
* UPDATE: micasad passes in the Home Directory
|
||||
*/
|
||||
|
||||
int platform = (int)Environment.OSVersion.Platform;
|
||||
@ -56,10 +54,63 @@ public class ICASAPol
|
||||
|
||||
if ( (platform == 128) || ( platform == 4) )
|
||||
{
|
||||
homeDir = System.Environment.GetEnvironmentVariable("HOME");
|
||||
// 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
|
||||
else // is windows
|
||||
{
|
||||
if (sUserHomeDir != null)
|
||||
{
|
||||
return sUserHomeDir + XmlConsts.policyFileName;
|
||||
}
|
||||
|
||||
homeDir = (System.Environment.GetEnvironmentVariable("USERPROFILE"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user