Fix ownership and permissions of directories