Every officer of a prison shall while acting as such have all the powers, authority, protection and privileges of a constable.