create and set permissions for secret directories correctly