Update function to sanitise file permissions.