Embattled San Francisco sheriff to keep his job