Bug 533976 wrong file permissions when saving or detaching attachment. r=bienvenu,sr=Neil

This commit is contained in:
ISHIKAWA, chiaki 2010-06-24 13:35:48 +01:00
Родитель fb92b9f16c
Коммит f5f18972f3
1 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -147,6 +147,8 @@ static NS_DEFINE_CID(kMsgSendLaterCID, NS_MSGSENDLATER_CID);
#define MIMETYPE_DELETED "text/x-moz-deleted"
#define ATTACHMENT_PERMISSION 00664
//
// Convert an nsString buffer to plain text...
//
@ -736,7 +738,7 @@ nsMessenger::DetachAttachmentsWOPrompts(nsIFile* aDestFolder,
ConvertAndSanitizeFileName(aDisplayNameArray[0], unescapedFileName);
rv = attachmentDestination->Append(unescapedFileName);
NS_ENSURE_SUCCESS(rv, rv);
rv = attachmentDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
rv = attachmentDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE, ATTACHMENT_PERMISSION);
NS_ENSURE_SUCCESS(rv, rv);
saveState = new nsSaveAllAttachmentsState(aCount,
@ -896,7 +898,7 @@ nsMessenger::SaveAttachmentToFolder(const nsACString& contentType, const nsACStr
rv = attachmentDestination->Append(unescapedFileName);
NS_ENSURE_SUCCESS(rv, rv);
#ifdef XP_MACOSX
rv = attachmentDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
rv = attachmentDestination->CreateUnique(nsIFile::NORMAL_FILE_TYPE, ATTACHMENT_PERMISSION);
NS_ENSURE_SUCCESS(rv, rv);
#endif
@ -1167,6 +1169,7 @@ nsMessenger::SaveAs(const nsACString& aURI, PRBool aAsFile, nsIMsgIdentity *aIde
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsILocalFile> tmpFile = do_QueryInterface(tmpTempFile, &rv);
// For temp file, we should use restrictive 00600 instead of ATTACHMENT_PERMISSION
rv = tmpFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
if (NS_FAILED(rv)) goto done;
@ -1863,7 +1866,7 @@ NS_IMETHODIMP
nsSaveMsgListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport)
{
if (m_file)
MsgNewBufferedFileOutputStream(getter_AddRefs(m_outputStream), m_file, -1, 00600);
MsgNewBufferedFileOutputStream(getter_AddRefs(m_outputStream), m_file, -1, ATTACHMENT_PERMISSION);
if (!m_outputStream)
{
mCanceled = PR_TRUE;
@ -1947,7 +1950,7 @@ nsSaveMsgListener::OnStopRequest(nsIRequest* request, nsISupports* aSupport,
}
else
{
rv = localFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
rv = localFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, ATTACHMENT_PERMISSION);
if (NS_FAILED(rv)) goto done;
}
rv = m_messenger->SaveAttachment(localFile,
@ -2897,10 +2900,11 @@ nsDelAttachListener::StartProcessing(nsMessenger * aMessenger, nsIMsgWindow * aM
getter_AddRefs(mMsgFile));
NS_ENSURE_SUCCESS(rv,rv);
// For temp file, we should use restrictive 00600 instead of ATTACHMENT_PERMISSION
rv = mMsgFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 00600);
NS_ENSURE_SUCCESS(rv,rv);
rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mMsgFileStream), mMsgFile, -1, 00600);
rv = MsgNewBufferedFileOutputStream(getter_AddRefs(mMsgFileStream), mMsgFile, -1, ATTACHMENT_PERMISSION);
// create the additional header for data conversion. This will tell the stream converter
// which MIME emitter we want to use, and it will tell the MIME emitter which attachments