Skip to content

Conversation

@floppym
Copy link
Contributor

@floppym floppym commented Dec 31, 2016

exec(3) from glibc says:

The execlp(), execvp(), and execvpe() functions duplicate the actions
of the shell in searching for an executable file if the specified
filename does not contain a slash (/) character. The file is sought in
the colon-separated list of directory pathnames specified in the PATH
environment variable. If this variable isn't defined, the path list
defaults to the current directory followed by the list of directories
returned by confstr(_CS_PATH). (This confstr(3) call typically returns
the value "/bin:/usr/bin".)

@floppym
Copy link
Contributor Author

floppym commented Dec 31, 2016

An alternative to this would be to hard-code a fallback PATH setting, probably based on a configure option.

exec(3) from glibc says:

  The execlp(), execvp(), and execvpe() functions duplicate the actions
  of the shell in searching for an executable file if the specified
  filename does not contain a slash (/) character. The file is sought in
  the colon-separated list of directory pathnames specified in the PATH
  environment variable. If this variable isn't defined, the path list
  defaults to the current directory followed by the list of directories
  returned by confstr(_CS_PATH). (This confstr(3) call typically returns
  the value "/bin:/usr/bin".)
@floppym floppym changed the title src/python-exec.c: utilze confstr(_CS_PATH) if PATH is unset src/python-exec.c: utilize confstr(_CS_PATH) if PATH is unset Dec 31, 2016
@mgorny
Copy link
Member

mgorny commented Dec 31, 2016

To be honest, I'm not convinced this is the best things to do. Citing POSIX:

If this environment variable is not present, the results of the search are implementation-defined.

This variable certainly isn't POSIX, and the glibc behavior is at best debatable. I certainly don't think it a good idea to use CWD like this.

@mgorny
Copy link
Member

mgorny commented Dec 31, 2016

FreeBSD, Darwin:

If this variable is not specified, the default path
is set according to the _PATH_DEFPATH definition in <paths.h>, which is
set to ``/usr/bin:/bin''. For execvP(), the search path is specified as
an argument to the function. In addition, certain errors are treated
specially.

Solaris manpage doesn't mention fallback at all.

Copy link
Member

@mgorny mgorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yeah, I would prefer that instead of emulating (bad) glibc behavior we'd set PATH to a sane value that would ensure consistent behavior on all systems.

@floppym
Copy link
Contributor Author

floppym commented Dec 31, 2016

Per our IRC conversation, I will open a new PR with a configure option for this instead.

@floppym floppym closed this Dec 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants