Redmine#2753: do not call readlink() on a directory to avoid spurious error

https://cfengine.com/dev/issues/2753

The proposed fix is just a suggestion.  Please review and see if it makes sense.