In other cases the party shall be placed in custody of the person legally entitled thereto, or if no one is so entitled, he shall be discharged.