Permission bug.

Added permission checking when printing the problem source during an error.

This resolves bug 2939.  

There is an associated pull request for pg that needs to be merged as well.