0

I was trying to debug my CGI script which started with the line:

#!/usr/bin/env python3

Of course, the problem was that the environment variables (specifically, $PATH) of Apache HTTPd and my shell was different.

After some digging, I discovered that the system-level .profile for the shell sets the $PATH by calling /usr/libexec/path_helper. I verified this by calling /usr/libexec/path_helper and comparing the output with the output of echo $PATH.

The path of Apache HTTPd is different than this value. This makes me assume that the HTTPd sets the value of $PATH manually.

My question is, why? Why would a process set $PATH manually? I presume that /usr/libexec/path_helper is some sort of system standard, no?

So, the question is, why would a process set $PATH manually, instead of calling some sort of system level standard, which /usr/libexec/path_helper seems like a system level standard.

1 Answer 1

1

/usr/libexec/path_helper I've only seen on Mac OS X; daemons (and also cron) on unix typically do not use the same environment (nor the same configuration) as the shell, so there is a notable split between interactive shells (that Apple provides some automagic configuration for) and daemons (especially those not managed by Apple).

Actually, it might be very bad if a network daemon picked up a new path because some user installed some random package to play around with and then suddenly the network daemon is calling the wrong tool from the wrong path...or maybe the network daemon needs a specific version of software X, not the one from the system-wide path system...

(I by the way completely disable /usr/libexec/path_help and set PATH manually everywhere, but I more or less know what trouble I'm getting into by doing things that way.)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.