It's generally for profit. In Havana, old American cars* (maquinas) run along established routes, with fixed fares. You can travel the city for 50 cents to a dollar, roughly.
Between cities, it's easy to find drivers who will take passengers, and hitchhiking (for money) is a very common and fluid system.
It's well in advance of our carpooling system in many ways, and all without smartphones.
I don't think it would work without smartphones here, but there's space in the market for an Airbnb of ridesharing. The underlying idea is monetization of spare private capacity.
Edit: I should add that the system is very, very safe. But Cuba is also very, very safe, so it's hard to draw conclusions.
*The American cars have replacement motors. Soviet and eastern european generally don't act as public taxis. Likely due to space, the America cars can fit 6-8 passengers.