[GNC-dev] Resolving symlinks in _br_find_exe in binreloc.c

Mike Alexander mta at umich.edu
Thu May 21 03:55:22 EDT 2020

I've had some fixes in binreloc.c for some time that I'm trying to clean 
up and commit.  Part of the problem is that _br_find_exe doesn't work at 
all for non-Aqua Mac builds (i.e. using X11).  I've fixed this by 
calling _NSGetExecutablePath if GNC_PLATFORM_OSX is set and 
MAC_INTEGRATION is not set.  This has been working for me for several 
years.  It shouldn't affect any other platforms.

The other problem is that it doesn't resolve symlinks properly.  There 
are bugs in that code that mean it never works, even in the simple case. 
  I can make simple cases (where the last path component is a symlink) 
work easily enough, but the general case is a bit more complicated if 
you limit yourself to using only readlink.  Is there any reason that we 
don't use the realpath function for this?  I think it exists in all 
non-Windows systems GnuCash cares about (Windows is a completely 
separate implementation of _br_find_exe).  It is in MacOS since 10.4, in 
Posix since POSIX.1-2001, in BSD4.4, and in Linux.  It's essentially 
trivial to call and will solve the problem.


More information about the gnucash-devel mailing list