This is a great question. I wanted to provide an answer which cited some specific, real-world situations. Currently the only people in space are those aboard the International Space Station. If anyone could potentially get into a scenario as you describe in your question, it would be them.
Currently, on spacewalks, a huge number of safety procedures are used to ensure the safety of the astronaut. One primary component is the use of tethers to keep the astronaut tied to the actual space station. If this tether were to break, there are secondary means of keeping the astronaut from drifting into space.
Once the astronaut comes untethered, his primary concern is to remove any velocity he may have which is taking him away from the space station. The cause of this velocity can depend on a variety of factors. Often in movies, its because something exploded and the astronaut is flying away from his station/shuttle quite rapidly. In a scenario like this, the astronaut can use his SAFER unit. This is a pack worn by astronauts during extra-vehicular activities (EVA) which is designed for just such an emergency. It has thrusters on it capable of slowing down the astronaut and sending him back towards the station/shuttle. These thrusters are of coarsecourse limited and can only handle changing the astronaut's velocity by about 3 m/s. If they're moving faster than that, they need an additional way to slow themselves down.
If, for whatever reason they can't use the thrusters, or it isn't enough, they're likely going to have to rely on Newton's Third Law $-$— for every action, there is an equal and opposite reaction. What this means is that they can slow themselves down by throwing any objects they have on hand. If they happened to have a wrench in their hand when the unfortunate event occurred, they could throw the wrench in the direction they were traveling. The act of ejecting the wrench in a particular direction would cause them to slow their motion in that direction. At this point, the SAFER unit might still be useful, even if it is out of propellant. They can always throw that! If they need to, they can try throwing anything they can safely dispose of which can help slow their speed and bring them back to the space station.
There is one final saving grace that I can think of. The ISS in particular has robotic arms on the outside. These arms are meant for doing space work by those inside the ISS and include things like performing repairs and helping ships to dock. It is quite possible that an arm could be used to grab onto a free-floating astronaut, or else provide the astronaut with something to grab onto. This of course relies on the fact that 1) the astronaut is close enough, and 2) the arm has not been destroyed during the accident that sendsent the astronaut into space.
So ultimately, a free-floating astronaut who has been untethered is not in an ideal situation, but certainly not unrecoverable. There are several redundant mechanisms which the astronaut can use to save themselves in emergency situations. Redundancy is the key to safe space travel!