From 21ba1ead8092b3d6b5d5db9ae44247065d5aa8c9 Mon Sep 17 00:00:00 2001 From: S Rahul Date: Tue, 26 May 2009 06:02:34 +0000 Subject: [PATCH] Bug#490570: Create CASA directory under c:/Progra~1/Novell/CASA/Profiles// for users who don't have home directory defined in the system registry and grant rights to only the system user and the CASA client user over the CASA directory. --- CASA/micasad/cache/SecretStore.cs | 11 +++++++++++ CASA/micasad/common/WinUser.cs | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CASA/micasad/cache/SecretStore.cs b/CASA/micasad/cache/SecretStore.cs index bdf806d2..6e5084cc 100644 --- a/CASA/micasad/cache/SecretStore.cs +++ b/CASA/micasad/cache/SecretStore.cs @@ -1041,7 +1041,18 @@ namespace sscs.cache if (!Directory.Exists(sNewPath)) { + string sSIDString; + string secDesc; + Directory.CreateDirectory(sNewPath); + + /* Give permissions to the user and system account */ + sSIDString = ((WinUserIdentifier)user.UserIdentifier).GetSID(); + System.Security.AccessControl.DirectorySecurity dirSec = Directory.GetAccessControl(sNewPath); + secDesc = "D:P(A;ID;GA;;;SY)(A;ID;GA;;;" + sSIDString + ")"; + System.Diagnostics.Trace.WriteLine("Setting security descriptor" + secDesc); + dirSec.SetSecurityDescriptorSddlForm(secDesc); + Directory.SetAccessControl(sNewPath, dirSec); } sSeperator = "\\"; diff --git a/CASA/micasad/common/WinUser.cs b/CASA/micasad/common/WinUser.cs index 25c0bc6c..bf7c5de7 100644 --- a/CASA/micasad/common/WinUser.cs +++ b/CASA/micasad/common/WinUser.cs @@ -81,9 +81,22 @@ namespace sscs.common CSSSLogger.DbgLog("Reading Reg: SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\" + sSIDString); string sProfile = ReadRegKey(Registry.LocalMachine, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\" + sSIDString, "ProfileImagePath"); - if (sProfile == null) + if (sProfile == null) { CSSSLogger.DbgLog("WinUser:GetUserHomeDir get Profile return null"); - else + if (sSIDString.Equals("S-1-5-18")) { + // Bug#490570 + string programFiles; + programFiles = ReadRegKey(Registry.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "ProgramFilesDir"); + if (programFiles == null) { + programFiles = ReadRegKey(Registry.LocalMachine, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion", "ProgramFiles"); + } + if (programFiles == null) { + CSSSLogger.DbgLog("WinUser:GetUserHomeDir unable to read program files path"); + } else { + m_sUserHome = programFiles + "\\Novell\\CASA\\profiles\\S-1-5-18"; + } + } + } else m_sUserHome = sProfile; //string sHomeDrive = ReadRegKey(Registry.Users, sSIDString+"\\Volatile Environment", "HOMEDRIVE");