Security Audit - Marshal export file to CASAManager for saving.
This commit is contained in:
parent
98c12387a6
commit
43009ada4f
@ -108,7 +108,6 @@ namespace Novell.CASA.GUI
|
||||
#endif
|
||||
|
||||
//Store off this location for next export
|
||||
|
||||
int iLastSlash = sFileName.LastIndexOf("/");
|
||||
if (Common.IS_WINDOWS)
|
||||
iLastSlash = sFileName.LastIndexOf("\\");
|
||||
@ -125,25 +124,28 @@ namespace Novell.CASA.GUI
|
||||
m_config.WriteConfig();
|
||||
|
||||
// call our daemon to get the users secrets
|
||||
ExportXMLSecrets exportSecrets = new ExportXMLSecrets(sMasterPWD, sEncryptString, sFileName);
|
||||
|
||||
object obj = Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets);
|
||||
|
||||
|
||||
/*
|
||||
byte[] theSecrets = (byte[])Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets);
|
||||
|
||||
// write em out.
|
||||
|
||||
ExportXMLSecrets exportSecrets = new ExportXMLSecrets(sMasterPWD, sEncryptString, null);
|
||||
byte[] baSecrets = (byte[])Novell.CASA.MiCasa.Communication.MiCasaRequestReply.Send(MiCasaRequestReply.VERB_EXPORT_SECRETS, null, null, null, exportSecrets);
|
||||
|
||||
if (baSecrets != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileStream fs = new FileStream(sFileName, FileMode.Create);
|
||||
fs.Write(theSecrets, 0, theSecrets.Length);
|
||||
fs.Write(baSecrets, 0, baSecrets.Length);
|
||||
fs.Flush();
|
||||
fs.Close();
|
||||
*/
|
||||
|
||||
CommonGUI.DisplayMessage(MessageType.Info, "Secrets saved to: \r\n" + sFileName);
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
CommonGUI.DisplayMessage(MessageType.Error, "Failed to save secrets");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonGUI.DisplayMessage(MessageType.Error, "No Secrets found");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
8
CASA/micasad/cache/SecretStore.cs
vendored
8
CASA/micasad/cache/SecretStore.cs
vendored
@ -1030,7 +1030,7 @@ namespace sscs.cache
|
||||
return persistDir + ConstStrings.MICASA_SERVER_VALIDATION_FILE;
|
||||
}
|
||||
|
||||
internal string GetSecretsForExport(string sEncryptionString)
|
||||
internal byte[] GetSecretsForExport(string sEncryptionString)
|
||||
{
|
||||
byte[] baIV = null;
|
||||
byte[] baSecrets = GetSecrets(sEncryptionString, ref baIV);
|
||||
@ -1040,13 +1040,11 @@ namespace sscs.cache
|
||||
byte[] baCombined = new byte[baIV.Length + baSecrets.Length];
|
||||
baIV.CopyTo(baCombined, 0);
|
||||
baSecrets.CopyTo(baCombined, baIV.Length);
|
||||
|
||||
string sB64 = Convert.ToBase64String(baCombined);
|
||||
return sB64;
|
||||
return baCombined;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Convert.ToBase64String(baSecrets);
|
||||
return baSecrets;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,13 +110,15 @@ namespace Novell.CASA.MiCasa.Communication
|
||||
uint msgLen = BitConverter.ToUInt32(msgLenBytes, 0);
|
||||
if (msgLen > 6)
|
||||
{
|
||||
System.Text.Encoding encoding = System.Text.Encoding.ASCII;
|
||||
byte[] buf = null;
|
||||
int bytesAvailable;
|
||||
int totalBytes = 0;
|
||||
int msgLencount = 0;
|
||||
string bufstring = null;
|
||||
byte[] temp = null;
|
||||
|
||||
// buffer for data
|
||||
MemoryStream ms = new MemoryStream();
|
||||
|
||||
while (totalBytes < (msgLen - 6))
|
||||
{
|
||||
bytesAvailable = mSocket.Available;
|
||||
@ -126,13 +128,15 @@ namespace Novell.CASA.MiCasa.Communication
|
||||
}
|
||||
buf = new byte[bytesAvailable];
|
||||
bytesRecvd = mSocket.Receive(buf);
|
||||
bufstring = bufstring + encoding.GetString(buf); //keep buffering in a string
|
||||
ms.Write(buf, 0, bytesRecvd);
|
||||
|
||||
totalBytes = totalBytes + bytesAvailable;
|
||||
}
|
||||
if (totalBytes == 0)
|
||||
return null;
|
||||
|
||||
byte[] finalbuf = encoding.GetBytes(bufstring);//finally, convert the string to a byte array of size 'totalBytes'
|
||||
byte[] finalbuf = ms.ToArray();
|
||||
|
||||
int returnBufferLen = msgIdBytes.Length + msgLenBytes.Length + totalBytes;
|
||||
returnBuffer = new byte[returnBufferLen];
|
||||
Array.Copy(msgIdBytes, returnBuffer, 2);
|
||||
|
@ -411,31 +411,18 @@ namespace sscs.verbs
|
||||
string sEncrpyptionPassphrase = secrets.GetPassphrase();
|
||||
|
||||
// get all secrets
|
||||
//byte[] baSecrets = ssStore.GetSecrets(sEncrpyptionPassphrase, ref baIV);
|
||||
string baSecrets = ssStore.GetSecretsForExport(sEncrpyptionPassphrase);
|
||||
byte[] baSecrets = ssStore.GetSecretsForExport(sEncrpyptionPassphrase);
|
||||
|
||||
string sFilePath = secrets.GetFilePath();
|
||||
if (sFilePath != null)
|
||||
if (baSecrets != null)
|
||||
{
|
||||
// write em out
|
||||
FileStream fs = new FileStream(sFilePath, FileMode.Create);
|
||||
// write the secrets now
|
||||
//fs.Write(baSecrets, 0, baSecrets.Length);
|
||||
fs.Flush();
|
||||
fs.Close();
|
||||
|
||||
#if LINUX
|
||||
// change file ownership to the user
|
||||
Mono.Unix.Native.Syscall.chown(sFilePath, (uint)userId.GetUID(), (uint)userId.GetUID());
|
||||
#endif
|
||||
|
||||
wo.SetObject(baSecrets);
|
||||
wo.SetError(constants.RetCodes.SUCCESS, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
wo.SetObject(baSecrets);
|
||||
wo.SetError(constants.RetCodes.FAILURE, "No Secrets for Export");
|
||||
}
|
||||
|
||||
wo.SetError(constants.RetCodes.SUCCESS, "");
|
||||
return wo;
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user