Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Apr 2016 14:07:04 +0200
From:      Bertram Scharpf <lists@bertram-scharpf.de>
To:        freebsd-questions@freebsd.org
Subject:   Re: Why is www's $PATH only /usr/bin:/bin?
Message-ID:  <20160427120704.GA77440@becker.bs.l>
In-Reply-To: <20160426194048.GA31481@box-fra-01.niklaas.eu>
References:  <20160426194048.GA31481@box-fra-01.niklaas.eu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, 26. Apr 2016, 21:40:48 +0200, Niklaas Baudet von Gersdorff wrote:
> I figured that www's $PATH is only /usr/bin:/bin. Why is that if
> /etc/login.conf says the following?
> 
>     default:\
>     --------8<--------
>         :path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin ~/bin:\
>     --------8<--------

> The thing is that I want to run something in /usr/local/bin with PHP's
> 
>     shell_exec($cmd);
> 
> but that's not working because it's not in $PATH.

I wondered as well about this behaviour sometimes. The
default path from login.conf will be set at login. Yet, the
www daemon is started from rc and this is not understood to
be a login. The perverse thing is that when you do a
"/usr/local/etc/rc.d/apache24 restart" from the command
line, then the PATH variable will contain the value you
expect.

I recommend to include a line into your Apache configuration
(or whichever HTTP server you use) like

  SetEnv PATH /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

Cron does the same by "PATH=..." as you can see in
"/etc/crontab". There is no possibility to do this in lpd,
wherefore I wrote a bug report. Have a look at the
description.

  <https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=205604>;

Bertram


-- 
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160427120704.GA77440>