phax / as2-lib

A generic Java AS2 library, servlet and server
107 stars 43 forks source link

Q - bcMail temporary files are created under /tmp directory and not deleted #103

Closed avnerw1 closed 4 years ago

avnerw1 commented 4 years ago

Hi Philip,

We use as2-lib, I noticed it is also using bcmail library. When a file is uploaded to the as2 server (on linux), a copy of each uploaded file is created on his “/tmp” directory. The filename pattern is “bcMail.mime” It has the same size of the uploaded file. The file is not deleted after the transfer is completed.

For example, if you upload 200 MB file, both the destination folder and the /tmp directory will have a file with size 200 MB.

The issue is that the /tmp directory is filled up with these files and user is concern about disk space.

I noticed SMimeUtil is generating these temporary files (but doesn’t delete them once processed or deleteOnExit). I also read that deleteOnExit doesn't always work or can cause issues (and in any case, we need the files to be cleaned before the JVM goes down, as the server is running for a long term).

We think a "use then delete-when-finished" approach is better than keeping this backup file forever. Might it be that you should use SMIMEUtil.toMimeBodyPart(CMSTypedStream, File) instead?

IMHO, the backing file should be disposed of when it's appropriate (something like a DestroyableMimeBodyPart).

Thanks, Avner

phax commented 4 years ago

Thanks for the report. Are you sure it is SMimeUtil and not SMIMESignedParser?

It seems to be very similiar to http://bouncy-castle.1462172.n4.nabble.com/Increasing-number-of-bcMail-mime-in-tmp-td1468333.html

phax commented 4 years ago

Ah okay. I see it. In the decryption when using SMIMEUtil.toMimeBodyPart

phax commented 4 years ago

I've created a 4.5.4 SNAPSHOT that should resolve this issue. Can you please check that? Thanks

avnerw1 commented 4 years ago

Hi Philip,

Many thanks for the fast response! We will download and test it soon (I'm on vacation tomorrow, but will do this on Tuesday).

Thanks, Avner

phax commented 4 years ago

Hi Avner, did you find time to crosscheck if your issue is now solved? Thx, Philip

avnerw1 commented 4 years ago

Hi Philip,

Unfortunately not, I apologize for not testing it yet as we had some urgent issues. We also noticed we need to do some code changes to use 4.5.4 (we are on 4.5.0) as there were some changes.

I will update you once tested.

Regards, Avner

phax commented 4 years ago

No worries, take your time. I was just curious ;)

phax commented 4 years ago

Hi Avner, I am about to do a 4.5.4 release - can you confirm that it works for you? Thanks

avnerw1 commented 4 years ago

Hi Phillip, I asked the developer to test it tomorrow. Sorry for the delays. Thanks, Avner

phax commented 4 years ago

Thanks for responding so quickly. I will go ahread with the 4.5.4 release as my tests were all positive but of course I am looking forward to your response as well.

avnerw1 commented 4 years ago

Hi Phillip,

Thank you for your patience. We have tested 4.5.5 release successfully. The temp files are not created anymore. :)

Thanks for the quick resolution!!

Regards, Avner

phax commented 4 years ago

Hi Avner, thanks for confirming that it works :) Happy AS2 message exchanging. BR, Philip