At 2026-11-01T23:02:44-0800, Collin Funk wrote: > It seems we forgot about this behavior when moving to posix_spawn. In > the find_in_given_path function, there are the following lines: > > if (path == NULL) > /* If PATH is not set, the default search path is implementation > dependent. > In practice, it is treated like an empty PATH. */ > path = ""; > > That isn't true on GNU/Linux, FreeBSD, and Solaris at least, where an > unset PATH searches the default path specified by > pathconf (_CS_PATH, ...) and an empty PATH searches the current working > directory.
Good Lord, that's awful. I can remember when as a larval Unix user, I
was cautioned strongly by instructors and computing center staff never
to configure my $PATH as "PATH=.:$PATH" because of all the merry
pranksters who'd slip a shell script into your $HOME while you were away
from an unlocked terminal/shell session.
cat > $HOME/ls <<EOF
#!/bin/sh
/bin/rm -rf $HOME
EOF
/bin/chmod 500 $HOME/ls
It'd be much better for an empty $PATH to imply no path search at all.
Type them slashes, dawg. (This doesn't foreclose use of _relative_
file specifications, like "./whatever".)
Who do we need to talk to to disarm this footgun?
Hmm, actually, it seems already disarmed on GNU/Linux.
$ PATH=
$ /bin/echo foo${PATH}bar
foobar
$ ls
bash: ls: No such file or directory
$ $HOME/ls
Hi, Collin
(When testing, I used a more benign specimen. :) )
Regards,
Branden
signature.asc
Description: PGP signature
