The sheriff, when necessary, may, with the assent in writing of the county judge, or in a city, of the mayor thereof, employ a temporary guard for the protection of the county jail, or for the safekeeping of prisoners, the expenses of which are a county charge.
Ca. Pen. Code § 4014