Fix for linux build and Server Keychain. Work-in-progress

This commit is contained in:
Jim Norman 2006-12-04 12:00:27 +00:00
parent 3216d2b739
commit b0fad0f85f
2 changed files with 179 additions and 152 deletions

View File

@ -75,8 +75,7 @@ namespace sscs.cache
User casaUser;
#if LINUX
Directory.CreateDirectory("/home/.casa/" + constants.ConstStrings.MICASA_SERVICE_NAME);
casaUser = new UnixUser(new UnixUserIdentifier(GetCasaServiceUID()), "/home/.casa/" + constants.ConstStrings.MICASA_SERVICE_NAME));
casaUser = new UnixUser(new UnixUserIdentifier(GetCasaServiceUID()), "/home/.casa/" + constants.ConstStrings.MICASA_SERVICE_NAME);
#else
// create a data directory for server secrets
Process proc = Process.GetCurrentProcess();
@ -100,6 +99,7 @@ namespace sscs.cache
static private int GetCasaServiceUID()
{
Mono.Unix.UnixUserInfo uui;
try
{
uui = new Mono.Unix.UnixUserInfo(constants.ConstStrings.MICASA_SERVICE_NAME);
@ -120,7 +120,25 @@ namespace sscs.cache
uui = new Mono.Unix.UnixUserInfo(constants.ConstStrings.MICASA_SERVICE_NAME);
}
return uui.UserId;
if (uui != null)
{
// create directory for casa
Mono.Unix.Native.FilePermissions permissions = Mono.Unix.Native.Syscall.umask(
Mono.Unix.Native.FilePermissions.S_IWGRP |
Mono.Unix.Native.FilePermissions.S_IWOTH);
Directory.CreateDirectory("/home/.casa/" + constants.ConstStrings.MICASA_SERVICE_NAME);
// set ownership
Mono.Unix.Native.Syscall.chown("/home/.casa/" + constants.ConstStrings.MICASA_SERVICE_NAME,
(uint)uui.UserId,
(uint)uui.GroupId);
Mono.Unix.Native.Syscall.umask(permissions);
}
return (int)uui.UserId;
}
#endif
private DateTime createTime;
@ -798,12 +816,17 @@ namespace sscs.cache
}
internal KeyChain GetKeyChain(string id)
{
{
Console.WriteLine("Keychain {0}", id);
// if this is the server keychain, return the casaStore controlled one.
if (id.StartsWith(constants.ConstStrings.SSCS_SERVER_KEY_CHAIN_ID))
{
KeyChain casakc = (KeyChain)casaStore.keyChainList[id];
casakc.AccessedTime = DateTime.Now;
Console.WriteLine("Returned casakc");
return casakc;
}
@ -1149,8 +1172,10 @@ namespace sscs.cache
#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);
Mono.Unix.Native.FilePermissions.S_IWGRP |
Mono.Unix.Native.FilePermissions.S_IRGRP |
Mono.Unix.Native.FilePermissions.S_IROTH |
Mono.Unix.Native.FilePermissions.S_IWOTH);
// create the directory if necessary
if (!Directory.Exists(POLICY_DIRECTORY))

View File

@ -41,7 +41,9 @@ namespace sscs.common
internal UnixUser(UserIdentifier unixUserId, string sUserHome)
{
m_userHome = sUserHome;
this.UnixUser(unixUserId);
userId = unixUserId;
secretStore = new SecretStore(this);
}
internal UnixUser(UserIdentifier unixUserId)