Any ordinance or resolution adopted by a county which requires written permission to enter vacant or unimproved private land from either the owner, the owner's agent, or the person in lawful possession of private land, shall not apply unless the land is immediately adjacent and contiguous to residential property, or enclosed by fence, or under cultivation, or posted with signs forbidding trespass, displayed at intervals of not less than three to a mile, along all exterior boundaries and at all roads and trails entering the private land.
Ca. Pen. Code § 602.2