It was legal if the situation suggested that he was likely under the influence of drugs or alcohol, which would be a crime if he had been or necessarily had been operating a vehicle. People do not normally sleep in their cars at a gas station. That he was suggests thatthe was under the influence and drove there while under the influence, which would be a crime. They could therefore legally wake and search him, since it appeared he was engaged in illegal activity, to ascertain if that was the case.