find_program() doesn't find not-readable programs
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Say, I'm trying to do find_program(SUDO NAMES sudo) and it fails while sudo is actually available and working.
cmSystemTools::FindProgram(), which in turn uses
access(filename, R_OK) to determine if the file is useful.
This is wrong, because a program may be not readable and still executable.
This is, for example, the case for setuid programs, as many distributions set ---s--x--x mode for them.
access() checks real user's permission instead of effective one.