#5059 chmod all sub files and folders in temp directory

Programatically set permission to all sub files and folders of temp directory.

Passed Unit test and JsLint