Fix leaking directory problem under privsep #3573

Say exactly what we are trying to remove. We need to trim off the front
of a string too, so that we do not get "//".

Handle case where string has length 0
Incorporate changes from Zach's review
Version history