bug 222012. Better enforce persistent directory location

This commit is contained in:
Jim Norman 2007-01-04 08:54:07 +00:00
parent 67e99fc3d9
commit d0a9891cdf
3 changed files with 523 additions and 471 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Jan 4 13:37:03 MST 2007 - jnorman@novell.com
- Bug 221012. Based on code review, enhance persistent directory
policy.
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Jan 3 08:12:10 MST 2007 - jnorman@novell.com Wed Jan 3 08:12:10 MST 2007 - jnorman@novell.com

File diff suppressed because it is too large Load Diff

View File

@ -276,11 +276,14 @@ namespace sscs.verbs
{ {
cpd.SetErrorMessage("Directory not allowed"); cpd.SetErrorMessage("Directory not allowed");
return wo; return wo;
} }
#endif
#endif if (!ssStore.IsDirectoryOwnedByUser(sNewDir))
{
cpd.SetErrorMessage("Directory not owned by user");
return wo;
}
// copy all .miCASA* files to new location // copy all .miCASA* files to new location
string[] files = Directory.GetFiles(sOldDir, ".miCASA*"); string[] files = Directory.GetFiles(sOldDir, ".miCASA*");
if (files != null) if (files != null)
@ -320,7 +323,7 @@ namespace sscs.verbs
} }
private WrappedObject DoMergeXMLSecrets(SecretStore ssStore, WrappedObject wo) private WrappedObject DoMergeXMLSecrets(SecretStore ssStore, WrappedObject wo)
{ {
byte[] baIV = new byte[16]; byte[] baIV = new byte[16];
ImportXMLSecrets addSecrets = (ImportXMLSecrets)wo.GetObject(); ImportXMLSecrets addSecrets = (ImportXMLSecrets)wo.GetObject();
string sMasterPassword = addSecrets.GetMasterPasssword(); string sMasterPassword = addSecrets.GetMasterPasssword();
@ -333,23 +336,23 @@ namespace sscs.verbs
{ {
// let's read it // let's read it
FileStream fs = new FileStream(sFilePath, FileMode.Open); FileStream fs = new FileStream(sFilePath, FileMode.Open);
int iBytes = 0; int iBytes = 0;
// if a master password was sent, read the first 16 bytes as IV. // if a master password was sent, read the first 16 bytes as IV.
if (sMasterPassword != null) if (sMasterPassword != null)
{ {
baXMLSecrets = new byte[fs.Length - 16]; baXMLSecrets = new byte[fs.Length - 16];
iBytes = fs.Read(baIV, 0, 16); iBytes = fs.Read(baIV, 0, 16);
iBytes = fs.Read(baXMLSecrets, 0, (int)fs.Length - 16); iBytes = fs.Read(baXMLSecrets, 0, (int)fs.Length - 16);
} }
else else
{ {
baXMLSecrets = new byte[fs.Length]; baXMLSecrets = new byte[fs.Length];
iBytes = fs.Read(baXMLSecrets, 0, (int)fs.Length); iBytes = fs.Read(baXMLSecrets, 0, (int)fs.Length);
} }
fs.Flush(); fs.Flush();
fs.Close(); fs.Close();
} }
} }
@ -410,17 +413,17 @@ namespace sscs.verbs
string sEncrpyptionPassphrase = secrets.GetPassphrase(); string sEncrpyptionPassphrase = secrets.GetPassphrase();
// get all secrets // get all secrets
byte[] baSecrets = ssStore.GetSecretsForExport(sEncrpyptionPassphrase); byte[] baSecrets = ssStore.GetSecretsForExport(sEncrpyptionPassphrase);
if (baSecrets != null) if (baSecrets != null)
{ {
wo.SetObject(baSecrets); wo.SetObject(baSecrets);
wo.SetError(constants.RetCodes.SUCCESS, ""); wo.SetError(constants.RetCodes.SUCCESS, "");
} }
else else
{ {
wo.SetError(constants.RetCodes.FAILURE, "No Secrets for Export"); wo.SetError(constants.RetCodes.FAILURE, "No Secrets for Export");
} }
return wo; return wo;