There's an inconspicuous metal box mounted on the wall of the gym at San Francisco County Jail No. 4.
When Kate Monico Klein turns a knob, the machine releases a condom in a small cardboard packet. Machines like this one — dispensing condoms for free — are installed in all of the county's male jails.
"We set [the machine] off to the side, so that people would have a minor amount of privacy," explains Monico Klein, director of HIV services for Jail Health, a division of the county's health department.
San Francisco has been distributing condoms to inmates in county jails for decades, but a new California law requires condoms to be made available to all state prisoners. California is the second state after Vermont to do so, even though sex between prisoners is unlawful here.
"I get about 10 of them every time," says Robert Greve, an inmate who's serving a short sentence at Jail No. 4, with a laugh. He has been in and out of prison in several states, but this is the first time Greve has been locked up somewhere that provided condoms.
"Condoms are very good to have around, I think, you know? Because it's a life-saving device," he says. "A lot of people don't care about their health, I think."
But even though condoms are available inside the jail, Greve says deputies still enforce rules against inmates having sex.
"They freak out about it — like, I've seen them catch people in bed together and they're like, 'hey, what are you doing?!' "
Inmate Rene Angel Ramirez, who is gay and HIV-positive, says condoms keep his partners safer and protect him from other diseases like gonorrhea, chlamydia, or hepatitis C.
"We still have the need of sex, and believe it or not the straight men, while they're in custody, they do have sexual activity with other males," Angel Ramirez says. "It's sad, because I heard from other inmates how they have get infected with HIV while in custody."
The Centers for Disease Control and Prevention estimates that 1 in 7 people living with HIV pass through correctional facilities each year.
Back in the 1980s, San Francisco became one of the first places in the country to hand out condoms to inmates in the county jail. But three decades later, it's still one of only a handful of prison and jails in the country that do so.
Often that's because of a simple reason: Sex in prison or jails is against the rules in every state, even if it's consensual. And in some states, including California, it's actually a crime.
Still, San Francisco Sheriff Ross Mirkarimi says he supports the condom distribution program if it helps slow the spread of HIV and other sexually transmitted diseases.
"The law's the law," he says. "But should this behavior occur, that there is a safer way. We want people to be protected — and we insist on it, that they be protected."
But not all deputies are comfortable with condoms being available.
"I could not report to you that there still is buy-in from the uniformed staff," says Matthew Freeman, San Francisco's chief deputy sheriff. There are reasons that even consensual sex is prohibited in jail, he says.
"We know from our experiences running and managing these county jails that even consensual activity amongst inmates can lead to very real problems," he says, like disharmony in the jail, which the sheriff's department says is a potential security risk.
In the early days, deputies also were concerned that condoms could be used as weapons or to smuggle drugs. And while Kate Monico Klein of the public health department says that hasn't happened, she says condoms have been put to some more unusual uses.
"We found that, among other things, the prisoners take the condoms and they use them as hair ties, they use them as pillows," she says. "One of the deputies told me that they blow them up and use them as balloons."
And although that initially bothered some people, she says, "one of the things we realized is that it is another way of destigmatizing HIV."
California's state prison system now has five years to come up with a plan to provide condoms in all of its facilities.
Copyright 2015 NPR. To see more, visit http://www.npr.org/.