Check permissions for directoy and file creations from within our code

Description

In a recet merge request, there was a notification about a (possible) weakness regarding permissions for directories created from within a running program. We should investigate this specific case and also look for others and see if we can limit the permissions during all these creation processes.

Please investigate all occurrences of dir/file creation