Where does the bash PATH on CentOS 7 get /usr/local/bin from?
In the bash source "config-top.h" has this:
/* The default value of the PATH variable. */
#ifndef DEFAULT_PATH_VALUE
#define DEFAULT_PATH_VALUE \
"/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:."
#endif
/* The value for PATH when invoking `command -p'. This is only used when
the Posix.2 confstr () function, or CS_PATH define are not present. */
#ifndef STANDARD_UTILS_PATH
#define STANDARD_UTILS_PATH \
"/bin:/usr/bin:/sbin:/usr/sbin:/etc:/usr/etc"
#endif
Other people have asked the same thing on the CentOS bug tracker. The earliest post I found was this one.
/usr/local/bin is hardcoded in /bin/bash.
- https://bugs.centos.org/view.php?id=10200
- https://bugs.centos.org/view.php?id=10199
- https://bugs.centos.org/view.php?id=10198
- https://bugs.centos.org/view.php?id=7492
As you will see this problem was first reported in May 2012, and has existed in CentOS 6 and CentOS 7.
So as confusing as it may be, it looks like your analysis the paths are not coming from /etc/profile is correct. The paths are coming from /bin/bash.
It definitely looks hard coded into /bin/bash
strings /bin/bash | grep "\/usr\/local\/bin"
/usr/local/bin:/bin:/usr/bin
which seems to be the default PATH.